Hacks and Hints TechieVarta

Icon

Another Techie Varta

Archive for the ‘web hosting’ Category


Backing up Wordpress MU Site

Monday, February 9th, 2009

Several of us don’t have need for and enthu for an elaborated backup system. Here is a small script that will backups the WPMU site including database and the file system and e-mails it to provided e-mail address. For small site this works perfectly. You can also use it to e-mail the backups to Gmail or msn mail. For automatic backup you can add this script to crontable of your host.

#!/bin/bash
DB=mu
WPMU_ROOT=/srv/www/mu-blogs

dirname=mu-backup-`date +”%m-%d-%y”`
cd /tmp
tmpdir=${dirname}

email=foo at bar . com

/bin/cp -R $WPMU_ROOT $tmpdir
/usr/bin/mysqldump mu > $tmpdir/db_backup.sql

/usr/bin/tar cfz $tmpdir.tgz $tmpdir

echo “Backup of WPMU $dirname” | /usr/bin/mail $email -s “WPMU Backup $dirname” -a $tmpdir.tgz
rm -rf $tmpdir*

Installing Wordpress Mu

Sunday, February 1st, 2009

I recently consolidated several of my blogs to a single WordPress Mu blog site. This allowed me to have a streamlined single user and site administration across all my blogs. Wordpress Mu which stands for WordPress Multi User, is implemented as an extension to our beloved WordPress suite and can run most of the WordPress plugins and themes although there are differences.

Installation

  1. Download latest WordPress Mu from the dowload site.
  2. Unzip WordPress Mu to a place where your web server can find it.
  3. Configure the web server and point it to the Mu site. For Apache the configuration looks like:
  4. 
    <VirtualHost>
     DocumentRoot /srv/www/mu-blogs
     ServerName example.com
     ServerAlias *.example.com
     ServerAdmin root@localhost
      AllowOverride FileInfo Options
     # AllowOverride All
      Order allow,deny
      Allow from all
     CustomLog /var/log/apache2/mublogs-access_log combined
    </VirtualHost>
    

    Look at ServerAlias directive. This allows blogs to have addresses of the form <blogname>.example.com.
    If you would rather use the blog names of the form:
    example.com/<blogname>, you don’t’ need to add the server alias directive.

  5. Now make sure DNS for *.example.com correctly points to your site.
  6. Point the browser to your newly created site, answer simple question and let WordPress Mu install the site and the site is up and running.

Themes

Most of the WordPress themes should work with WordPress Mu theme. For themes to be available for individual blogs, they must be enabled in the admin menu. I wanted all my blogs to use the same theme and did not want to manually edit theme setting in every blog. To achieve this, I replaced the default theme with the theme of my choice. Any future created WordPress blog will automatically inherit the default theme.

Plugins

One thing you noticed when installing plugins is that MU has two plugin directories: <wordpressroot>/wp-content/plugin and <wordpressroot>/wp/content/mu-plugin. Any plugin placed in the <wordpressroot>/wp-content/plugin are available to every blog but still must be activated just like any normal wordpress plugins. The mu-plugin directory is special. Any plugin placed in this directory is automatically activated and all the blogs automatically get it. In addition WordPress Mu does not scan subdirectories under mu-plugin directory. The plugin’s php must be directly placed in the mu-plugin directory.

Happy Blogging!

Drupal: Impressions and Plugins

Saturday, November 3rd, 2007

Readers of this site know that this site runs WordPress for theblogs. Today I want to talk about what I run for my web site. I use great Web Site management software called Drupal. Both WordPress and Drupal are similar in several aspects. Like WordPress, this software is written in PHP and can use MySql as the backend. Both the software are extensible using modules and have a wide variety of modules providing various extensions. Both software allow themes and have a wide variety of themes available.

However, there are several key differences. Drupal is full WebSite management software which also has a blog management feature. WordPress on the other hand is a blog only software and does a great job at it. I could have used Drupal for blog however, I found WordPress before I found Drupal and I was already running WordPress before I built my main site. I am extremely happy with WordPress and do not see a reason for change. I have not experimented with Drupal’s blog feature to know more.

