The Apache HTTP server is the world’s widest-used web server. It allow many powerful features including dynamically loadable modules, robust media support and extensive integration with other popular software packages.

Install Apache

Enter the below command on your server console to install Apcahe server:

[[email protected] ~]# sudo apt-get install apache2 apache2-doc apache2-utils

Configure the Multi-Processing Module

1. Apache 2.4 provides a range of multi-processing modules (MPMs) to manage connections. The default MPM is the event module, although the prefork module is still recommended if you are using regular PHP.

The Prefork Module

You need to open /etc/apache2/mods-available/mpm_prefork.conf file in your favorite text editor and edit the some values which required:

[[email protected] ~]# vi /etc/apache2/mods-available/mpm_prefork.conf

# prefork MPM # StartServers: number of server processes to start # MinSpareServers: minimum number of server processes which are kept spare 
# MaxSpareServers: maximum number of server processes which are kept spare 
# MaxRequestWorkers: maximum number of server processes allowed to start 
# MaxConnectionsPerChild: maximum number of requests a server process serves
<IfModule mpm_prefork_module> 
StartServers 4 
MinSpareServers 20 
MaxSpareServers 40 
MaxRequestWorkers 200 
MaxConnectionsPerChild 4500 
</IfModule>

2. The event module on Ubuntu 14.04 is enabled by default. Disable and enabled the prefork module:

[[email protected] ~]# sudo a2dismod mpm_event
[[email protected] ~]# sudo a2enmod mpm_prefork

3. Restart Apache:

[[email protected] ~]# sudo service apache2 restart

The Event Module

1. If you want to keep your event module available, these settings are suggested for a 2 GB server only.

Open the file /etc/apache2/mods-available/mpm_event.conf in your favorite text editor and edit the some values which required:

[[email protected] ~]# vi /etc/apache2/mods-available/mpm_event.conf
# event MPM 
# StartServers: initial number of server processes to start 
# MinSpareThreads: minimum number of worker threads which are kept spare 
# MaxSpareThreads: maximum number of worker threads which are kept spare 
# ThreadsPerChild: constant number of worker threads in each server process 
# MaxRequestWorkers: maximum number of worker threads 
# MaxConnectionsPerChild: maximum number of requests a server process serves
<IfModule mpm_event_module> 
StartServers 2 
MinSpareThreads 25 
MaxSpareThreads 75 
ThreadLimit 64 
ThreadsPerChild 25 
MaxRequestWorkers 150 M
axConnectionsPerChild 3000 
</IfModule>

2. Restart Apache:

[[email protected] ~]# sudo service apache2 restart

Configure Virtual Hosting

Apache supports name-based virtual hosting, which enables multiple domains to be hosted on a single server with a single IP Address. While there are various ways to set up virtual hosts, the following approach is suggested.

1. You have to disable the default Apache virtual host:

[[email protected] ~]# sudo a2dissite 000-default.conf

2. Now you need to create an web4linux.com.conf file in /etc/apache2/sites-available using your favorite text editor, replacing domain example of web4linux.com with your own domain URL in both the configuration file and in the file name:

[[email protected] ~]# vi /etc/apache2/sites-available/web4linux.com.conf
<VirtualHost *:80> 
ServerAdmin [email protected] 
ServerName web4linux.com 
ServerAlias www.web4linux.com
DocumentRoot /var/www/web4linux.com/public_html/ 
ErrorLog /var/www/web4linux.com/logs/error.log 
CustomLog /var/www/web4linux.com/logs/access.log combined 
</VirtualHost>

If you want to add another website in apache or host you need to process the same step with another domain.

If you want to enable the perl,you have to add below line in file /etc/apache2/sites-available/web4linux.com.conf

[[email protected] ~]# vi /etc/apache2/sites-available/web4linux.com.conf
Options ExecCGI 
AddHandler cgi-script .pl

3. Build directories for the logs of your websites, and replace web4linux.com with your own domain information:

[[email protected] ~]# sudo mkdir -p /var/www/web4linux.com/public_html 
[[email protected] ~]# sudo mkdir /var/www/web4linux.com/logs

4. You need to enable the site:

[[email protected] ~]# sudo a2ensite web4linux.com.conf

5. Restart Apache:

[[email protected] ~]# sudo a2ensite web4linux.com.conf

Apache Mods and Scripting

Install Apache Modules

One of the strengths of Apache is its ability to customize modules. For Apache modules the default installation directory is the directory /etc/ apache2/mods-available/.

1. Below are the list available Apache modules:

[[email protected] ~]# sudo apt-cache search libapache2*

2. If you want to install any desired modules:

[[email protected] ~]# sudo apt-get install [module-name]

3. All mods are located in the / etc/apache2/ mods-available directory. Edit the.conf file of any module installed, if necessary, and then enable the module:

[[email protected] ~]# sudo a2enmod [module-name]

4. Enter the below command to disable a module that is currently enabled:

[[email protected] ~]# a2dismod [module-name]

That’s all about the installation of Apache in Ubuntu 14

Thankyou…