Moving website to a new VPS

I used to run my web server at home, but I decided that for traffic reasons it would be better to just rent a VPS (Virtual Private Server). The first one I tried was IT-staden (then called “serverconnect.se”), the best thing that can be said about it is that it was cheap…. I then decided to try something else, so I picked Blanye hosting, which is also cheap, but looks like it has better specification VPS’s, and it looked like it’d actually work reliably. These are my notes from the transfer from one VPS to another, it’s mostly for my own use, should I need to do it again sometime in the future, but maybe someone else can use it too.

1. Move files

This was pretty easy, I just copied everything under /var/www/ to the new server. And made a backup of everything on the server.

2. Move database

First I made copies of all the individual databases with this command:
mysqldump -u USERNAME -pPASSWORD DATABASENAME > FILENAME.sql

Then created the databases in phpmyadmin on the new server and importet the databases with this command:
mysql -u USERNAME -pPASSWORD DATABASENAME < FILENAME.sql

2b. Move user privileges

I have some different users set up for the MySQL database. Instead of creating them again I wanted to move them, luckily it’s pretty easy as described here: Copy export MySQL user priviledges

3. Web server setup

I run multiply websites on the server, so I set up some Virtual Hosts

For the WordPress blog I needed to use a .htaccess file to rewrite the urls (the Apache2 module “mod_rewrite”, this has to be enabled in the Apache2 web server:
a2enmod rewrite

This also has to be enabled in the virtual hosts we set up earlier, this change needs to be made:
“None” should be “All”, like it is here:

<Directory /var/www/www.smovs.dk/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>

The last.fm widget I use on the pages use cURL, so I had to add that to PHP5 too:
apt-get install curl libcurl3 libcurl3-dev php5-curl php5-mcrypt

Now restart the web server and cross your fingers:
/etc/init.d/apache2 restart

4. FTP server

To enable automatic updates in WordPress, it needs to have access to an ftp server it can transfer the files to. So I installed ProFTPD on the VPS:

apt-get install proftpd

I choose to run the server in standalone mode, ‘cos somehow it doesn’t work if I choose the inetd mode…

Now add a new user:

adduser wordpress

Choose a password for the user and just accept [enter] the rest of the options.

Now we need to let the wordpress user access the blog, first goto the users home director and then make a symbolic link to the website dir:

cd /home/wordpress
ln -s /var/www/blog

And we’ll change the owner of the WordPress dir to the wordpress user:

chown wordpress -hR /var/www/blog/

Now WordPress should be able to update itself and its plugins, all you have to do is to input the credentials for the wordpress user we just set up in the WordPress admin panel.

DiggDeliciousGoogle BuzzSlashdotRedditShare

Related Posts:


This entry was posted in Linux, VPS and tagged , , , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>