User Tools

Site Tools


accessibility:how-install-configure-and-troubleshoot-apache-http-223-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

1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 1em; padding-right: 1.5em; padding-bottom: 1em; padding-left: 1.5em; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; vertical-align: baseline; overflow-x: auto; overflow-y: auto; width: 600px; background-image: url(http://s2.wp.com/wp-content/themes/pub/motion/images/blacktrans.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; font-size: 1.2em; white-space: pre-wrap; background-position: initial initial; background-repeat: initial initial; "
#  rpm -q httpd

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

1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 1em; padding-right: 1.5em; padding-bottom: 1em; padding-left: 1.5em; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; vertical-align: baseline; overflow-x: auto; overflow-y: auto; width: 600px; background-image: url(http://s2.wp.com/wp-content/themes/pub/motion/images/blacktrans.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; font-size: 1.2em; white-space: pre-wrap; background-position: initial initial; background-repeat: initial initial; "
# yum groupinfo "Web Server"

If not installed, then install it with:

1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 1em; padding-right: 1.5em; padding-bottom: 1em; padding-left: 1.5em; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; vertical-align: baseline; overflow-x: auto; overflow-y: auto; width: 600px; background-image: url(http://s2.wp.com/wp-content/themes/pub/motion/images/blacktrans.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; font-size: 1.2em; white-space: pre-wrap; background-position: initial initial; background-repeat: initial initial; "
# yum install "Web Server"

To install the text-based browser:

1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 1em; padding-right: 1.5em; padding-bottom: 1em; padding-left: 1.5em; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; vertical-align: baseline; overflow-x: auto; overflow-y: auto; width: 600px; background-image: url(http://s2.wp.com/wp-content/themes/pub/motion/images/blacktrans.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; font-size: 1.2em; white-space: pre-wrap; background-position: initial initial; background-repeat: initial initial; "
# yum install elinks

To use elinks:

1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 1em; padding-right: 1.5em; padding-bottom: 1em; padding-left: 1.5em; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; vertical-align: baseline; overflow-x: auto; overflow-y: auto; width: 600px; background-image: url(http://s2.wp.com/wp-content/themes/pub/motion/images/blacktrans.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; font-size: 1.2em; white-space: pre-wrap; background-position: initial initial; background-repeat: initial initial; "
# elinks 127.0.0.1

To access Apache Server on CentOS 5:

Open a browser and enter:

1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 1em; padding-right: 1.5em; padding-bottom: 1em; padding-left: 1.5em; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; vertical-align: baseline; overflow-x: auto; overflow-y: auto; width: 600px; background-image: url(http://s2.wp.com/wp-content/themes/pub/motion/images/blacktrans.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; font-size: 1.2em; white-space: pre-wrap; background-position: initial initial; background-repeat: initial initial; "
http://localhost

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:

1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 1em; padding-right: 1.5em; padding-bottom: 1em; padding-left: 1.5em; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; vertical-align: baseline; overflow-x: auto; overflow-y: auto; width: 600px; background-image: url(http://s2.wp.com/wp-content/themes/pub/motion/images/blacktrans.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; font-size: 1.2em; white-space: pre-wrap; background-position: initial initial; background-repeat: initial initial; "
# system-config-securitylevel
1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 1em; padding-right: 1.5em; padding-bottom: 1em; padding-left: 1.5em; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; vertical-align: baseline; overflow-x: auto; overflow-y: auto; width: 600px; background-image: url(http://s2.wp.com/wp-content/themes/pub/motion/images/blacktrans.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; font-size: 1.2em; white-space: pre-wrap; background-position: initial initial; background-repeat: initial initial; "
 Allow WWW(HTTP) as "Trusted Services"
1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 1em; padding-right: 1.5em; padding-bottom: 1em; padding-left: 1.5em; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; vertical-align: baseline; overflow-x: auto; overflow-y: auto; width: 600px; background-image: url(http://s2.wp.com/wp-content/themes/pub/motion/images/blacktrans.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; font-size: 1.2em; white-space: pre-wrap; background-position: initial initial; background-repeat: initial initial; "
# apachectl start

Configure Apache service to start when the system is rebooted.

1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 1em; padding-right: 1.5em; padding-bottom: 1em; padding-left: 1.5em; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; vertical-align: baseline; overflow-x: auto; overflow-y: auto; width: 600px; background-image: url(http://s2.wp.com/wp-content/themes/pub/motion/images/blacktrans.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; font-size: 1.2em; white-space: pre-wrap; background-position: initial initial; background-repeat: initial initial; "
# chkconfig httpd on

Configure Apache Server to restart on CentOS 5

1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 1em; padding-right: 1.5em; padding-bottom: 1em; padding-left: 1.5em; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; vertical-align: baseline; overflow-x: auto; overflow-y: auto; width: 600px; background-image: url(http://s2.wp.com/wp-content/themes/pub/motion/images/blacktrans.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; font-size: 1.2em; white-space: pre-wrap; background-position: initial initial; background-repeat: initial initial; "
# apachectl restart

Example

  1. Back up your /etc/httpd/conf/httpd.conf file.
  1. Save(press Esc then type :wq) the file

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:

1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 1em; padding-right: 1.5em; padding-bottom: 1em; padding-left: 1.5em; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; vertical-align: baseline; overflow-x: auto; overflow-y: auto; width: 600px; background-image: url(http://s2.wp.com/wp-content/themes/pub/motion/images/blacktrans.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; font-size: 1.2em; white-space: pre-wrap; background-position: initial initial; background-repeat: initial initial; "
       AuthType Basic
       AuthName "Test Passwords"
       AuthUserFile /etc/httpd/passdb
       Require user user1

Test the syntax with one of the followings:

1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 1em; padding-right: 1.5em; padding-bottom: 1em; padding-left: 1.5em; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; vertical-align: baseline; overflow-x: auto; overflow-y: auto; width: 600px; background-image: url(http://s2.wp.com/wp-content/themes/pub/motion/images/blacktrans.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; font-size: 1.2em; white-space: pre-wrap; background-position: initial initial; background-repeat: initial initial; "
# httpd -t
1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 1em; padding-right: 1.5em; padding-bottom: 1em; padding-left: 1.5em; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; vertical-align: baseline; overflow-x: auto; overflow-y: auto; width: 600px; background-image: url(http://s2.wp.com/wp-content/themes/pub/motion/images/blacktrans.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; font-size: 1.2em; white-space: pre-wrap; background-position: initial initial; background-repeat: initial initial; "
# httpd -S

Restart Apache

1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 1em; padding-right: 1.5em; padding-bottom: 1em; padding-left: 1.5em; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; vertical-align: baseline; overflow-x: auto; overflow-y: auto; width: 600px; background-image: url(http://s2.wp.com/wp-content/themes/pub/motion/images/blacktrans.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; font-size: 1.2em; white-space: pre-wrap; background-position: initial initial; background-repeat: initial initial; "
# apachectl restart

Configuring Passwords

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

1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 1em; padding-right: 1.5em; padding-bottom: 1em; padding-left: 1.5em; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; vertical-align: baseline; overflow-x: auto; overflow-y: auto; width: 600px; background-image: url(http://s2.wp.com/wp-content/themes/pub/motion/images/blacktrans.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; font-size: 1.2em; white-space: pre-wrap; background-position: initial initial; background-repeat: initial initial; "
#  htpasswd -c /etc/httpd/passdb user1

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

1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 1em; padding-right: 1.5em; padding-bottom: 1em; padding-left: 1.5em; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; vertical-align: baseline; overflow-x: auto; overflow-y: auto; width: 600px; background-image: url(http://s2.wp.com/wp-content/themes/pub/motion/images/blacktrans.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; font-size: 1.2em; white-space: pre-wrap; background-position: initial initial; background-repeat: initial initial; "
#  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 192.168.1.0:

1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 1em; padding-right: 1.5em; padding-bottom: 1em; padding-left: 1.5em; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; vertical-align: baseline; overflow-x: auto; overflow-y: auto; width: 600px; background-image: url(http://s2.wp.com/wp-content/themes/pub/motion/images/blacktrans.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; font-size: 1.2em; white-space: pre-wrap; background-position: initial initial; background-repeat: initial initial; "
# vi /etc/httpd/conf/httpd.conf
1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 1em; padding-right: 1.5em; padding-bottom: 1em; padding-left: 1.5em; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; vertical-align: baseline; overflow-x: auto; overflow-y: auto; width: 600px; background-image: url(http://s2.wp.com/wp-content/themes/pub/motion/images/blacktrans.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; font-size: 1.2em; white-space: pre-wrap; background-position: initial initial; background-repeat: initial initial; "
Order allow,deny
       Allow from  192.168.1.0/255.255.255.0

Apache Troubleshooting

Backup the httpd.conf configuration file.

Make sure Apache is running:

1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 1em; padding-right: 1.5em; padding-bottom: 1em; padding-left: 1.5em; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; vertical-align: baseline; overflow-x: auto; overflow-y: auto; width: 600px; background-image: url(http://s2.wp.com/wp-content/themes/pub/motion/images/blacktrans.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; font-size: 1.2em; white-space: pre-wrap; background-position: initial initial; background-repeat: initial initial; "
# service httpd status

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

1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 1em; padding-right: 1.5em; padding-bottom: 1em; padding-left: 1.5em; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; vertical-align: baseline; overflow-x: auto; overflow-y: auto; width: 600px; background-image: url(http://s2.wp.com/wp-content/themes/pub/motion/images/blacktrans.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; font-size: 1.2em; white-space: pre-wrap; background-position: initial initial; background-repeat: initial initial; "
# apachectl start
1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 1em; padding-right: 1.5em; padding-bottom: 1em; padding-left: 1.5em; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; vertical-align: baseline; overflow-x: auto; overflow-y: auto; width: 600px; background-image: url(http://s2.wp.com/wp-content/themes/pub/motion/images/blacktrans.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; font-size: 1.2em; white-space: pre-wrap; background-position: initial initial; background-repeat: initial initial; "
# service httpd start

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

1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 1em; padding-right: 1.5em; padding-bottom: 1em; padding-left: 1.5em; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; vertical-align: baseline; overflow-x: auto; overflow-y: auto; width: 600px; background-image: url(http://s2.wp.com/wp-content/themes/pub/motion/images/blacktrans.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; font-size: 1.2em; white-space: pre-wrap; background-position: initial initial; background-repeat: initial initial; "
# chkconfig httpd on

Test the syntax with one of the followings:

1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 1em; padding-right: 1.5em; padding-bottom: 1em; padding-left: 1.5em; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; vertical-align: baseline; overflow-x: auto; overflow-y: auto; width: 600px; background-image: url(http://s2.wp.com/wp-content/themes/pub/motion/images/blacktrans.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; font-size: 1.2em; white-space: pre-wrap; background-position: initial initial; background-repeat: initial initial; "
# httpd -t
1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 1em; padding-right: 1.5em; padding-bottom: 1em; padding-left: 1.5em; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; vertical-align: baseline; overflow-x: auto; overflow-y: auto; width: 600px; background-image: url(http://s2.wp.com/wp-content/themes/pub/motion/images/blacktrans.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; font-size: 1.2em; white-space: pre-wrap; background-position: initial initial; background-repeat: initial initial; "
# httpd -S

To view error log file run the following command:

1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 1em; padding-right: 1.5em; padding-bottom: 1em; padding-left: 1.5em; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; vertical-align: baseline; overflow-x: auto; overflow-y: auto; width: 600px; background-image: url(http://s2.wp.com/wp-content/themes/pub/motion/images/blacktrans.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; font-size: 1.2em; white-space: pre-wrap; background-position: initial initial; background-repeat: initial initial; "
# tail /var/log/httpd/error_log

To view Access log file run:

1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 1em; padding-right: 1.5em; padding-bottom: 1em; padding-left: 1.5em; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; vertical-align: baseline; overflow-x: auto; overflow-y: auto; width: 600px; background-image: url(http://s2.wp.com/wp-content/themes/pub/motion/images/blacktrans.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; font-size: 1.2em; white-space: pre-wrap; background-position: initial initial; background-repeat: initial initial; "
# tail /var/log/httpd/access_log

To restar Apache with out disconnecting the users run :

1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 1em; padding-right: 1.5em; padding-bottom: 1em; padding-left: 1.5em; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; vertical-align: baseline; overflow-x: auto; overflow-y: auto; width: 600px; background-image: url(http://s2.wp.com/wp-content/themes/pub/motion/images/blacktrans.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; font-size: 1.2em; white-space: pre-wrap; background-position: initial initial; background-repeat: initial initial; "
# service httpd reload

If you want stop Apache:

1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 1em; padding-right: 1.5em; padding-bottom: 1em; padding-left: 1.5em; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; vertical-align: baseline; overflow-x: auto; overflow-y: auto; width: 600px; background-image: url(http://s2.wp.com/wp-content/themes/pub/motion/images/blacktrans.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; font-size: 1.2em; white-space: pre-wrap; background-position: initial initial; background-repeat: initial initial; "
# apachectl stop



 
 

accessibility/how-install-configure-and-troubleshoot-apache-http-223-centos-5.txt · Last modified: 2016/07/19 01:23 (external edit)