How To Web Server
1. Install Apache
[root@proxy /]# yum install httpd
Setting up Install Process
Setting up repositories
updates-released 100% |=========================| 951 B 00:00
extras 100% |=========================| 1.1 kB 00:00
base 100% |=========================| 1.1 kB 00:00
Reading repository metadata in from local files
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for httpd to pack into transaction set.
httpd-2.0.54-10.4.i386.rp 100% |=========================| 74 kB 00:02
---> Package httpd.i386 0:2.0.54-10.4 set to be updated
--> Running transaction check
--> Processing Dependency: httpd = 2.0.54-10 for package: mod_ssl
--> Processing Dependency: httpd = 2.0.54-10 for package: httpd-manual
--> Restarting Dependency Resolution with new changes.
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for mod_ssl to pack into transaction set.
mod_ssl-2.0.54-10.4.i386. 100% |=========================| 23 kB 00:01
---> Package mod_ssl.i386 1:2.0.54-10.4 set to be updated
---> Downloading header for httpd-manual to pack into transaction set.
httpd-manual-2.0.54-10.4. 100% |=========================| 114 kB 00:03
---> Package httpd-manual.i386 0:2.0.54-10.4 set to be updated
--> Running transaction check
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Updating:
httpd i386 2.0.54-10.4 updates-released 947 k
Updating for dependencies:
httpd-manual i386 2.0.54-10.4 updates-released 1.7 M
mod_ssl i386 1:2.0.54-10.4 updates-released 94 k
Transaction Summary
=============================================================================
Install 0 Package(s)
Update 3 Package(s)
Remove 0 Package(s)
Total download size: 2.7 M
Is this ok [y/N]: y
Downloading Packages:
(1/3): mod_ssl-2.0.54-10. 100% |=========================| 94 kB 00:03
http://download.fedoraproject.org/pub/fedora/linux/core/updates/4/i386/httpd-manual-2.0.54-10.4.i386.rpm: [Errno 4] IOError: [Errno ftp error] timed out
Trying other mirror.
(2/3): httpd-manual-2.0.5 100% |=========================| 1.7 MB 01:00
(3/3): httpd-2.0.54-10.4. 100% |=========================| 947 kB 00:33
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Updating : httpd ######################### [1/6]
Updating : mod_ssl ######################### [2/6]
Updating : httpd-manual ######################### [3/6]
Cleanup : mod_ssl ######################### [4/6]
Cleanup : httpd-manual ######################### [5/6]
Cleanup : httpd ######################### [6/6]
Updated: httpd.i386 0:2.0.54-10.4
Dependency Updated: httpd-manual.i386 0:2.0.54-10.4 mod_ssl.i386 1:2.0.54-10.4
Complete!
2. Check the installation.
a. If its properly installed.
[root@proxy /]# rpm -qa|grep httpd
system-config-httpd-1.3.2-2
httpd-2.0.54-10.4
httpd-manual-2.0.54-10.4
b. Start/Stop/Restart the service.
[root@proxy /]# service httpd start
[root@proxy /]# service httpd stop
[root@proxy /]# service httpd restart
c. Checking at boot time.
[root@proxy /]# /sbin/chkconfig httpd on
[root@proxy /]# /sbin/chkconfig --list httpd
httpd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
3. Check the config files.
The Apache configuration file is: /etc/httpd/conf/httpd.conf
Web pages are served from the directory as configured by the DocumentRoot directive. The default directory location is:
- Red Hat 7.x-9, Fedora Core, Red Hat Enterprise 4, CentOS 4: /var/www/html/
4. Common configuration options
a. ServerRoot – used for specifying the base directory of the Web server.
ServerRoot "/etc/httpd"
b. ServerAdmin – email address that is included in error messages
ServerAdmin root@example.com
c. ServerName – hostname and port the server uses
ServerName www.example.com:80
d. DocumentRoot – primary directory of the Web server.
DocumentRoot "/var/www/html"
e. Listen – this the port where server listens for requests.
Listen 203.189.11.73:80
e. Users/Groups – tell which user/group will anser requests
User apache
Group apache
f. LoadModule – used for loading modules into apache’s running config
LoadModule cgi_module modules/mod_cgi.so
LoadModule cgi_module modules/mod_ssl.so
g. ErrorLog – location of the errors
ErrorLog logs/error_log
5. Try your site by going to your browser.
http://localhost or http://ip-address