How to Install Apache on Ubuntu Server 14.04

Apache2 is the most popular Web Server Implementation for Ubuntu Server 14.04. In This Tutorial we are going to learn how to install Apache on Ubuntu Server 14.04. In Addition to installing Apache on Ubuntu Linux, we will also learn how to create and configure Apache Virtual Host and host a simple static website on Ubuntu Server.

Install Apache on Ubuntu 14.04

Apache web server for Ubuntu Linux provides by the apache2 package. We can install Apache2 on Ubuntu using apt-get install command.

sudo apt-get update

sudo apt-get install apache2

Then start the Apache web server using service command.

sudo service apache2 start

Now if you type your server IP address on the web browser you should get the Ubuntu Apache2 default web page.

Install Apache on Ubuntu Server 14.04
  • Ubuntu Apache2 main configuration file is /etc/apache2/apache2.conf file.
  • Default DocumentRoot is /var/www/html folder. You can host your website instantly by putting your website content into the /var/www/html folder.

Configure Apache Virtual Host in Ubuntu Linux 14.04

So now let’s see how to host a static website on Ubuntu Apache Server. For this tutorial I am going to use the domain name And I am going to host in /var/www/example folder.

  • Domain Name :
  • Document Root : /var/www/example
Step One

Create the Document root

First, create the folder /var/www/example using the mkdir command.

sudo mkdir /var/www/example

Then we need to make apache group www-data as the group owner of the /var/www/example folder and also give write permission to the group.

sudo chgrp www-data /var/www/example/

sudo chmod g+rwX /var/www/example/

sudo chmod g+s /var/www/example/

  • chgrp command will change the group owner of the /var/www/example/ directory to apache www-data group.
  • chmod g+rwX command will give read write access to apache group
  • chmod g+s command ensure that www-data group will be the group owner of every new files and folders create inside the /var/www/example/ folder.
Step Two

Create the Virtual Host

We configured document root for the our domain name, now we need to create the apache virtualhost for the www.example.con domain.

Ubuntu Apache Virtual Host Configuration file should be create inside the /var/www/site-availe directory using .cong extension.

touch /etc/apache2/sites-available/example.conf

Now open example.conf file we created, using a text editor and add the following virtual host configuration.

<VirtualHost *:80>



DocumentRoot /var/www/example/

ErrorLog /var/log/apache2/

CustomLog /var/log/apache2/ combined


Step Three

Enable the virtual host

Now we need to enable the virtual host using a2ensite command. Then restart the apache server using service command.

sudo a2ensite example.conf

sudo service apache2 restart

a2ensite enable ubuntu apache virtual host

Ok, now we have configured the apache virtual host for our domain name Now all we have to do is put content of the Website to /var/www/example folder and point to our server IP address using DNS.

Just like that you can create as many virtual hosts as you want and host multiple website on your Ubuntu server.

What we Learned ?

In this tutorial learned how to install and configure a basic Web server on Ubuntu Linux 14.04 using Apache Web Server.

First, we Installed Apache on Ubuntu 14.04 using apt-get install command. Then we learned to configure Apache Virtual Host on Ubuntu Linux to host multiple Web sites.