In my previous post I listed some reasons for moving your blog or other web based projects to an unmanaged Virtual Private Server. For those who feel they have what it takes to make take the plunge and get their hands dirty, here are some tips for getting up and running. For this I will be using Linode a very popular hosting provider with a large community of users. One thing I like about Linode is it’s support. If you have any issues, you can post a support ticket online. They are usually very fast to respond and pretty helpful. They also have a library full of step-by-step tutorials on setting things up like webservers, databases etc. Another killer feature is what is called “StackScripts”. These are scripts written by users that allow for point and click install of popular server setups. If you’re impatient or don’t want to get your hands too dirty you might want to start out with one of these.
With a VPS you pretty much decide how you’re server is going to be setup and the possibilities are almost endless. So how do you go about moving to your VPS? For the sake of brevity, this article assumes a little more tech knowledge than your average blogger. You should also be familiar with the basics of navigation via the command line. Remember, Google is your friend.
1. Sign up for an account.
Once you have an account created you’ll want to decide what kind of server you want. The web runs on Linux/Unix so that’s what you’re going to be working with. For beginners I would recommend the latest version of Ubuntu. It’s been around for a while and the web is full of forums and howtos dealing with almost anything you want to do with it. Follow the instructions.
During your install you should have been prompted to choose a “root” password. “root” is the Linux equivalent of Admin. You have to power to change anything on your Linode with this account. It is recommended that you create a separate non-root user for day to day use as root has to potential to do great damage if you don’t know what you’re doing. Google it if you’re unsure how.
Once your Linode is created you’re going to want to install some sort of web server. Apache is the most popular these days. Nginx (pronounced engine X) is another popular one. WordPress runs well on what is called a LAMP stack which stands for Linux, Apache, MySQL, PHP. Check out the Linode Library for details on how to set that up.
2. Transfer your files.
Once you have a webserver setup you should be able to reach it by pointing your browser to the ip address Linode assigned to your VPS. Eventually you’ll want your domain name to point there but we’ll cover that later.
Most shared hosting providers provide Secure Shell or SSH access to user accounts. Ubuntu Linux is no different and provides SSH access right out of the box. SSH can also be used to transfer files securely. I recommend WinSCP for Windows users and Cyberduck for Mac users.
Point the software of your choice to your shared hosting account and download the files for your blog to your Desktop. After that point it at your Linode ip address and put those same files into your DOCUMENT_ROOT. This is normally “/var/www/htdocs” for Apache installs.
WordPress stores posts and other data in a MySQL database. You’re going to want to get all that stuff too. Log into your shared hosting account via SSH and on the command line type the following:
mysqldump -h <server> -u <username> -p <password> -c –add-drop-table –add-locks –all –quick –lock-tables <databasename> > sqldump.sql
Replace <server>, <username>, <password> and <databasename> with the appropriate info. If you don’t know it, your hosting provider should be able to assist you.
Use WinSCP or Cyberduck to download the sqldump.sql file that is created and then upload it to your VPS.
Log into your VPS via SSH and type the following:
mysql -u <username> -p <password> -h localhost <databasename> < sqldump.sql
Now your WordPress configuration needs to be updated. Go to your DOCUMENT_ROOT and find the file called wp-config.php. You can open it to edit by typing the following:
Change the lines for DB_NAME, DB_USER and DB_PASSWORD to reflect what you setup when you installed the LAMP stack. DB_HOST should be “localhost” since the MySQL server is running on the same machine as your webserver.
Point your browser to the ip address assigned to your Linode and you’re site should look the same as it does on your old hosting provider’s server.
3. Move your domain name.
I recommend having your domain name registered to a company other than your actual hosting provider as this makes it easier to switch hosting in the future. If you bought your domain from someplace like domain.com or go-daddy.com you should be fine.
The first thing you’re going to want to do is go through your domain company and change your domain’s namservers to Linode’s nameservers. Ask your domain provider for help if you don’t know what this is. Linode’s nameservers ns1.lindode.com, ns2.linode.com etc. ns1 and ns2 should be enough but you can add up to ns5 if you like.
Login to your Linode account through their website and click on DNS manager. Click on add a domain. Enter your domain (without the www) and a contact email address. Make sure “Yes, insert a few records to get me started, using this IP” is selected. Click “Add Master Zone” and you’re done. Basically you’ve just made Linode the manager of your domain and all subdomains. You can change these settings later.
Your domain won’t point to your new server immediately it can take upwards of 24 hours for the change to propagate through the web. To check to see if it’s pointing to your new VPS open a command line in Windows and type:
Or in Mac or Linux:
Replace <yourdomain> with yoru actual domain name. The ip listed should match the one assigned to your VPS by Linode.
4. Cancel your old hosting contract
If everything is working you can now get rid of your old provider.
Now that you have full control of your own server you can make other changes to it or even add a mail server. That’s beyond the scope of this article or even this blog but I encourage you to do the research and figure it out for yourself. Where you go after this is entirely up to you.