Do it your self Hobby

Installing WordPress in Virtualbox using Apache server

Installing WordPress in Virtualbox using Apache server
What you need:

  • Ubuntu 14.04.4 server installed in Virtualbox

Configuring Access to VirtualBox

Turn off your virtual machine. On Virtualbox goto
Settings >> Network >> Adapter 1 (tab) >> Attached to:
Select : Bridge Adapter
Click Ok and run your Virtual Machine

On the Console, enter the command below to check your IP address:

ip addr show

Set static IP address

Change your IP Address:

sudo nano /etc/network/interfaces

Comment this line by adding # in the begining:

#iface eth0 inet dhcp

The following steps should be based on your network address. In this tutorial I will use my Network Address. My network maybe different from yours. If you have no idea about this, you may study a little about setting up network address. Add the following lines

iface eth0 inet static

To save, press ctrl+o and exit ctrl+x
Reboot your VM:

sudo reboot

Check your IP if it applied the setting we did:

ip addr show

Check your IP if it is correct

Install Openssh

Start installing the SSH to your VM

sudo apt-get install openssh-server

You should be able to use Putty to connect to your Virtual Machine. Run your Putty and enter the following details:

  • Host Name:
  • Saved Sessions: MyDemoVM (any name)
  • Click Save and click Open

From here we will start using Putty to configure the server.
[Optional] If you want to setup your Putty to login automatically, you should setup the SSH on your Virtual Machine. To do that, you may wish to read the following article: SET SSH PUBLIC KEY AUTHENTICATION

Install LAMP

Once you are logged in using Putty, you can copy paste the codes from this page. You can paste it by simply right clicking your mouse inside Putty.
Lets start installing Apache first, copy the code below and paste it to your Putty:

sudo apt-get install apache2

Next is MySQL

sudo apt-get install mysql-server

Finally, install Php

sudo apt-get install php5 libapache2-mod-php5

Check Apache if it works. Go to you browser and enter the address of your server, in this tutorial its
apache Installing WordPress in Virtualbox
Check your Php if it works, paste this code in your Putty:

php -r 'echo "\n\nYour PHP is working.\n\n\n";'

Configuring SQL

We will create an SQL database that will be used by the wordpress.
Paste this code, this will ask your SQL root password

mysql -u root -p

Create database named: WP


Add user named: User1

CREATE USER [email protected];

Password is Password1

SET PASSWORD FOR [email protected]= PASSWORD("Password1");

Lastly grant user privilege

GRANT ALL PRIVILEGES ON WP.* TO [email protected] IDENTIFIED BY 'Password1';

Finish it with the following code:


Installing WordPress

Ensure you are in user root directory


Download the latest WordPress


Unzip the file

tar xzvf latest.tar.gz

Make a copy of wp-config.php

cd wordpress
sudo cp wp-config-sample.php wp-config.php

Create directory where we will save the wordpress files

sudo mkdir /var/www/site1

Copy the wordpress files

sudo rsync -avP * /var/www/site1/

Give the server user access to folder

cd /var/www/site1
sudo chown www-data:www-data * -R

Configuring WordPress

Open WordPress configuration file

sudo nano wp-config.php

Now change the DB_NAME, DB_USER and DB_PASSWORD according to the details below:

/** The name of the database for WordPress */
define('DB_NAME', 'WP');
/** MySQL database username */
define('DB_USER', 'User1');
/** MySQL database password */
define('DB_PASSWORD', 'Password1');
cd /etc/apache2/sites-available

check the files on the folder


Some apache version has different filename. If you see default.conf that is the one we need to copy. But in my case it shows 000-default.conf
Lets copy the file and save it as site1.conf

sudo cp 000-default.conf site1.conf

Edit site1.conf

sudo nano site1.conf

Paste this code:

	ServerAdmin [email protected]
	DocumentRoot /var/www/site1
	<Directory />
		Options FollowSymLinks
		AllowOverride None
	<Directory /var/www/site1>
		Options Indexes FollowSymLinks MultiViews
		AllowOverride None
		Order allow,deny
		allow from all

activate site

sudo a2ensite site1.conf

reload apache

sudo service apache2 reload

Go to your browerser and type the IP Address:
and configure the WordPress.


If you have this error: “Your PHP installation appears to be missing the MySQL extension which is required by WordPress” then type this:

sudo apt-get install  php5-mysqlnd-ms
sudo service apache2 reload