Linode Tutorial: How To Move Your WordPress Blog to Linode
Want to easily transition your existing Wordpress blog to Linode? Check out this Linode tutorial. By Ray Wenderlich.
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress, bookmark, personalise your learner profile and more!
Create accountAlready a member of Kodeco? Sign in
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress, bookmark, personalise your learner profile and more!
Create accountAlready a member of Kodeco? Sign in
Contents
Linode Tutorial: How To Move Your WordPress Blog to Linode
15 mins
Setting up a LAMP Server
Again, another guide has got us covered here. Just run through this excellent guide on installing a LAMP server on Ubuntu 9.10 and you’ll be up and running in no time.
At this point, I’d recommend making a little test index.php script inside your public_html directory, then browse to it from your local machine to make sure everything works. You can use a very simple index.php like the following:
<?php echo 'Hello, PHP!'; ?>
To test this out, you’ll need to set up the /etc/hosts file on your local machine to map your domain name to your new Linode server’s IP.
Just add the following line to /etc/hosts:
x.x.x.x www.yourdomain.com
Then use your web browser on your local machine to browse to your domain. If all works well, you should see the results from your index.php script!
Migrating WordPress
Ok now onto the fun part – migrating the WordPress blog over! There are seven quick steps to make this happen.
1. Go to your old web server and made a backup of the entire WordPress database, as well as WordPress’s wp-content folder.
Save the resulting files to your local PC, and then copy them to your Linode via scp (change the port to whatever you set up as the SSH port):
scp -P 30000 wordpress_db_backup.sql username@x.x.x.x:/home/username scp -P 30000 wordpress_content_backup.zip username@x.x.x.x:/home/username
2. Make a new database for your WordPress data on your Linode box and import the old database contents:
mysql -u root -p create database wordpress use wordpress; grant all privileges on wordpress.* to 'username'@'localhost' identified by 'password'; exit; mysql -p -d wordpress < /home/username/wordpress_db_backup.sql
3. Move to the public_html directory for your site, and download WordPress according to the following instructions from the Linode WordPress guide:
wget http://wordpress.org/latest.tar.gz tar -xzvf latest.tar.gz rm latest.tar.gz mv wordpress/* ./ rmdir wordpress cp wp-config-sample.php wp-config.php
4. Edit wp-config.php to specify the database name, username, and password that you specified above.
5. Unzip your old wp-content data into the wordpress installation:
mv wp-content wp-content-old sudo aptitude install unzip unzip /home/username/wordpress_content_backup.zip
6. You should enable mod_rewrite in Apache because WordPress uses it to rewrite URLs.
a2enmod rewrite
7. You need to set up your .htaccess file. The .htaccess file is a set of directives to Apache that you can use to protect certain files and folders, tweak settings, and rewrite URLs, among other things.
All you have to do is create a new file named .htaccess in your public_html directory, and add the following to the file (note you'll have to replace the last section with data from WordPress):
<files .htaccess> order allow,deny deny from all </files> # disable the server signature ServerSignature Off # protect wpconfig.php <files wp-config.php> order allow,deny deny from all </files> # who has access, who doesn't order allow,deny allow from all # disable directory browsing Options All -Indexes # set the canonical url RewriteEngine On RewriteCond %{HTTP_HOST} ^ryourdomain\.com$ [NC] RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [R=301,L] # wordpress settings - from Settings\Permalinks RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L]
And that's it! At this point you can fire up www.yourdomain.com in your web browser on your local PC, and if all works well your WordPress blog should show up like normal!
Final Details
There are two more details you'll have to fix up that you might not notice at first glance.
First, you'll probably want to set up a SMTP server so WordPress can send you mail (such as when a comment needs moderation). To do this, just run through this this handy guide from Linode - it just takes a couple minutes.
Second, you'll want to set up the permissions on your wp-content/uploads directory so that WordPress can write files to this directory. You can fix this by changing the group of your web site directories to the group apache runs under (www-data) and setting the permissions of wp-content/uploads to 775.
cd /srv/www sudo chgrp -R www-data * cd yourdomain.com/public_html/wp-content sudo chmod -R 755 uploads/
Once you're satisfied everything is working, you can go to your DNS provider (I use dnsmadeeasy.com) and switch the A record to point to your new server's IP.
With my DNS provider, it just took about half an hour for the changes to take effect!
And That's a Wrap!
I'm loving the new VPS for this site - the performance seems a lot better, and I love being able to customizer the server however I want. Everything about the Linode server has been great so far, and they did a great job making everything go smoothly with their excellent documentation!
Let me know if you have any questions about Linode or doing a WordPress migration, or if you are a Linux guru and have tips for additional things I should/shouldn't do! :]
References:
- The Linode Library - Probably was my #1 reference!
- Slicehost Article about securing a Slicehost node, which applies here as well.
- Great summary of the configuration steps from the various guides. I used this guy's referral code to thank him for his good work!
- Almost Perfect HTAccess File for WordPress Blogs - Used this as a reference for constructing my htaccess file.