This blog was running on Stefan’s DSL connection and with me tinkering with it I was using up his bandwidth. Usually when he was trying to connect to the office and get some work done.

I have a very good connection to the Internet via Optimum Online. It’s a dynamically assigned address but does not change and even if it does I run a dynamic DNS client to tell my DNS server when I’ve moved. So I decided that I would move the blog and change the whole URL. Easy right?

  1. I wanted to create the virtual host blog.dembowski.net on my basement web server dixie.dembowski.net while maintaining both virtual hosts. Oh yeah and use only one IP address.
  2. I wanted to change the host name and the web page URL from http://www.dembowski.net/wordpress/ to http://blog.dembowski.net/.

Setting up the virtual server

I added to my DNS zone dembowski.net a new record for blog.dembowski.net:

blog.dembowski.net. 3600 IN CNAME dixie.dembowski.net.

A while back I switched my server’s Linux distribution from Fedora to SuSE. One of the appeals was that SuSE comes with a reasonable configuration tool called yast.

Yast has a section for creating virtual hosts in Apache, and I thought how hard can this be?

After killing lots of time and totally breaking the web server configuration I ended up removing the Apache packages, deleting /etc/apache2 directory and /etc/sysconfig/apache2 file (options and configs remain even if you remove the software packages).

# rpm -e apache2-mod_php5 apache2-prefork apache2
# rm -rf /etc/apache2 /etc/sysconfig/apache2

I used yast to re-install the same packages, ran the online update, configured apache and got back a basic no frills web server running.

Most Linux distributions have put a conf.d directory in Apache’s configuration directory. It works like this: any file with the extension .conf gets included in the configuration. I knew about this but figured using yast would be easier.

So much for that idea. I went into yast one last time to enable the apache modules php5 and rewrite. Enabling mod_rewrite is not enough, you also need to turn on the FollowSymLinks option or it just does not work.

The configuration file I created in /etc/apache2/conf.d contains the following lines

NameVirtualHost *

<VirtualHost *>
ServerName dixie.dembowski.net
DocumentRoot /srv/www/htdocs
ServerAdmin webmaster@dembowski.net
ErrorLog /var/log/apache2/dixie.dembowski.net-error_log
CustomLog /var/log/apache2/dixie.dembowski.net-access_log combined
</VirtualHost>

<VirtualHost *>
ServerName blog.dembowski.net
DocumentRoot /srv/www/htdocs/wordpress
ServerAdmin webmaster@dembowski.net
RewriteEngine On
<Directory /srv/www/htdocs/wordpress>
Options +FollowSymLinks
AllowOverride All
</Directory>
ErrorLog /var/log/apache2/blog.dembowski.net-error_log
CustomLog /var/log/apache2/blog.dembowski.net-access_log combined
</VirtualHost>

Not too complicated really. Now when I point my web browser to either host name I get two different web pages.

Preparing WordPress

First off read this whole article, and seriously this part. The WordPress documentation is really good and helped a lot. Normally you would want to do one or the other; being a “challenging” person I was determined to do both.

I did NOT read the documentation. There is a step where you need to tell WordPress the URI for referencing itself. The documentation says Update Options -> Logout -> “Do not try to open/view your blog now!” They are not kidding around, WordPress sends you to the web page it thinks it is running on and not the host that it actually is running.

Restoring the web server files and directory onto the new box was not a problem. And the mysql backup was edited with vi and I changed all of the references from http://www.dembowski.net/wordpress/ to http://blog.dembowski.net/. I had to have missed one because every time I went to the web page http://blog.dembowski.net/ I was sent to the old server whenever I clicked on anything including the admin web pages.

There probably is a better way to do this but I eventually just put into my workstations hosts file the IP address of the new box and claimed it was www.dembowski.net. Just to play it safe I shut down the old web server, logged into the new box and fixed all of the options with the new info. Once I was all done I removed the bogus entry in my hosts file.

WordPress’s PHP scripts on my box kept running out of memory and crashed. I changed the file /etc/php5/apache2/php.ini and changed the memory_limit from 8M to 1632M That seems to have taken care of it.

All that was left to do is make sure that anyone going to the old web page gets sent to the new one. On the old server I changed the .htaccess file in the wordpress directory to now read

RewriteEngine On
RedirectMatch ^/wordpress/(.*) http://blog.dembowski.net/$1 [L,R]

Apache’s mod_rewrite rocks. This took any web requests for http://www.dembowski.net/wordpress/anything and redirected the web browser to go to the new URL with http://blog.dembowski.net/anything.

Blog successfully migrated to a new host and a new directory. Next up putting SSL back on one of my virtual web servers.