You are on page 1of 7

Chng trnh o t o: LINUX NETWORK ADMINISTRATION - LPI

Web Server Apache

T i v bi vi t: Web Server - Apache 1. Gi i thi u Apache - Chng trnh my ch HTTP l m t chng trnh dnh cho my ch i tho i qua giao th c HTTP. Apache ch y trn cc h i u hnh tng t nh Unix, Microsoft Windows, Novell Netware v cc h i u hnh khc. Apache ng m t vai tr quan tr ng trong qu trnh pht tri n c a m ng web th gi i. Khi c pht hnh l n u, Apache l chng trnh my ch m ngu n m duy nh t c kh nng c nh tranh v i chng trnh my ch tng t c a Netscape Communications Corporation m ngy nay c bi t n qua tn thng m i Sun Java System Web Server. T tr i, Apache khng ng ng ti n tri n v tr thnh m t ph n m m c s c c nh tranh m nh so v i cc chong trnh my ch khc v m t hi u su t v tnh nng phong ph. T thng 4 nm 1996, Apache tr thnh m t chng trnh my ch HTTP thng d ng nh t. Hn n a, Apache th ng c dng so snh v i cc ph n m m khc c ch c nng tng t . Tnh n thng 1 nm 2007 th Apache chi m n 60% th tr ng cc chong trnh phn ph i trang web. Apache c pht tri n v duy tr b m t c ng ng m ngu n m d i s b o tr c a Apache Software Foundation. Apache c pht hnh v i gi y php Apache License v l m t ph n m m t do v mi n ph. 2. Chu n b
e-mail: tranxuanchien@live.com website: www.linuxwhoami.blogspot.com TP. HCM 06/2009

Chng trnh o t o: LINUX NETWORK ADMINISTRATION - LPI

- t IP - t hostname: server06.hcm.com - T t firewall, SELinux - C u hnh my l m t Primary Name Server cho domain hcm.com sao cho www.hcm.com c IP chnh l Dns Server. 3. C u hnh - t IP (192.168.9.106) #vi /etc/sysconfig/network-scripts/ifcfg-eth0 - t hostname (server06.hcm.com) #vi /etc/sysconfig/network #vi /etc/hosts - File c u hnh #cp /usr/share/doc/bind-9.3.3/sample/etc/name.conf /var/named/chroot/etc #vi /var/named/chroot/etc/named.conf N i dung: zone "hcm.com" { type master; file "hcm.db"; }; zone "9.168.192.in-addr-arpa" { type master; file "192.168.9.db"; }; - T o file database ngh ch vi /var/named/chroot/var/named/192.168.9.db N i dung: $TTL 86400 @ IN SOA server06.hcm.com. root.hcm.com. ( 2009062001 3H 15M 1W 1D ) IN NS server06.hcm.com 106 IN PTR server06.hcm.com. 106 IN PTR www.hcm.com. - T o file database thu n vi /var/named/chroot/var/named/hcm.db N i dung: $TTL 86400 @ IN SOA server06.hcm.com. root.hcm.com. (
e-mail: tranxuanchien@live.com website: www.linuxwhoami.blogspot.com TP. HCM 06/2009

Chng trnh o t o: LINUX NETWORK ADMINISTRATION - LPI

2009062001 3H 15M 1W 1D ) IN NS server06.hcm.com server06 IN A 192.168.9.106 www IN A 192.168.9.106 4. Lab - Ki m tra gi httpd (ci t n u cha c) #rpm -qa httpd - start d ch v httpd #service httpd start - Ki m tra Server c m port 80/tcp cha? #netstat -ltn - Truy c p vo web (xu t hi n mn hnh default apache) www.hcm.com File c u hnh httpd: /etc/httpd/conf/httpd.conf 4.1 C u hnh Server listen port 8000 thay v port 80 - S a dng 134 c a file c u hnh: Listen 8000 - restart d ch v #service httpd restart - Ki m tra M trnh duy t nh p:www.hcm.com:8000 4.2 C u hnh email c a user qu n tr Web Server l admin@hcm.com - C u hnh dng 251 file c u hnh: ServerAdmin admin@hcm.com - restart d ch v #service httpd restart 4.3 t tn cho Website chnh l www.hcm.com - C u hnh dng 265, file c u hnh: ServerName www.hcm.com:8000 - restart d ch v
e-mail: tranxuanchien@live.com website: www.linuxwhoami.blogspot.com TP. HCM 06/2009

Chng trnh o t o: LINUX NETWORK ADMINISTRATION - LPI

