Asf020 - HTTPD
Asf020 - HTTPD
Unit 6
Web Services
RH253-RH253-RHEL5-en-1-
20070325
Copyright 2007 Red Hat, Inc.
All rights reserved
6-1
http://www.way2download.com/linux/RH253/unit-6/page01.html [2008/02/06 08:30:48 PM]
Objectives
Objectives
Upon completion of this unit, you should be
able to:
Learn the major features of the Apache
HTTP server
Be able to configure important Apache
parameters
Learn per-directory configuration
Learn how to use CGI with Apache
Identify key modules
Understand proxy web servers
RH253-RH253-RHEL5-en-1-
20070325
Copyright 2007 Red Hat, Inc.
All rights reserved
6-2
http://www.way2download.com/linux/RH253/unit-6/page02.html [2008/02/06 08:30:50 PM]
Apache Overview
Apache Overview
Process control:
spawn processes before needed
adapt number of processes to demand
Dynamic module loading:
run-time extensibility without recompiling
Virtual hosts:
Multiple web sites may share the same web server
RH253-RH253-RHEL5-en-1-
20070325
Copyright 2007 Red Hat, Inc.
All rights reserved
6-3
http://www.way2download.com/linux/RH253/unit-6/page03.html [2008/02/06 08:30:51 PM]
Service Profile: HTTPD
Service Profile: HTTPD
Type: SystemV-managed service
Packages: httpd, httpd-devel, httpd-
manual
Daemon: /usr/sbin/httpd
Script: /etc/init.d/httpd
Ports: 80(http), 443(https)
Configuration: /etc/httpd/*, /var/www/
*
Related: system-config-httpd, mod_ssl
RH253-RH253-RHEL5-en-1-
20070325
Copyright 2007 Red Hat, Inc.
All rights reserved
6-4
http://www.way2download.com/linux/RH253/unit-6/page04.html [2008/02/06 08:30:52 PM]
Apache Configuration
Apache Configuration
Main server configuration stored in /etc/
httpd/conf/httpd.conf
controls general web server parameters, regular
virtual hosts, and access
defines filenames and mime-types
Module configuration files stored in /etc/
httpd/conf.d/*
DocumentRoot default /var/www/html/
RH253-RH253-RHEL5-en-1-
20070325
Copyright 2007 Red Hat, Inc.
All rights reserved
6-5
http://www.way2download.com/linux/RH253/unit-6/page05.html [2008/02/06 08:30:54 PM]
Apache Server Configuration
Apache Server Configuration
Min and Max Spare Servers
Log file configuration
Host name lookup
Modules
Virtual Hosts
user and group
RH253-RH253-RHEL5-en-1-
20070325
Copyright 2007 Red Hat, Inc.
All rights reserved
6-6
http://www.way2download.com/linux/RH253/unit-6/page06.html [2008/02/06 08:30:55 PM]
Apache Namespace Configuration
Apache Namespace Configuration
Specifying a directory for users' pages:
UserDir public_html
MIME types configuration:
AddType application/x-httpd-php .phtml
AddType text/html .htm
Declaring index files for directories:
DirectoryIndex index.html default.htm
RH253-RH253-RHEL5-en-1-
20070325
Copyright 2007 Red Hat, Inc.
All rights reserved
6-7
http://www.way2download.com/linux/RH253/unit-6/page07.html [2008/02/06 08:30:56 PM]
Virtual Hosts
Virtual Hosts
NameVirtualHost 192.168.0.100:80
<VirtualHost 192.168.0.100:80>
ServerName virt1.com
DocumentRoot /virt1
</VirtualHost>
<VirtualHost 192.168.0.100:80>
ServerName virt2.com
DocumentRoot /virt2
</VirtualHost>
RH253-RH253-RHEL5-en-1-
20070325
Copyright 2007 Red Hat, Inc.
All rights reserved
6-8
http://www.way2download.com/linux/RH253/unit-6/page08.html [2008/02/06 08:30:57 PM]
Apache Access Configuration
Apache Access Configuration
Apache provides directory- and file-level host-
based access control
Host specifications may include dot notation
numerics, network/netmask, and dot notation
hostnames and domains
The Order statement provides control over
"order", but not always in the way one might
expect
RH253-RH253-RHEL5-en-1-
20070325
Copyright 2007 Red Hat, Inc.
All rights reserved
6-9
http://www.way2download.com/linux/RH253/unit-6/page09.html [2008/02/06 08:30:59 PM]
Apache Syntax Utilities
Apache Syntax Utilities
service httpd configtest
apachectl configtest
httpd -t
Checks both httpd.conf and ssl.conf
RH253-RH253-RHEL5-en-1-
20070325
Copyright 2007 Red Hat, Inc.
All rights reserved
6-10
http://www.way2download.com/linux/RH253/unit-6/page10.html [2008/02/06 08:30:59 PM]
Using .htaccess Files
Using .htaccess Files
Change a directory's configuration:
add mime-type definitions
allow or deny certain hosts
Setup user and password databases:
AuthUserFile directive
htpasswd command:
htpasswd -cm /etc/httpd/.htpasswd bob
htpasswd -m /etc/httpd/.htpasswd alice
RH253-RH253-RHEL5-en-1-
20070325
Copyright 2007 Red Hat, Inc.
All rights reserved
6-11
http://www.way2download.com/linux/RH253/unit-6/page11.html [2008/02/06 08:31:01 PM]
.htaccess Advanced Example
.htaccess Advanced Example
AuthName "Bob's Secret Stuff"
AuthType basic
AuthUserFile /var/www/html/.htpasswd
AuthGroupFile /var/www/html/.htgroup
<Limit GET>
require group staff
</Limit>
<Limit PUT POST>
require user bob
</Limit>
RH253-RH253-RHEL5-en-1-
20070325
Copyright 2007 Red Hat, Inc.
All rights reserved
6-12
http://www.way2download.com/linux/RH253/unit-6/page12.html [2008/02/06 08:31:02 PM]
CGI
CGI
CGI programs are restricted to separate
directories by ScriptAlias directive:
ScriptAlias /cgi-bin/ /path/cgi-bin/
Apache can greatly speed up CGI programs
with loaded modules such as mod_perl
RH253-RH253-RHEL5-en-1-
20070325
Copyright 2007 Red Hat, Inc.
All rights reserved
6-13
http://www.way2download.com/linux/RH253/unit-6/page13.html [2008/02/06 08:31:04 PM]
Notable Apache Modules
Notable Apache Modules
mod_perl
mod_php
mod_speling
RH253-RH253-RHEL5-en-1-
20070325
Copyright 2007 Red Hat, Inc.
All rights reserved
6-14
http://www.way2download.com/linux/RH253/unit-6/page14.html [2008/02/06 08:31:05 PM]
Apache Encrypted Web Server
Apache Encrypted Web Server
Apache and SSL: (port
443)
mod_ssl
/etc/httpd/conf.d/ssl.conf
Encryption Configuration:
certificate: /etc/pki/tls/certs/your_host.
crt
private key: /etc/pki/tls/private/
your_host.key
Certificate/key generation:
/etc/pki/tls/certs/Makefile
self-signed cert: make testcert
certificate signature request: make certreq
RH253-RH253-RHEL5-en-1-
20070325
Copyright 2007 Red Hat, Inc.
All rights reserved
6-15
http://www.way2download.com/linux/RH253/unit-6/page15.html [2008/02/06 08:31:06 PM]