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
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)
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:
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:
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:
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:
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:
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
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"
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.
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
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
- Back up your /etc/httpd/conf/httpd.conf file.
- Run from the command line:
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
-
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; "> check WWW(HTTP) as Trusted services
-
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; "> # mkdir /var/www/html/test/
-
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; "> # cd /var/www/html/test/
-
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 index.html
- insert(type i) the following:
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; ">
Hello
- Save(press Esc then type :wq) the file
-
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
-
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
-
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; "> # chcon -R -u system_u /var/www/html/test/
-
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; "> # chcon -R -t httpd_sys_content_t /var/www/html/test/
- Browse
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://127.0.0.1/test
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:
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 user1Test the syntax with one of the followings:
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
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
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:
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):
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:
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
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.0Apache Troubleshooting
Backup the httpd.conf configuration file.
Make sure Apache is running:
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:
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
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:
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:
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
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:
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:
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 :
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:
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
http://s2.wp.com/wp-content/themes/pub/motion/images/whitetrans.png); background-attachment: initial; background-origin: initial; background-clip: initial; background-color: initial; overflow-x: hidden; overflow-y: hidden; width: 640px; font-size: 0.8em; line-height: 1.1em; background-position: initial initial; background-repeat: initial initial; ">
- Home
- About Us
- News & Media
- Programs
- Collaborative Projects
- Workgroups
- Publications
- Events
- Training



