You are on page 1of 8

developerWorks 25.04.

2006

LPI: Web-
(LPIC-2) 208

Apache Squid
Web- Apache
Apache -- web- ,
Linux .
web- (
),
Apache .
Linux Apache ,
, .
Apache , ,
, Apache HTTP
Server Project.
, Apache,
.
2001 Apache 2.x, Apache 1.3.x
, 1.3.x bug fixes
. 1.3 2.x
; 1.3, 2.x.
-- 1.3.34 (), 2.0.55
(), 2.1.9 ().
,
2.x. , 2.x
, ,
( , PHP 1.3
). , , ,
, 2.x, 1.3.x.

Squid -
Squid -- - web-,
HTTP, FTP, TLS, SSL, HTTPS.
, -- -
, , , - ,
. ,

Squid ,
,

.
Squid ,
web- (), ,
web-, LAN .
Squid ,
web- .


Linux, man .
, Linux.
Linux Documentation Project,
,
HOWTO. Linux; ,
O'Reilly's TCP/IP Network Administration, , . (
.)
Apache .
,
Apache.
.

web-

Apache .
, , ,
Apache . Apache httpd,
apache2. ,
/usr/sbin/, ,
, .
Apache , -d serverroot -f
config .
, ;
, .
-f ServerRoot.
, apache2.conf,
httpd.conf, . , ,

/etc/apache2/, /etc/apache/, /etc/httpd/conf/, /etc/httpd/apache/conf,


- , , Linux,
, Apache. man apache2 man
httpd - .
Apache ,
. ,
.

;

. root,
.
:
Listing 1. The Apache
# ps axu | grep apache2
root
6620
Ss
Nov12
0:00 /usr/sbin/apache2
www-data 6621
S
Nov12
0:00 /usr/sbin/apache2
www-data 6622
Sl
Nov12
0:00 /usr/sbin/apache2
www-data 6624
Sl
Nov12
0:00 /usr/sbin/apache2
dqm
313
S+
03:44
0:00 man apache2
root
637
S+
03:59
0:00 grep apache2

-k
-k
-k
-k

start
start
start
start

-DSSL
-DSSL
-DSSL
-DSSL

nobody. Listing 1
-- www-data.


, Apache
. Apache2, ,
, /etc/apache2/apache2.conf,
Include statements
, , . ,
Apache, , (
).
, , .
"" httpd.conf, Apache
1.3 , .
, ,
, :
Listing 2.
# Include the virtual host configurations:
Include /etc/apache2/sites-enabled/[^.#]*

Apache 2.x,
( 1.3.x). ,
:
Listing 3. From /etc/apache2/apache2.conf
# Include module configuration:
Include /etc/apache2/mods-enabled/*.load
Include /etc/apache2/mods-enabled/*.conf

Apache
, :
Listing 4. Apache
# cat /etc/apache2/mods-enabled/userdir.load
LoadModule userdir_module /usr/lib/apache2/modules/mod_userdir.so
# cat /etc/apache2/mods-enabled/userdir.conf
<IfModule mod_userdir.c>
UserDir public_html
UserDir disabled root
<Directory /home/*/public_html>
AllowOverride FileInfo AuthConfig Limit
Options MultiViews Indexes SymLinksIfOwnerMatch
IncludesNoExec
</Directory>
</IfModule>

Include .load .conf


/etc/apache2/mods-enabled/
: --
; XML / .
/, --
.


Apache.

Apache. ;
:
Listing 5.
# Global error log.

ErrorLog /var/log/apache2/error.log

,
, , .
.
LogFormat , ,
; , CustomLog Apache actually
.
, .
,
.
LogFormat , %.
,
, , Listing 6.
Listing 6. LogFormat
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""
combined
CustomLog /var/log/apache2/referer_log combined

Apache .
: %h IP- , ,
%t , %>s HTTP ,
%{Referer} ,
.
, LogFormat CustomLog
. Listing 6 combined,
, , myfoobarlog.
, combined, common, referer,
agent. ,
log-.

web-
, multi-homing

, Apache,
.
, .
,
AccessFileName,
.htaccess.

<Directory>. :
Listing 7. directory
#Let's have some Icons, shall we?
Alias /icons/ "/usr/share/apache2/icons/"
<Directory "/usr/share/apache2/icons">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

Apache
.
Apache,
.
<VirtualHost>; ,
, /etc/apache2/sites-enabled/, .
, :
Listing 8.
<VirtualHost "foo.example.com">
ServerAdmin webmaster@foo.example.com
DocumentRoot /var/www/foo
ServerName foo.example.com
<Directory /var/www/foo>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
CustomLog /var/log/apache2/foo_access.log combined
</VirtualHost>
<VirtualHost "bar.example.org">
DocumentRoot /var/www/bar
ServerName bar.example.org
</VirtualHost>
<VirtualHost *>
DocumentRoot /var/www
</VirtualHost>

* HTTP ,
( , IP-
, -).

, DNS
CNAME.
multi-homing ,
. multi-homing, IP-,
, web-. ,
HTTP- LAN, .
, ,
. BindAddress, - *, IP-,
. :
Listing 9. multi-homing
BindAddress 192.168.2.2
Listen 192.168.2.2:8000
Listen 64.41.64.172:8080

, LAN (
192.168.2.2) 80 8000.
Apache HTTP WAN ,
8080.


Order, Allow from, Deny from <Directory>
.

IP-. Order
.
, ,
web-.
, Auth*, -,
<Directory>. ,
, Listing 10.
Listing 10.
<Directory "/var/www/baz">
AuthName "Baz"
AuthType Basic
AuthUserFile /etc/apache2/http.passwords
AuthGroupFile /etc/apache2/http.groups
Require john jill sally bob
</Directory>

.htaccess-.
, ,
. (
) SSL.
SSL- web- mod_ssl.
SSL, , ,
,
. SSL.
Apache 2.x mod_ssl, web- Apache.