How to setup a LAMP with wordpress on VPS ?

What is a LAMP ?

LAMP means Linux Apache Mysql PHP. It is a set of open source software that you need to run a website, Linux is your operating system, Apache is your web server, Mysql is your database and PHP is your engine to execute php files in your website.

Nowadays everyone is moving on Mariadb instead of Mysql. So in this this tutorial I will install Mariadb instead of Mysql.

Get your root privileges on your VPS, If you have not a VPS you can follow this link here get one of the cheapest VPS on the market. If you already got your VPS just skip to the installation of the LAMP.

Let’s make a VPS on DigitalOcean which cost you $5 Per month with some decent resources that you can run a website.

After you have signing go to Droplets on the sidebar and follow the below on the screen shots :

Put the name of your server and choose $5 per month you can choose more if you want :


Here you can select your server you can choose any server that you like :


Select Ubuntu 140.04 x64 for the Image selection :





Click on Create Droplet.



You are done with creating your first VPS. You will receive an email on your account that will give the details of your logins.

Step One Apache installation.

Apache a very popular webserver that is wide used in the world :

Type the commands below for the installation :

apt-get update

apt-get upgrade

apt-get install apache2

Open your favourite browser and type the ip address of the server in your address bar :

You should get a welcome page of Apache. To get your ip type this command :

ip a s eth0 |grep -w inet |awk '{print $2}' |cut -d"/" -f1

Step Two Mariadb installation.

Mariadb is a fork of mysql that use the binaries of mysql and have lots of improved performance.

apt-get install software-properties-common
<code class="fixed">apt-key adv --recv-keys --keyserver hkp:// 0xcbcb082a1bb943db
add-apt-repository 'deb <a href=""></a> trusty main'
apt-get update

apt-get install mariadb-server

ref : Mariadb.

There will be a prompt on the screen that will ask you a root password for Mysql, you can put any password of your choice.

Step Three PHP5 installation.

Php is one of the most worldwide web scripting language used to display dynamic content on a website.

On your terminal type the following commands :

apt-get install php5 libapache2-mod-php5 php5-mcrypt php5-mysql

Now we need to restart Apache so that the modules shall be active :

service apache2 restart or /etc/init.d/apache2 restart

We can now say that you have a LAMP installed on your server. That’s nice to have a lamp installed but what will you do you don’t have have a content to show to the world :D. Let’s install Word press !!

First Step Download WordPress.

WordPress is an web application where you can create awesome websites and blog. It is both free and priceless.

cd /root/


tar -xvzf latest.tar.gz

mv wordpress /var/www/wp

chown -R www-data: /var/www/wp

Second Step Database configuration.

We will create a databases name wordpress and we will create a user that will be allowed to access this database only.

mysql -root -p

Enter the password that you have entered when installing Mariadb.

On the console type the following command :

mysql>create database wordpress;

mysql>grant all privileges on wordpress.* to 'username'@'%' identified by 'password';

mysql>flush privileges;

Third Step Apache configuration.

We need to configure the ServerAdmin and DocumentRoot :

vim /etc/apache2/sites-enabled/000-default.conf

Modify the ServeAdmin and DocumentRoot as below :

<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.

ServerAdmin [email protected]
DocumentRoot /var/www/wp

# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

Save the file.

service apache2 restart or /etc/init.d/apache2 restart

We have installed WordPress and we need to configure. To access the configuration page of wordpress type the server ip in your browser :

Choose your language for installation.

langwordpressReplace the values that the field below that you have configured previously on the database configuration part.

dataworpressYou should get this page below :

sussFill the blank with your desired information I fill some sample data :


Click on install WordPress, after you will be redirected to the login page and you will be ask to enter the login that you have just created on the previous page.

Once you login you will get you dashboard and here you are with a fully working WordPress live on internet.


Here is you Dashboard :


Keep in touch guys, Im sure that you will make beautiful website and blog from it.

Article by Ash

“Your eyes can deceive you. Don’t trust them.” – Obi-Wan Kenobi