Data Networking/Fall 2014/Priya/WEB-SERVER/configuring the Apache2 web server

From Wikiversity
Jump to navigation Jump to search

In this article, we will describe the steps and procedures required to install and configure Apache 2 web server on a Linux machine, (specifically Ubuntu 14.04).

Step 1
Installing Apache2

To install Apache2 on Ubuntu 14.04, use the following commands Update Linux files

    sudo apt-get update     

Installs Apache2 Web Server

    sudo apt-get install apache2

To check that Apache2 is successfully installed, open a web browser and type the following

    http://localhost

If the Apache2 default page should be displayed, congratulation!



Step 2
Creating Directory files

After successfully installing Apache2, we'll create the html file that will contain our web site information and design. To create the directory folder, use the following command

    sudo mkdir /var/www/neunetworks.com/

Change the properties of the directory to allow the web server to read the html file

    sudo chmod 755 /var/www/
    sudo chown $USER:$USER /var/www/neunetworks.com/

Create and edit sample.html to the layout you prefer

    sudo nano /var/www/neunetworks.com/sample.html



Step 3
Configuring Apache2 - apache2.conf

Now we have to configure it to meet our needs. The Apache2 configuration file is apache2.conf and can be accessed using the following command

    sudo nano /etc/apache2/apache2.conf

We are required to do the following modifications, add the following lines to apache2.conf:

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

Adding /var/www/neunetworks.com/ directory allows the Apache2 to reach our hosted web site located at that directory. The apache2.conf has many other variables that can be modified to our demands, such as KeepAlive and MaxKeepAliveRequests, which determines how the web server would handle persistent HTTP connections.



Step 4
Configuring Apache2 - dir.conf

Since we didn't use the default .html file syntax (index.html), we have to add our 'sample.html' to the list of accessible directory indices. Modify the following file

    sudo nano /etc/apache2/mods-available/dir.conf


Append sample.html to the list of indices

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



Step 5
Configuring Apache2 - 000-default.conf

000-default.conf is used by the Server to identify itself. For our web site, we need to modify/add the following lines to direct the web server to our web site

    ServerAdmin webmaster@localhost
    ServerName neunetworks.com
    DocumentRoot /var/www/neunetworks.com



Step 6
Restart Apache2

Now that the Apache2 configuration is complete, we need to reload the web server, so that the new configurations can be implemented

    sudo service Apache2 restart



Step 7
Verification

To verify that our changes have been successfully configured and implemented, simply reload the web site (you might need to delete your browser's cahce)

    http://localhost