Hi there,

it’s been a while since this small blog went online, but right now it’s time to make changes happen 🙂 First step was a server movement. That requires several steps to take a look at:

Export MySQL Database, Backup Web

Easy to say, just issue

mysqldump -u root -p dbname > dbname.sql

Afterwards, find all the entries of your old Servername in the table wp_options where option_name is site_url and home. Replace them with your new Blog Url.
If you are using Permalinks you might adapt those too (they might be rebuilt within the admin interface). I did that with the exported SQL dump using kwrite.

The web is easy to backup, just created a tar.gz from the webdir

cd /var/www
tar cvzf blog.tar.gz blog/

And scp’d everything to the new location.

Import database and re-deploy web

Easy as it is:

cd /var/www/legendiary/
tar xvzf blog.tar.gz
mysql -u root -p dbname < dbname.sql

Setup Virtualhost

First enable modules

a2enmod rewrite
a2enmod ssl

Then create your own SSL certificate (self signed).

openssl genrsa -des3 -out server.key 1024
openssl req -new -key server.key -out server.csr
cp server.key server.key.org
openssl rsa -in server.key.org -out server.key
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

And copy server.key and sever.crt to an appropriate location where you can point from SSL VirtualHost config.

Then setup the 2 VirtualHosts:

cd /etc/apache2/sites-available
vim site
vim site-ssl

Setup ServerName, ServerAlias, DocumentRoot for the new site. Then within
the basic setup and RewriteEngine On.
If the blog remains in a subdirectory of the site, add another Directory directive also with RewriteEngine on.
It could happen that the default site uses AllowOverride None - if Rewrite is not working change that to All.

For SSL, add a section like this and point to generated server.key and server.crt before.

        SSLEngine on
        SSLCertificateFile    /etc/ssl/certs/server.crt
        SSLCertificateKeyFile /etc/ssl/private/server.key

Enable Site

a2ensite site
a2ensite site-ssl
/etc/init.d/apache2 reload

Hint: a2ensite creates a symbolic link from site-available to sites-enabled. This directory is included within apache2.conf to be loaded automatically.

Forcing Redirect / to blog/

Quite simple: Match on / using ^ as Url start index and $ as end and redirect to /blog/ (watch the /)

        RewriteEngine On
        RewriteRule ^/$ /blog/ [R]

Now for the cleanup stuff within the blog 😉

%d bloggers like this: