How To InstallLinuxWWW-WEB

Install web-server (httpd) in CentOS and RedHAT

This post will guide to install a basic Apache web server in CentOS and RedHAT operating system. Apache web server project was started by Robert McCool on 1996 (history of Apache Web Server) and nowadays it’s the most widely used web server due to it’s scalability, integration with several security and modules, .htaccess parsing etc. Apache is responsible for than 50% of traffic in web industry. (Apache Traffic Usage)


  1. CentOS or RedHAT Operating system installed. (We’ve used CentOS 6.8 x64 bit system)
  2. Any test editor installed.
  3. Off-course a working Internet connection

Difficulty: Easy   Time Required: 10 minutes


Apache is called as httpd (http daemon, daemon is a typical RedHAT term to indicate Services, read more)in RedHAT based system and is present in base repository of yum installer.

yum -y install httpd

Apache is installed in your CentOS or RedHAT system now.. 🙂


httpd main configuration file is located in “/etc/httpd/conf/httpd.conf”. Edit it with your text editor with root or sudo right. We’ll use “nano” as command line text editor for rest of the text as “root” and so “sudo” will be ignored. If you like to install nano use the following command or else proceed with default “vim” or whatever is suitable for you.

yum -y install nano

Now edit the configuration file as follows

nano /etc/httpd/conf/httpd.conf

Find the following and change as follows if it’s not already there (You can easily find something in nano by pressing ctrl+w followed by what you want to search in the text, for ex: ctrl+w then “Listen” for the first line of the following)

Listen 80

User apache

Group apache

ServerRoot “/etc/httpd”

DocumentRoot “/var/www/html”

Include conf.d/*.conf

Most of this are already present in the default configuration file and you need not to change, but just be sure those are there.

  1. “Listen 80” indicate in which port apache will listen for http connection. General format is IP:port (eg: Listen If IP part is skipped as here and by default “httpd” will listen to port 80 of all IP addresses present in your system. [Don’t get excited for secure https and don’t replace with 443 here, this is not for https, there is other way for https, but that itself need another post].
  2. “User apache” and “Group apache” indicate under which User and Group the web server will run [Remember each process need to have an user in Linux]. 
  3. “ServerRoot” indicates root directory of the server. If you don’t explicitly define a directory starting with “/” it will be defined as “/etc/httpd/directory-name”
  4. “DocumentRoot” indicates the default directory of your web content. Notice DocumentRoot is started with “/” and so not a part of “ServerRoot”
  5. A tricky part is “Include” which can include any file and directory in the configuration without writing that directly in configuration. This keeps the configuration file clean and other things separated. Here any file in “/etc/httpd/conf.d” with .conf extension is included. This will be used latter to include virtual hosts (don’t worry right now)

Yahhh..!! You are ready to host your own Single html based website in your server. Just copy and past it into “DocumentRoot” that is “/var/www/html”. Please name the home page of your website as “index.html”. Now start httpd with the following command

service httpd start

Type your “Public IP address” in browser URL field (eg: where is your IP address) or use any domain name pointed to that IP address in browser URL field and you’ll find your first website. To point your domain say and your IP is you’ve to create a DNS “A” record for with a value (more about DNS records). If you don’t have an Public IP and testing it on own laptop please browse “localhost” or “” (i.e. http://localhost or in local browser in your laptop.

This finishes installing a very simple web server in CentOS or RedHAT based system. Although most of the functions like https, hosting multiple website on same server and other advanced functions are not covered yet and will be covered in subsequent posts.

For any quarry please don’t hesitate to leave a comment or contact the author with “authorname”@”” without any quotes.

Visits: 401

Leave a Reply

Your email address will not be published. Required fields are marked *