How to set up a fully functional web server on Ubuntu 12.04, 14.04 and 15.10

In this tutorial i will go through how to set up a web server on Ubuntu 12.04, 14.04, and 15.10.

If you’re doing this on a local machine. Fire up your terminal and skip to step 2!

If you’re doing this on a remote server via SSH (Secure Shell). Continue as following.

Step 1 – Connect to server

If you’re on Windows. Download any external SSH client. For example PUTTY.

If you’re on linux. Open your terminal and connect to the remote server by using the following command:


Enter your password and continue with step 2.

Step 2 – Update your apt repository

sudo apt-get update

Step 3 – Install Apache

Apache is the main and most important part of the LAMP stack. It will let your clients connect to your server via http (Hyper Text Transfer Protocol).

Run the command:

sudo apt-get install apache2

Now test if it worked properly by going to

If something like this showed up. You know it worked like a charm! 😉



Step 4 – Install MySQL

Next step is to install MySQL. MySQL is the most common Database software/server used in various web applications.

To install MySQL, run the following commands:

sudo apt-get install mysql-server php5-mysql
sudo mysql_install_db

Follow the steps provided by the installation script.

And then run the following command to remove some dangerous default settings.

sudo mysql_secure_installation

This script will also lock down your MySQL server so it can only be reached via localhost.

Step 5 – Install PHP

PHP is the most common server side scripting language used in most web applications. And is a necessery part of the whole LAMP stack.

To install PHP, run the following command:

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

Afterwards you can install various php modules by running the following command:

apt-cache search php5-

This will return a list of available modules and info on them.

To install a module run the command:

sudo apt-get install php5-<module>

Step 6 – Test PHP Processing

Before finishing you might want to test if it all worked as expected. To do this create a new file in your web server root directory by running the command:

sudo nano /var/www/html/test.php


sudo nano /var/www/test.php

(Depending on your version of Ubuntu)

And then type in:

echo "Hello World!";

Now visit

Did it say “Hello World!”?

Yes? Then it worked. You’ve now set up a functional web server. Time to start using it! 😀


Do you have any problems or follow up questions? Comment below or shoot me an email at! 🙂

One Response to How to set up a fully functional web server on Ubuntu 12.04, 14.04 and 15.10

  1. BobbuBrowne says:

    Hello! Cool post, amazing!!!

Leave a Reply

Your email address will not be published. Required fields are marked *