Home > Apache, CentOS, How To, Linux OS > How-to: Install, Configure and Troubleshoot Apache HTTP 2.2.3 on CentOS 5

How-to: Install, Configure and Troubleshoot Apache HTTP 2.2.3 on CentOS 5

This may be applicable to all Apache 2 versions.

To install Apache Server on CentOS 5:

Apache is installed with CentOS 5 by default.

To check if the Apache Server is installed

#  rpm -q httpd

Or (with yum, you need to be on line)

# yum groupinfo "Web Server"

If not installed, then install it with:

# yum install "Web Server"

To install the text-based browser:

# yum install elinks

To use elinks:

# elinks

To access Apache Server on CentOS 5:

Open a browser and enter:


To configure Apache Server on CentOS 5.

You do not need to do any thing to the default configuration httpd.conf file to get your Apache Server running.

All you need is to write your index.html and your web pages and place them in /var/www/html.

The default DocumentRoot is located in /var/www/html.

The default home page is located in /usr/share/doc/HTML/index.html.

The default ServerRoot in httpd.conf is ServerRoot “/etc/httpd”.

Make sure the firewall does not block access to port 80 by running:

# system-config-securitylevel
 Allow WWW(HTTP) as "Trusted Services"
# apachectl start

Configure Apache service to start when the system is rebooted.

# chkconfig httpd on

Configure Apache Server to restart on CentOS 5

# apachectl restart


  1. Back up your /etc/httpd/conf/httpd.conf file.
  2. Run from the command line:
    # system-config-securitylevel
  3. check WWW(HTTP) as Trusted services
  4. # mkdir /var/www/html/test/
  5. # cd /var/www/html/test/
  6. # vi index.html
  7. insert(type i) the following:


  8. Save(press Esc then type :wq) the file
  9. # apachectl restart
  10. # chkconfig httpd on
  11. # chcon -R -u system_u /var/www/html/test/
  12. # chcon -R -t httpd_sys_content_t /var/www/html/test/
  13. Browse

Configuring user based security

To allow only authorized users who have passwords, add the following lines to /etc/httpd/conf/httpd.conf.

Just before the commented option for the UserDir directive:

       AuthType Basic
       AuthName "Test Passwords"
       AuthUserFile /etc/httpd/passdb
       Require user user1

Test the syntax with one of the followings:

# httpd -t
# httpd -S

Restart Apache

# apachectl restart

Configuring Passwords

To create the passwords database passdb in /etc/httpd and add user1 to it run the following command:

#  htpasswd -c /etc/httpd/passdb user1

To add another user, run the following command without the -c switch(which creates the database):

#  htpasswd /etc/httpd/passdb user2

Configuring host based security

Add the following to the Directory if you want to allow access only to your network. If your network for example is

# vi /etc/httpd/conf/httpd.conf
Order allow,deny
       Allow from

Apache Troubleshooting

Backup the httpd.conf configuration file.

Make sure Apache is running:

# service httpd status

If not running, start apache with one of the followings:

# apachectl start
# service httpd start

Make sure Apache is running during the boot process with this command:

# chkconfig httpd on

Test the syntax with one of the followings:

# httpd -t
# httpd -S

To view error log file run the following command:

# tail /var/log/httpd/error_log

To view Access log file run:

# tail /var/log/httpd/access_log

To restar Apache with out disconnecting the users run :

# service httpd reload

If you want stop Apache:

# apachectl stop
  1. September 1, 2010 at 12:44 PM

    Thanks for this cheat-sheet. Added to bookmarks

  1. January 3, 2011 at 10:32 AM

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

%d bloggers like this: