Basic Apache Configuration

In our last article, we have learned about the working of a web server. But do u know which are the most popular web servers of world. If not, then i am going to tell you about them. The web server software that we use, depends on the operating system that we are using. Microsoft Windows systems uses IIS [Internet Information Server], whereas most of the Unix based operating systems uses Apache web Server. Apache is the most popular web server of the world. Most of the Internet users believe that a web sites success depends upon its content and promotion. But this is not enough. A correct choice of web server is as important as content of website. Before choosing a web server we should consider its capabilities and support.

We are going to learn Apache. Apache was released in 1995 by Apache Software Foundation. Apache is an open source web software application that can run on most of the Operating system platform including Windows, Linux, Unix, Solaris, Novell Net Ware and Mac OS. Apache is released under Apache License. It is the biggest competitor of Microsoft’s IIS, which is a paid web software application. Apache supports virtual hosting which means we can configure more than one website on a single pc. Currently Apache is a giant in the field of Web Servers and you can verify it by searching in Internet. Apache holds about 60% of market share in the market of Web Servers. Apache is the best web server till now, so we are going to configure it on our Linux machine.

Now lets configure Basic Apache Web Server on our Linux machine:

Step 1. Install http package and Start its service.

[root@localhost ~]# yum install http* -y 

[root@localhost ~]# service httpd restart 

Above command starts the ‘httpd’ service. Make sure that you run ‘chkconfig’ command, so that the service remain working after reboot.

[root@localhost ~]# chkconfig httpd on 

Step 2. Open the following file and type the name of website and its address

[root@localhost ~]# vim /etc/hosts 

# Do not remove the following line, or various programs 
# that require network functionality will fail. localhost.localdomain localhost 
::1 localhost6.localdomain6 localhost6 

The above file does mapping between the Ip-address and the Domain name. If we do not configure this file, the web page will only open with the ip-address of the web server. We do not need to configure this file, if we have DNS server. But in our case, i am assuming that i do not have any DNS server.

Step 3. Create a file index.html into /var/www/html directory.

[root@localhost ~]# touch /var/www/html/index.html 

When we install http package, /var/www/html directory is created automatically. Apache by default reads index.html page, which should be placed in any subdirectory of ‘www’. If you want your apache to display ‘.php’ pages as well, you should install the ‘php’ packages in your system.

Now open index.html with your favourite text editor, and write anything here which you want to see in your web browser.

[root@localhost ~]# vim /var/www/html/ 

Hello World !!!

Step 4. Now open the httpd.conf file which stores all major configuration of web server. Now go to the bottom of the file & put the below mentioned entries

[root@localhost ~]# vim /etc/httpd/conf/httpd.conf 

ServerAdmin root@localhost.localdomain 
DocumentRoot /var/www/html/
ErrorLog logs/ 
CustomLog logs/ common

Here above:

VirtualHost: VirtualHost directive tells the Apache that we are going to use Name based virtual hosting,or we can say that all the websites will use only one IP-address.80 means that we are using name based virtual hosting for the http protocol.

ServerAdmin: It is the Email address of the Administrator.

DocumentRoot: This is the location of web page. By default, apache runs index.html page.

ServerName: This is the name of your website.

ErrorLog: This is the location where all error reports will be stored.

CustomLog: This is the location where all normal http access details will be stored.

Step5. Now Restart the httpd service.

[root@localhost ~]# service httpd restart 

Step6. Now your web server is ready to server you web page. You can see your web page with your web browser or you can also see your web page using command line. Just type the name of your web site or its ip.

[root@localhost ~]# elinks

Note: Install the elinks package, if it is not installed.


[root@localhost ~]# elinks

You can leave a response, or trackback from your own site.

Leave a Reply