It’s a step by step guide for setting up wordpress on a vanila server (e.g Digital Ocean, don’t know about it? then read Digital Ocean VPS Review) running Ubuntu 12.04 LTS (latest LTS release, recommended for server). With, most of the VPS providers, you can deploy GNU/Linux distribution from their control panel itself, after that, everything will done over the ssh connection.
Step 1. Setting up the server
ssh into the server and create a user (as it’s not a good idea to use root account).
apt-get -y update
adduser user_name --ingroup sudo
Now, logout from the current session and login again with the user newly created above.
Install the web server – Apache (you could also choose nginx)
sudo apt-get install apache2
Now, create a virtual host –
In this tutorial I’ll be using nano editor (a light-weight command line editor) So, if it’s not already installed – then install it using
sudo apt-get install nano.
sudo nano /etc/apache2/sites-available/example.com
and add this contents (change few things according to your need such as domain name, user_name)
If you selected nginx instead of Apache, here is a sample configuration for nginx/wordpress blog.
Then enable the virtual host,
sudo a2ensite example.com
sudo service apache2 reload
Step 2. Installing Dependencies (PHP, MySQL)
During installation process, you will be asked to provide password for MySQL root account.
sudo apt-get install mysql-server
sudo apt-get install php5 libapache2-mod-php5 php5-mysql
For image manipulation, wordpress uses php-gd library, so you need to install that as well,
sudo apt-get install php5-gd
You may have to enable rewrite mod for apache2, to do that simply type :
sudo a2enmod rewrite
sudo service apache2 restart
Step 3. Creating Database
Login with MySQL root account and create the required users and databases (you need to remember these details for wp-config.php)
mysql -u root -p
create database DBNAME;
grant all on DBNAME.* to DB_USER@localhost identified by 'password';
Step 4. Installing WordPress
Download the latest version of wordpress and extract its content.
tar -xzvf latest.tar.gz
For simplicity, you can rename the wordpress directory to something like – your domain name e.g example.com.
mv wordpress example.com
Now, you can manually edit the wp-config.php file or go through the automated installation process (just visit the URL, I assume you have setup DNS correctly, or use IP address instead).
Then add the database details and random strings for session tokens etc and save the file (Ctrl+x, y). Now, rename the file.
mv wp-config-sample.php wp-config.php
That’s set, you’ve successfully installed wordpress, visit the URL/IP_ADDRESS and create the admin user.
Moving your Blog ?
If you’re moving your old wordpress blog to a new server, then you also need to copy
wp-contents directory (from the old one to new server, it’s the directory – that holds your images, themes and plugins). Besides that you will also have to export/import database contents. Use your server control panel or a tool like PHPMyAdmin (which is usually installed on all shared hosting providers) to export your database contents in *.sql format.
I assume you already have an exported database file (*.sql), So you can easily import it, on new server using the single command –
mysql -h localhost -u DB_USER -p DB_NAME < db_backup.sql
Note : If you have any problem during installation, then leave a comment here, we’ll try to figure it out!