After migrating from a shared webhost to a dedicated VPS, the next step is to migrate all my wordpress sites to that 1 VPS instance.

This is basically setting up the wordpress scripts for each site, and writing the apache virtual host for each.

Digital Ocean have guides on configuring multiple virtual hosts on 1 machine, and also how to setup multiple wordpress manually.

I will be summarizing the steps.

1. Setup MySQL

Firstly, you need to setup your mysql database to be used with your wordpress.

In this example, we are using wp_myblog1 for database name, wp_myblog1 for the mysql user and secretpassword.

mysql -u root -p

# Setup your database name, and a mysql user
CREATE USER wp_myblog1@localhost;
SET PASSWORD FOR wp_myblog1@localhost= PASSWORD("secretpassword");

GRANT ALL PRIVILEGES ON wp_myblog1.* TO wp_myblog1@localhost IDENTIFIED BY 'secretpassword';

2. Setup wordpress scripts

Download and copy wordpress (the scripts) to some directory eg. /var/www/

# Download Wordpress
cd ~
tar xzvf latest.tar.gz

cd /var/www
sudo mkdir
cp ~/wordpress/wp-config-sample.php ~/wordpress/wp-config.php
sudo rsync -avP ~/wordpress/ /var/www/

cd /var/www/myblog1
sudo chown www-data:www-data * -R
sudo usermod -a -G www-data root

3. Configure Wordpress

Configure wp-config.php to let wordpress know how to connect to your mysql.

cd /var/www/myblog1
sudo nano wp-config.php

Edit these:

define('DB_NAME', 'wp_myblog1');

define('DB_USER', 'wp_myblog1');

define('DB_PASSWORD', 'secretpassword');

Save and exit.

4. Setup Virtual Host

Setup Apache to let it know there are multiple virtual hosts to the machine.

cd /etc/apache2/sites-available
sudo cp 000-default.conf
sudo nano

NOTE: You must have a .conf extension

Edit as follows:

<VirtualHost *:80>
  ServerAlias *

  DocumentRoot /var/www/

  <Directory />
    Options FollowSymLinks
    AllowOverride None
  <Directory /var/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    allow from all

Enabled this new virtual host, and restart Apache

sudo a2ensite
sudo service apache2 reload

That’s it!

You have configured for 1 wordpress.

To configure for multiple wordpress, repeat with eg myblog2




Back to Home