Sunday, 7 January 2007

Adding a new WordPress blog to a Debian install

The Debian WordPress package is set up to allow multiple blogs to be hosted on the same server, using Apache's virtual hosts. However, when I looked, I couldn't find any documentation on how to enable this.

This is how I did it, using wordpress and apache2.

Before you start, you must have control over your DNS, and the ability to create CNAME aliases. Add an alias for your web server, giving it the name of the blog that you want to host. In my case, the site is blog.mortia.org.uk.
Firstly, set up the WordPress database and configuration using the supplied example sript:
sudo bash /usr/share/doc/wordpress/examples/setup-mysql -n mortiablog blog.mortia.org.uk

Then we need to configure apache2 to serve WordPress, rather than the site's default index page, for the host blog.mortia.org.uk. I can't remember where this information came from (it was a while ago when I first did this); I think it's a modified version of the example apache configuration from the Debian examples directory.

Start by going to /etc/apache2/sites-available, and copy your default site file 'default' to another name. I used 'blog.mortia'. Then you need to edit it to trigger only for the new hostname that you've set up, and for the root to point to the standard WordPress installation:

  • Remove the outer 'NameVirtualHost *' directive

  • Add a 'ServerName blog.mortia.org.uk' directive inside the VirtualHost section.

  • Change the DocumentRoot from /var/www/ to /usr/share/wordpress/, not forgetting to modify the section too.

  • Change the names of the log files so they don't conflict with your main site.

  • Remove any other aliases etc that you don't want on the blog site.


To get apache2 to pick up this new site, you need to symlink the new config file into /etc/apache2/sites-enabled, and restart the server.

cd ../sites-enabled
sudo ln -s ../sites-available/drup.mortia .
sudo /etc/init.d/apache2 restart

Now you're ready to point your browser to the new URL, and start configuring WordPress as normal. You may need to shift-reload to see the WordPress page.

Update 2007/06/09: added the -n flag, supported by newer versions, to get a reasonable database name.

2 comments:

  1. [...] Andy » Adding a new WordPress blog to a Debian install [...]

    ReplyDelete
  2. I am familiar with this problem, but I was not able to solve it, had to call a person to support, so he helped me. Thank you for sharing your experience! This is useful.
    Richard Brown data room due diligence

    ReplyDelete