To use Drupal, you should install several plugins.

Essential Drupal Plugins

Site Management Related Modules

  • Category: This software allows you to hierarchically structure your site in tree-like structure. It automatically builds menu as needed.
  • Path Auto: This module automatically creates your URL alias based on page titles and various rules. this can significantly increase search engine ranking.
  • Global Redirect: If path aliases are enabled, the pages on your site are generally accessible using two different paths: default Drupal path and alaised path. This module changes that such that the default Drupal URL results in sending a redirect to the aliased page rather then serving the page. This makes sure that your site is not unnecessarily put in sandbox by Google.

Search Engines Related Plugins

  • Google Analytic: This module provides support for Google Analytics
  • GSiteMap: This module provides on demand Google sitemap generation.

Content Creation Related Plugins

  • TinyMCE: This plugin brings in rich WYSIWYG editor inside Drupal for content creation.
  • Image: : This module allows users to manage Images inside Drupal.
  • Upload Image: This module allows users to upload images on the Drupal website.
  • Weather: I wanted to display weather on my Drupal site. I tried this module and found it to be not very useful. I eventually ended up creating a custom modules. After trying HTML code from Weather.Com and AccuWeather.com, I ended up using AccuWeather.com’s weather related HTML in my custom module.

What I did not like about Drupal?

The Drupal software menu system is non-intuitive. “Site-Building” what does that mean? Modules are enabled in “Site Building” and configured in “Site Configuration”. I wished there was a way to configure the modules as a button as soon as they were enabled. With software like Drupal, you land up with 10s of module. I wish there was a way to organize modules in categories.

The way user authorization is separated from actual module configuration is another thing I don’t like. It is nice that you can see authorization level at a single place, but equally nice will be a way to configure authorization level whenever a module is configured. I suggest that we provide a method to configure authorization both in module level and in user management section.

Drupal and WordPress on the same Site

The great advantage of Open Source Software is that the users have choice. I can run software from different sources and use their strongest parts to come up with a very useful end result. I and based on my reading from the web many others, believe that Drupal is great site management tool and WordPress blogging infrastructure is superior to that of Drupal’s . It is rather easy to run Drupal and WordPress on the same server however it is very difficult to run them in integrated fashion. It will be wonderful to develop a WordPress Module for Drupal and have WordPress site inherit Drupal’s theme or even have its own theme. But, that way they can share the same users.

Another area where the integration will be useful is in sitemap generation. It will be good if there was a way to have Drupal’s sitmap include WordPress sitemap. I had to do some php hacking to get that working.

Create a full featured web/blog host at your home: Part 2

Thursday, October 25th, 2007

Part 1

As promised here is the part 2 of the post.

Setting up Web Server

The next task is to setup your web server. There are several servers you can choose. My favorite is Apache. It comes bundled with most Linux distributions. You probably want to setup the apache server as a virtual host. To setup the virtual server, fire up your favorite editor to configure apache configuration and add something like the following:

<VirtualHost  *:80>
	DocumentRoot /srv/www/htdocs
	ServerName example.com
	ServerAdmin root@localhost
	<Directory /srv/www/htdocs>
		AllowOverride None
		Order allow,den
		Allow from all
	</Directory>
	CustomLog /var/log/apache2/example.log
</VirtualHost>

Restart apache by doing something like /etc/init.d/apache restart. If you took my earlier warning about security seriously, you would have firewall on your server blocking all accesses to your web server. Use your favorite firewall management tool for the server to open hole through server firewall. Suse’s yast makes this process relatively straightforward. I am sure other distributions have something similar.

Edit /etc/hosts on the web server machine and add a host entry for the web server’s IP address as your machine’s NATed IP address. This step is not absolutely essential but it makes life a lot simpler. Fire up firefox on the Linux machine and make sure you can access http://<your-machine’s name>/. If you try to access the same web page from another machine in your network, this is probably very slow. That is because the DNS is resolving your machine’s the hostname as external IP address of your NAT box and the packets are not directly going to your Linux machine. If you have this problem open /etc/hosts on Linux and c:\windows\system32\drivers\etc\hosts on Windows machine and add an entry with webhosts name and its NATed IP address. The entry will look something like:

 192.168.32.8    example.com

