This weekend I migrated my blog to a new vps, the article describes how to configure and install a blog based on wordpress with lighttpd and mysql. The reference platform is Debian Squeeze.
1. Backup your blog
From old vps, stop Service
/etc/init.d/lighttpd stop /etc/init.d/mysqld stop
Backup database
cd /root mysql -u wp_admin -p wordpress > ./wordpress_db_backup.sql tar -pczf wordpress_db_backup.sql.tar.gz ./wordpress_db_backup.sql
Backup content
tar -pczf sitebackup.tar.gz /var/www/yourwordpressblog/
2. Copy data from old vps
From new vps, transfer site backup
scp root@oldvps:/root/sitebackup.tar.gz ./
Transfer database backup
scp root@oldvps:/root/databasebackup.tar.gz ./
3. Install and Configure Mysql
Install MYSQL
apt-get install mysql-server mysql-client
Create Password for the Mysql user root
mysqladmin -u root password yourrootsqlpassword
Create database
mysqladmin -u root -p create wordpress
Set permission to user wp_admin on database with name “wordpress”
mysql -u root -p GRANT ALL PRIVILEGES ON wordpress.* TO 'wp_admin'@'localhost' IDENTIFIED BY 'wp_admin_password'; GRANT ALL PRIVILEGES ON wordpress.* TO 'wp_admin'@'localhost.localdomain' IDENTIFIED BY 'wp_admin_password'; FLUSH PRIVILEGES; quit;
Extract dabase backup
tar xvfz wordpress_db_backup.sql.tar.gz
Restore database
mysql -u wp_admin -p wordpress < wordpress_db_backup.sql
4. Install and configure Lighttpd with php
Install lighttp
apt-get install lighttpd
Install php
apt-get install php5-cgi php5-mysql php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl
Configure Lighttpd
ln -s /etc/lighttpd/conf-available/05-auth.conf /etc/lighttpd/conf-enabled/05-auth.conf ln -s /etc/lighttpd/conf-available/10-fastcgi.conf /etc/lighttpd/conf-enabled/10-fastcgi.conf ln -s /etc/lighttpd/conf-available/10-simple-vhost.conf /etc/lighttpd/conf-enabled/10-simple-vhost.conf ln -s /etc/lighttpd/conf-available/15-fastcgi-php.conf /etc/lighttpd/conf-enabled/15-fastcgi-php.conf
Edit /etc/lighttpd/lighttpd.conf and enable “mod_rewrite”
From this:
# "mod_rewrite";
to this:
"mod_rewrite"
Save and close.
Configure wordpress site on lighttpd
Edit /etc/lighttpd/conf-available/10-simple-vhost.conf
Insert:
## Your wordpress blog
$HTTP["host"] == "www.yourwordpressblog.com" {
server.document-root = "/var/www/yourwordpressblog/"
server.errorlog = "/var/log/lighttpd/yourwordpressblog/error.log"
#accesslog.filename = "/var/log/lighttpd/yourwordpressblog/access.log"
url.rewrite = (
"^/(wp-admin|wp-includes|wp-content|download)/(.*)" => "$0",
"^/(sitemap.xml|sitemap.xml.gz|robots.txt)" => "$0",
"^/(.*.php)" => "$0",
"^/(.*)$" => "/index.php/$1"
)
url.access-deny = ("wp-config.php")
}
#OPTIONAL: Secure rules to protect /wp-admin/
auth.backend = "htdigest"
auth.backend.htdigest.userfile = "/etc/lighttpd/.passwd"
#auth.debug = 2
auth.require = ( "/wp-admin/" =>
(
"method" => "digest",
"realm" => "Authorized users only",
"require" => "valid-user"
)
)
#OPTIONAL: Redirect rule in case of multiple domain
$HTTP["host"] =~ "www.yourwordpressblog.it|yourwordpressblog.it|www.yourwordpressblog.net|yourwordpressblog.net|www.yourwordpressblog.org|yourwordpressblog.org" {
url.redirect = ( "^/(.*)" => "http://www.yourwordpressblog.com/$1" )
}
Save and close.
Create Log directory
mkdir /var/log/lighttpd/yourwordpressblog
Set Permission
chown www-data:www-data /var/log/lighttpd/yourwordpressblog
Optional step, to protect /wp-admin/ folder create “.passwd” file:
Install htdigest
apt-get install apache2-utils
Create “.passwd” file
htdigest -c /etc/lighttpd/.passwd ‘Authorized users only’ administrator
Exctract sitebackup.tar.gz
tar xvfz sitebackup.tar.gz
Move the content of the blog in /var/www/yourwordpressblog
mv ./sitebackup /var/www
Set permission:
chow -R www-data:www-data /var/www/yourwordpressblog
Restart lighttpd
/etc/init.d/lighttpd restart
Now the blog has been migrated to the new vps, comments are available to you if you have any suggestions.
NOTE:
If permalink don’t work, and return error 404, check if rows below are there :
# BEGIN WordPress
<IfModule mod_rewrite.c>
ErrorDocument 404 /index.php?error=404
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Thanks,



