主要了解虚拟目录的使用
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 root@station10.example.com
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/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/312079/viewspace-1012067/