How to install Apache in Ubuntu 14

This article shows the steps required to install Apache in Ubuntu 14. Apache web server is the most used and reliable web server of the world.

This tutorial assumes you have an Ubuntu server, with full root access. The first step is access your Ubuntu server with root by SSH. We will explain how to install Apache httpd and its modules, PHP, Perl and Python.

Install Apache in Ubuntu: starting the process

First of all, you need to update your server packages with apt-get

sudo apt-get update

After completed, you can install Apache with this command:

 sudo apt-get install apache2 apache2-doc apache2-utils

Now, by default, the root folder of the apache is located in /var/www/html. Let’s enter this directory by issuing this command:

cd /var/www/html

To test Apache, you need to know the ip address of the server. There are two methods to do that:

Method #1 , shows the current hostname of the server. This hostname usually points to the correct IP.

hostname

Method #2, this prints the current IP address of the server, from the ifconfig output.

ifconfig | grep inet | awk '{ print $2 }'

Now the IP address is known. We can now test the installed apache webserver. Open your favourite browser, just type your IP or hostname:

install apache in ubuntu 14 - completed process

Install Apache modules

To install specific apache modules, we can first list the available modules. We should first run this command:

sudo apt-cache search libapache2*

To install one module, just issue these commands. The first command installs the module, and the second a2enmod, enables it into Apache.

sudo apt-get install [name-of-the-module]
sudo a2enmod [name-of-the-module]

Install apache with PHP, Perl and Python modules

You can easily install apache in Ubuntu with these common programming modules, by running these commands:

Install PHP:

sudo apt-get install libapache2-mod-php5 php5

Then, install Python:

sudo apt-get install libapache2-mod-python

And finally, install Perl:

sudo apt-get install libapache2-mod-perl2

To install MySQL in Ubuntu, you can also read this article: How to install MySQL in Ubuntu
Further documentation about Apache:

Share the Post:
Picture of Gustavo Gallas

Gustavo Gallas

Graduated in Computing at PUC-Rio, Brazil. Specialized in IT, networking, systems administration and human and organizational development​. Also have brewing skills.