At this time you should be able to go to the newly configured host and access the web site. You are now ready to configure blog software.

Setting up Blog Software

Now it is time to setup you blog software. After evaluating several blog software, I decided to use WordPress. I will strongly recommend WordPress to nearly everyone trying to host their blog site. It is easy to administer. There is a very strong community out there. You can easily find plugin for almost anything you want to do. WordPress is based on PHP so make sure you have PHP installed before you start. WordPress also has dependency on MySql make sure you have MySql installed. The next step is to create MySql user.

To create the MySql user do the following:

>mysql -u root -p

Password: <enter mysql password>

mysql>create <db-name>

mysql>use <db-name>

mysql>GRANT ALL PRIVILEGES ON *.* TO

        '<user>'@'localhost' IDENTIFIED BY

        '<db-pass>' WITH GRANT OPTION;

Note down the db-user and db-pass entered in this process.

You are now ready to configure and install the WordPress. Download WordPress and unzip it at a place where your webserver can serve. In the wordpress home directory, there is a file wp-config-sample.php. Copy it to wp-config.php. Edit this file to provide DB name, DB username and DB password.

Fire your Web Browser and point it to the blog’s home directory. Follow on screen direction to complete the WordPress install. You are all set. Drop me a word if you have problem installing.

Happy blogging.

Next time essential WordPress plugins.

Create a full featured web/blog host at your home: Part 1

Wednesday, October 24th, 2007

If you are wondering why will I want to do this. Just scroll down to the FAQ section.

WARNING: Running a server at home is always a security risk. So be careful.

The blog host setup will involve network setup, actual host setup, web server setup, and blog software setup.

Network Setup

You will need a good Internet connection. A cable or FIOS connection will offer good enough bandwidth for your site. In most cases the blog host will share the Internet connection with other machines. You will need a good NAT box. Linksys and Netgear both make lots of good affordable NAT boxes. Most Install the NAT box and connect your Linux machine to the NAT box. If you do not know how to configure NAT box, just Google for it or look at the NAT’s manual.

Next you will need a public hostname so that your friends can find you. I use DynDNS. They offer free web host name in 10s of domains. You may want to sign up with a service which is supported by your NAT box. Sign up with dynamic DNS provider and configure your NAT box with the DNS information. In most cases DNS takes immediate effect however in some cases DNS entries can take up to 72 hours to propagate through the network.

Open a command prompt and type > nslookup <your dns name>. If this resolves to the public IP address of your NAT box, you are all set with DNS configuration.

Web/Blog Host Configuration

For web/blog host you will need a reasonable machine. If you have an old reasonably powered P4 machine, that will be a good candidate. Install an Operating system on the machine. Linux is most suitable web host. It offers good mix security and performance. Unlike Windows most Linux distributions work on old machines lying in your closet. You can use any decent Linux distribution on this machine. I use OpenSuse. Since this machine will be externally accessible update any security patches. Also, configure rather restrictive iptables based firewall.

Next you will need to configure port forwarding on your NAT box. Logon on to your Linux machine and type “ip addr” to get IP the address assigned to your machine. Now logon to admin interface of the NAT box. Find the place where you can configure port forwarding. Configure it to forward port 80 to the IP address of your Linux machine.

In part 2 I will go over the details of Web Server and Blog software configuration.

FAQ

Why do you want to create a website at your home when there are so many other options?

Because I can. Because it is fun. Because I have full control over the software which runs the site. Because it serves my intellect.

Will this slow down your home network?
For most average users, it is not a big deal. Most cable service providers offer you enough bandwidth to run a reasonable site at home. If your site really gets busy and gets too much traffic, you may have to move site to ISP. But, at that time you can also become part of Adsense and earn some money. Most users will never reach that level of usage.