Thursday, December 31, 2009

APACHE WEB SERVER IN REDHAT LINUX

APACHE WEB SERVER

Features:
1. WWW Web Server
2. Modular

Tasks:

1. Install Apache 2.2x
•httpd*rpm
•/etc/httpd - top-level configuration container on RH5
•/etc/httpd/conf - primary configuration directory
•/etc/httpd/conf/httpd.conf - primary Apache configuration file
•/etc/httpd/conf.d - drop-in configuration directory, read by Apache upon startup
2. Explorer: /etc/httpd/conf/httpd.conf

•HTTPD runs as: apache:apache
•Apache maintains, always, a 'main' server, which is independent of Virtual Hosts. This server is a catch-all for traffic that doesn't match any of the defined virtual hosts.
directive governs file system access.

Note: The primary Apache process runs as 'root', and has access to the full file system. However, directive restricts the web-user's view of the file system.

• Test access to '.ht*' files from web root
• ErrorLog logs/error_log - default error log file for ALL hosts
• logs/access_log - default log file for default server

Note: Every directory, outside of the 'DocumentRoot' should have at least one: directive defined.

3. Start Apache and continue to explore
•service httpd start
root 31324 1 0 10:17 ? 00:00:00 /usr/sbin/httpd
apache 31326 31324 0 10:17 ? 00:00:00 /usr/sbin/httpd
apache 31327 31324 0 10:17 ? 00:00:00 /usr/sbin/httpd
apache 31328 31324 0 10:17 ? 00:00:00 /usr/sbin/httpd
apache 31329 31324 0 10:17 ? 00:00:00 /usr/sbin/httpd
apache 31330 31324 0 10:17 ? 00:00:00 /usr/sbin/httpd
apache 31331 31324 0 10:17 ? 00:00:00 /usr/sbin/httpd
apache 31332 31324 0 10:17 ? 00:00:00 /usr/sbin/httpd
apache 31333 31324 0 10:17 ? 00:00:00 /usr/sbin/httpd

Note:

•Parent Apache runs as 'root' and can see the entire file system
•However, children processes run as 'apache' and can only see files/directories that 'apache:apache' can see
4. Create an Alias for content outside of the web root (/var/www/html)
•Alias /testalias1 /var/www/testalias1

AllowOverride Non
order allow,deny
allow from all

5. Ensure that Apache will start when the system boots
•chkconfig --level 35 httpd on && chkconfig --list httpd

Virtual Hosts Configuration:
Features:
1. Ability to share/serve content based on 1 or more IP addresses

2. Supports 2 modes of Virtual Hosts:
•IP Based - one site per IP address
•Host header names - multiple sites per IP address



Tasks:
1. Create IP Based Virtual Hosts
•ifconfig eth0:1 192.168.75.210
•Configure the Virtual Host:

ServerAdmin webmaster@linuxcbtserv4.linuxcbt.internal
ServerName site1.linuxcbt.internal
DocumentRoot /var/www/site1

Order allow,deny
Allow from all

CustomLog logs/site1.linuxcbt.internal.access.log combined
ErrorLog logs/site1.linuxcbt.internal.error.log


• Create: /var/www/site1 and content
• Update: /etc/httpd/conf/httpd.conf with VHost information

2. Create Name-based Virtual Hosts using the primary IP address

•/etc/httpd/conf/httpd.conf:
NameVirtualHost 192.168.75.199:80

ServerAdmin webmaster@linuxcbtserv4.linuxcbt.internal
ServerName site3.linuxcbt.internal
DocumentRoot /var/www/site3

Order allow,deny
Allow from all

CustomLog logs/site3.linuxcbt.internal.access.log combined
ErrorLog logs/site3.linuxcbt.internal.error.log

No comments:

Post a Comment