1.配置vhost.conf
NameVirtualHost 192.168.2.74:80 <VirtualHost 192.168.2.74:80> DocumentRoot /var/www/html/localhost/public_html ServerName 192.168.2.74 ServerAdmin example@gmail.com ErrorLog "|rotatelogs /var/www/html/localhost/log/error_%Y_%m_%d.log 86400 480" CustomLog "|rotatelogs /var/www/html/localhost/log/access_%Y_%m_%d.log 86400 480" common </VirtualHost>
2.配置httpd.conf
<Directory /> AllowOverride None Options None Order allow,deny Allow from all </Directory>
3.配置防火墙规则
/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT /etc/rc.d/init.d/iptables save
注:删除规则的方法:
先找到规则的编号,然后按编号删除 $iptables -nvL --line-numbers Chain INPUT (policy ACCEPT 0 packets, 0 bytes) num pkts bytes target prot opt in out source destination 1 0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:80 2 495 39735 ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED 3 0 0 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0 4 0 0 ACCEPT all -- lo * 0.0.0.0/0 0.0.0.0/0 $iptables -D INPUT 1 $/etc/rc.d/init.d/iptables save
4.重启httpd服务
service httpd restart