This post describe about how to install Apache2  web server in Ubuntu Latest version, it is an open-source multi-platform web server. We have already discussed Apache installation on previous post.

Update and install necessary packages, 

# apt-get update

Install apache server package,
 
# apt-get install apache2  -y

Once you have installed apache check that web server version and Moudles,

Version :
 
# apache2 -version
Server version: Apache/2.4.10 (Ubuntu)
Server built:   Jul 24 2015 17:25:18


Modules :
 
# apache2ctl -M

Loaded Modules:
 core_module (static)
 so_module (static)
 watchdog_module (static)
 http_module (static)
 log_config_module (static)
 logio_module (static)
...
...


Disable listing directories / Files on browser :

Do you want to disable listing directories or files for secure your files from the hacker, Open the main apache2.conf file and update following lines in root directory  
 
# vim /etc/apache2/apache2.conf

<Directory /var/www>
    Options  Indexes FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>

change to 
 
<Directory /var/www>
        Options ExecCGI FollowSymLinks IncludesNOEXEC SymLinksIfOwnerMatch
        AllowOverride None
        Require all granted
</Directory>

The user requests a directory from the server, by default apache look to a file index.html  We want to tell our web server to prefer .php. So we will create Apache server look for an index.php file first.

Open a dir.conf file and make sure the below lines should be into it.
 
# vim /etc/apache2/mods-enabled/dir.conf

<IfModule mod_dir.c>
        DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
</IfModule>

Finally, Restart the apache2 service
 
# systemctl restart apache2.service

To check the apache service status.
 
# systemctl status apache2.service


● apache2.service - LSB: Apache2 web server
   Loaded: loaded (/etc/init.d/apache2)
   Active: active (running) since Thu 2015-11-12 11:53:42 IST; 29s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 13425 ExecStop=/etc/init.d/apache2 stop (code=exited, status=0/SUCCESS)
  Process: 13449 ExecStart=/etc/init.d/apache2 start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/apache2.service
           ├─13463 /usr/sbin/apache2 -k start
           ├─13466 /usr/sbin/apache2 -k start
           └─13467 /usr/sbin/apache2 -k start


To make sure the server accept connections on port 80,
 
# netstat -alnp | grep apache2

tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      14604/apache2


Find the public IP Address,
 
#  ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//' | head -1
192.168.1.100 


Open your webbrowser and enter the your system ip address,

http://192.168.1.100/