#service httpd restart - T o file v i n i dung b t k #vi /var/www/html/index.html - M trnh duy t ki m tra. 4.4 C u hnh th m c ch a Website l /data/web - T o th m c #mkdir /data #mkdir /data/web - T o file v i n i dung b t k #vi /data/web/index.html - C u hnh dng 281 trong file c u hnh DocumentRoot "/data/web" - restart d ch v #service httpd restart 4.5 C u hnh Apache sao cho khi truy c p Website , file home.html s c load u tin. - C u hnh dng 391 file c u hnh DirectoryIndex home.html - restart d ch v #service httpd restart 4.6 Xem log c a httpd - Error log: #tail -f /var/log/httpd/error_log - Access log: #tail -f /var/log/httpd/access_log 5. C u hnh Alias Yu c u: C u hnh Server sao cho khi truy c p www.hcm.com/soft/ s truy xu t vo th m c /chiase/soft - Thm vo cu i file c u hnh dng sau: Alias /soft/ "/chiase/soft/" - T o file /chiase/soft/index.html - restart d ch v #service httpd restart
e-mail: tranxuanchien@live.com website: www.linuxwhoami.blogspot.com TP. HCM 06/2009

Chng trnh o t o: LINUX NETWORK ADMINISTRATION - LPI

- Ki m tra: truy c p www.hcm.com/soft/ 6. C u hnh ch ng th c cho th m c /chiase/soft Yu c u: C u hnh Web Server sao cho ch c user hv1, hv2 c php truy xu t vo www.hcm.com/soft.com - Thm vo cu i file c u hnh o n sau: <Directory /chiase/soft/> AuthType Basic AuthName "Chung thuc nguoi dung" AuthUserFile /etc/httpd/conf/htpasswd Require user hv1 hv2 </Directory> - T o user v passwd ch ng th c cho web #htpasswd -c /etc/httpd/conf/htpasswd hv1 #htpasswd /etc/httpd/conf/htpasswd hv2 - Lu : Dng l nh u tin ch c php ch y m t l n duy nh t! - restart d ch vu #service httpd restart - Ki m tra: truy c p vo www.hcm.com/soft/ v i cc user v a t o. 7. C u hnh Hosting - C u hnh Web Server Hosting 2 Website www.hcm.com www.linux.com - C u hnh Dns Server ch u trch nhi m phn gi i 2 record sau www.hcm.com www.linux.com - T o 2 file database thu n l hcm.db v linux.db vi /var/named/chroot/var/named/hcm.db N i dung: $TTL 86400 @ IN SOA server06.hcm.com. root.hcm.com. ( 2009062001 3H 15M 1W 1D ) IN NS server06.hcm.com
e-mail: tranxuanchien@live.com website: www.linuxwhoami.blogspot.com TP. HCM 06/2009

Chng trnh o t o: LINUX NETWORK ADMINISTRATION - LPI

server06 IN A 192.168.9.106 www IN A 192.168.9.106 vi /var/named/chroot/var/named/linux.db N i dung: $TTL 86400 @ IN SOA server06.linux.com. root.linux.com. ( 2009062001 3H 15M 1W 1D ) IN NS server06.linux.com server06 IN A 192.168.9.106 www IN A 192.168.9.106 - Ch nh s a file c u hnh #vi /var/named/chroot/etc/named.conf N i dung: zone "hcm.com" { type master; file "hcm.db"; }; zone "9.168.192.in-addr-arpa" { type master; file "192.168.9.db"; }; zone "linux.com" { type master; file "linux.db"; }; - Ch nh s a dng 972 file c u hnh NameVirtualHost 192.168.9.106:80 - thm vo cu i file c u hnh o n sau: <VirtualHost www.nhatnghe.com:80> ServerAdmin webmaster@hcm.com DocumentRoot /data/web ServerName www.hcm.com ErrorLog logs/www.hcm.com-error_log CustomLog logs/www.hcm.com-access_log common </VirtualHost> <VirtualHost www.linux.com:80> ServerAdmin webmaster@linux.com
e-mail: tranxuanchien@live.com website: www.linuxwhoami.blogspot.com TP. HCM 06/2009

Chng trnh o t o: LINUX NETWORK ADMINISTRATION - LPI

DocumentRoot /data/web ServerName www.linux.com ErrorLog logs/www.linux.com-error_log CustomLog logs/www.linux.com-access_log common </VirtualHost>

- T o th m c web g c /data/web1 v t o file /data/web1/index.html - restart d ch v httpd #service httpd restart - ki m tra website 8. C u hnh Web Server sao cho cc user trn h th ng c th truy c p vo trang web c nhn c a user - C u hnh file httpd.conf + S a dng 355 #UserDir disable + Dng 362 UserDir public_html - M ro t dng 370 n 381 - T o user hv1 v hv2 - T o th m c: #mkdir /home/hv1/public_html #mkdir /home/hv2/public_html - T o file (N i dung b t k) #vi /home/hv1/public_html/index.html #vi /home/hv2/public_html/index.html - C p quy n cho home dir c a t ng user #chmod 755 -R /home/hv1 #chmod 755 -R /home/hv2 - restart httpd #service httpd restart - Ki m tra: truy c p vo web http://www.nhatnghe.com/~hv1 v http://www.nhatnghe.com/~hv2
e-mail: tranxuanchien@live.com website: www.linuxwhoami.blogspot.com TP. HCM 06/2009

You might also like