by Weithenn on 星期三, 7月 07, 2010
Lab1. 設定 Apache 基本服務
- RPMS: httpd、httpd-manual (才有 .htaccess 語法可參考)
- /etc/httpd/conf/httpd.conf /etc/httpd/conf.d/*
- TCP port 80 and 443
# yum –y install httpd httpd-manual
# service httpd configtest ; service httpd start ; chkconfig httpd on
# vi /etc/sysconfig/iptables
-A FW-RULES -p tcp -s 192.168.0.200/32 --dport 80 -j ACCEPT
# vi /etc/httpd/conf/httpd.conf
DocumentRoot /var/www/html
# restorecon –R /var/www/html
# elinks http://server.example.com
# vi /etc/httpd/conf/httpd.conf //Virtual Host設定
NameVirtualHost 192.168.0.100:80
<VirtualHost 192.168.0.100:80>
ServerAdmin webmaster@server100.example.com
DocumentRoot /www/docs/dummy-host.example.com
ServerName server100.example.com
ErrorLog logs/dummy-host.example.com-error_log
CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
Lab2. 設定 Apache 支援 CGI Script
# vi /var/www/cgi-bin/test.cgi
#!/usr/bin/perl
print "\n\nhello world";
# chmod +x test.cgi //給予 test.cgi 可執行的權限
Lab3. 設定 Apache 支援.htaccess 保護功能
# locate htaccess //要安裝httpd-manual才有 .htaccess 語法可參考
/var/www/manual/howto/htaccess.html
# elinks /var/www/manual/howto/htaccess.html //找 Authentication example 即可
# vi /etc/httpd/conf/httpd.conf
AllowOverride Authconfig
# vi .htaccess //設定 .htaccess 設定
AuthName “login”
AuthType basic
AuthUserFile /var/www/html/.htpasswd
require user bob may
# htpasswd -mc /var/www/html/.htpasswd weithenn //建立可存取使用者帳號 weithenn 並設定密碼 (第一個帳號需加上參數 -c)
# htpasswd -m /var/www/html/.htpasswd chris //建立可存取使用者帳號 chris 並設定密碼
Lab4. 設定 Squid
# yum –y install squid
# chkconfig squid on
# vi /etc/squid/squid.conf
acl lanuser src 192.168.0.0/24 //允許使用 Squid 服務的網段
http_access allow lanuser
# service squid start