日期:88/4/3
壹、Web Server (apache_1.3.4) 安裝程序
1. 以 root 身份登入主機。 (假設本主機之ip為140.123.10.211,hostname為bsd1)
2. 取得原始程式檔。
#cd /tmp
#ftp -i ftp.ccu.edu.tw
Name (ftp.ccu.edu.tw:root):anonymous
Password:[email protected]
ftp>bin
ftp>ls
ftp>cd /pub2/www/apache/dist
ftp>get apache_1.3.4.tar.gz
ftp>bye
#pwd
#ls -l
3. 解壓縮原始程式。
#tar xvfz apache_1.3.4.tar.gz
#ls -l
#cd apache_1.3.4
#ls –l
4. 建立及執行編譯環境組態檔。
#echo >apache.config
#ls -l
#chmod +x apache.config
#ls -l
#./configure –help >configure.help
#ls
#more configure.help
#ee apache.config
#!/bin/csh
setenv CFLAGS "-O2 -m486 -pipe"
./configure --enable-module=so --enable-module=digest --enable-module=rewrite
--with-perl=/usr/bin/perl --enable-suexec --suexec-uidmin=100
#./apache.config
5. 編譯及安裝系統。
#ls /usr/local
#make all install
6. 修改組態設定檔 (httpd.conf)
#ls /usr/local
#cd /usr/local/apache/conf
#ee httpd.conf
UserDir WWW (P.6-11)
DirectoryIndex index.html index.htm (P.6-15)
ServerName bsd1.ccu.edu.tw (P.6-11)
Port 80 (P.6-8)
User nobody (P.6-9)
Group nobody (P.6-9)
#CacheNegotiatedDocs (P.6-11)
Alias /icons/ "/usr/local/apache/icons/" (P.6-19)
ScriptAlias /cgi-bin/ "/usr/local/apache/cgi-bin/" (P.6-19)
AddHandler cgi-script .cgi (P.6-19,P6-35)
註: 可用 /usr/local/apache/bin/apachectl configtest 指令來檢查設定是否正確‧
#cd /usr/local/apache/bin
#./apachectl
#./apachectl configtest
./apachectl configtest
Syntax OK
#ps –auxww|grep httpd
抱歉httpd daemon沒有被啟動。
7. 啟動 WWW Server。
#./apachectl start
#ps –auxww|grep httpd
Very good. 有6個httpd daemon被啟動,其中只有一個的owner是root,其他5個為nobody。
停止 WWW Server。
#./apachectl stop
#ps –auxww|grep httpd
httpd daemon真的都沒有了。
#./apachectl start
#ps –auxww|grep httpd
httpd daemon又回來了。
9. 重新讀取WWW Server組態檔
當你有更改組態檔httpd.conf時,你需要重新讀取它,你所更改的設定才會生效哦!
#./apachectl restart
10. 如何測試 WWW Server 是否正常運作?
telnet server_name 80
#telnet localhost 80
:
Escape character is '^]'.
GET / HTTP/1.0 (輸入完按兩次 Enter 鍵)
:
Connection closed by foreign host. (出現此訊息表示正常)
Unable to connect to remote host: Connection refused (出現此訊息表示不正常)
連線網址:http://140.123.10.211/ (140.123.10.211為WWW Server之ip)
#rm /tmp/apache_1.3.4.tar.gz (刪除apache_1.3.4.tar.gz檔案)
#rm –rf /tmp/apache_1.3.4 (刪除apache_1.3.4目錄)
貳、Proxy Server (squid-2.1.PATCH2) 安裝程序
1. 以 root 身份登入主機。
2. 取得原始程式檔。
#ftp -i ftp.ccu.edu.tw
ftp>cd /pub/www/squid/squid-2/STABLE
ftp>get squid-2.1.PATCH2-src.tar.gz
ftp>bye
3. 解壓縮原始程式。
#tar xvfz squid-2.1.PATCH2-src.tar.gz
#cd squid-2.1.PATCH2
4. 建立及執行編譯環境組態檔。
#echo >squid.config
#chmod +x squid.config
#ee squid.config
#!/bin/csh
setenv CFLAGS "-O2 -m486 -pipe"
./configure --enable-snmp --enable-icmp --enable-forw-via-db --enable-htcp --enable-gnuregex
#./squid.config
5. 編譯及安裝系統。
#make all ; make install install-pinger
#cd /usr/local/squid/bin ; ls -l
#file *
#ls -l
#strip *
#ls -l
6. 修改組態設定檔 (squid.conf)
#cd /usr/local/squid/etc
#ee squid.conf
cache_peer proxy.ccu.edu.tw parent 3128 3130 default
cache_peer_domain proxy.ccu.edu.tw !ccu.edu.tw !cy.edu.tw
hierarchy_stoplist cgi-bin ?
hierarchy_stoplist /cgi bin/ /wc/
hierarchy_stoplist ccu.edu.tw 140.123. 127.0.0.1
hierarchy_stoplist www.ccu.edu.tw www.ccunix.ccu.edu.tw ftp.ccu.edu.tw gopher.ccu.edu.tw
hierarchy_stoplist .cgi .asp .idc .dll
acl QUERY urlpath_regex cgi-bin \? \.(cgi|idc|dll|mp3)$ \.ccu\.edu\.tw \.cy\.edu\.tw
acl local_ip src 140.123.0.0/16
acl local_dn srcdomain ccu.edu.tw
no_cache deny QUERY local_ip local_dn
cache_mem 128 MB
cache_swap_low 90
cache_swap_high 95
cache_mem_low 75
cache_mem_high 90
maximum_object_size 4096 KB
cache_dir /home1/cache 1000 16 256
cache_store_log none
ftp_user [email protected]
reference_age 1 week
#TAG: acl
acl manager proto cache_object
acl all src 0.0.0.0/0.0.0.0
acl SSL_ports port 443 563
acl Dangerous_ports port 7 9 19
acl CONNECT method CONNECT
acl ccu src 140.123.0.0/16
acl ccu-ip dst 140.123.0.0/16
acl squid-url urlpath_regex squid-internal
acl cc-ip src 140.123.10.0/24 140.123.19.0/24 140.123.254.0/24
acl ccu-web-dn dstdomain ccu.edu.tw
# TAG: http_access
http_access deny manager !localhost !cc-ip
http_access deny CONNECT !SSL_ports
http_access deny Dangerous_ports
http_access allow localhost
http_access deny ccu-url
http_access allow squid-url !ccu-web-dn
http_access allow ccu
http_access deny all
#TAG: icp_access
icp_access allow squid-url !ccu-web-dn
icp_access allow all
#TAG: miss_access
miss_access allow squid-url ccu localhost !ccu-web-dn
miss_access deny !ccu !localhost all
cache_mgr squid@w3.ccu.edu.tw
cache_effective_user nobody
cache_effective_group nogroup
log_icp_queries off
query_icmp on
7. 建立 cache 資料目錄結構。
#mkdir /home1/cache
#chown nobody.nogroup /home1/cache
#cd /usr/local/squid/bin
#./squid –z (需等幾分鐘)
8. 啟動 Proxy Server。
#chown nobody.nogroup /usr/local/squid/logs
#./RunCache&
註:kill -9 `cat /usr/local/squid/logs/squid.pid` 停止服務。
kill -HUP `cat /usr/local/squid/logs/squid.pid` 重新讀取組態檔。
◎ 如何測試 WWW Server 是否正常運作?
telnet server_name 3128
:
Escape character is '^]'.
GET / HTTP/1.0 (輸入完按兩次 Enter 鍵)
:
Connection closed by foreign host. (出現此訊息表示正常)
Unable to connect to remote host: Connection refused (出現此訊息表示不正常)
參、實習注意事項
一、各組主機 IP Address 及 Domain Name
組別 |
IP Address |
Domain Name |
一 |
140.123.10.211 |
bsd1.ccu.edu.tw |
二 |
140.123.10.212 |
bsd2.ccu.edu.tw |
三 |
140.123.10.213 |
bsd3.ccu.edu.tw |
四 |
140.123.10.214 |
bsd4.ccu.edu.tw |
五 |
140.123.10.215 |
bsd5.ccu.edu.tw |
六 |
140.123.10.216 |
bsd6.ccu.edu.tw |
七 |
140.123.10.217 |
bsd7.ccu.edu.tw |
二、組態檔取得方式
ftp://140.123.254.3/pub/ccu/course/httpd.conf
ftp://140.123.254.3/pub/ccu/course/squid.conf
Tags: 壹、web, server, 身份登入主機。, (apache134), 日期:8843