httpd伺服器的安裝和基本配置

tonykorn97發表於2008-10-18

主要了解虛擬目錄的使用

1,安裝
[root@station10 /]# yum install httpd*

[root@station10 /]# chkconfig httpd on

[@more@]

2,啟動
[root@station10 /]# service httpd start
Starting httpd: [ OK ]
[root@station10 /]#

3,校驗 DocumentRoot目錄:
DocumentRoot "/var/www/html"

4,測試

5,建立目錄
[root@station10 /]# mkdir -p /var/www/virtual/www10.example.com/html
[root@station10 /]# cd /var/www/virtual/www10.example.com/html
[root@station10 html]# cat > index.html <> www10.example.com
> EOF
[root@station10 html]#


6,修改配置檔案

NameVirtualHost 192.168.0.10:80


ServerName www10.example.com
ServerAdmin
DocumentRoot /var/www/virtual/www10.example.com/html
ErrorLog logs/www10.example.com-error_log
CustomLog logs/www10.example.com-access_log combined


Options Indexes Includes


7,測試dns是否正常
[root@station10 html]# dig www10.example.com

; <<>> DiG 9.3.3rc2 <<>> www10.example.com
;; global options: printcmd
;; Got answer:
;; ->>HEADER<;; flags: qr aa rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 1, ADDITIONAL: 1

;; QUESTION SECTION:
;www10.example.com. IN A

;; ANSWER SECTION:
www10.example.com. 86400 IN CNAME station10.example.com.
station10.example.com. 86400 IN A 192.168.0.10

;; AUTHORITY SECTION:
example.com. 86400 IN NS server1.example.com.

;; ADDITIONAL SECTION:
server1.example.com. 86400 IN A 192.168.0.254

;; Query time: 12 msec
;; SERVER: 192.168.0.254#53(192.168.0.254)
;; WHEN: Fri Oct 17 20:59:17 2008
;; MSG SIZE rcvd: 113

[root@station10 html]#


8,語法檢查:
[root@station10 html]# service httpd configtest
Syntax error on line 1002 of /etc/httpd/conf/httpd.conf:
directive missing closing '>'
[root@station10 html]#

按照提示修改,然後重新執行:
[root@station10 html]# service httpd configtest
Syntax OK
[root@station10 html]# service httpd reload
Reloading httpd: [ OK ]
[root@station10 html]#


9,測試
[root@station10 conf]# elinks -dump www10.example.com
www10.example.com
[root@station10 conf]#

10. 防火牆設定
[root@station10 html]# iptables -I INPUT 1 -s 192.168.0.0/24 -p tcp --dport 80 -j ACCEPT
[root@station10 html]# service iptables save
Saving firewall rules to /etc/sysconfig/iptables: [ OK ]
[root@station10 html]#

11,本機可以訪問,其他機器訪問一直報錯:
[root@station10 conf]# elinks -dump station12.example.com
ELinks: Receive timeout
[root@station10 conf]#

把iptables重新啟動測試,執行setup設定firewall等。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/312079/viewspace-1012067/,如需轉載,請註明出處,否則將追究法律責任。

相關文章