虚拟主机
httpd-2.4示例步骤:
1. 进行规划虚拟主机 192.168.209.8:80,192.168.209.10:80 www.10linux.com,www.iounix.com /var/www/html/10linux,/var/www/html/iounix 2. ]# mkdir /var/www/html/{10linux,iounix} ~]# vim /var/www/html/iounix/index.html <h1>iounix.com</h1> ~]# vim /var/www/html/10linux/index.html <h1>10linux.com</h1> <h2>welcome here</h2> 3. 编辑配置文件 /etc/httpd/conf.d/10linux.conf <VirtualHost 192.168.209.8:80> ServerName www.10linux.com DocumentRoot "/var/www/html/10linux" <Directory "/var/www/html/10linux"> Options None AllowOverride None Require all granted </Directory> CustomLog "logs/10linux_access_log" </VirtualHost> /etc/httpd/conf.d/iounix.conf <VirtualHost 192.168.209.10:80> ServerName www.iounix.com DocumentRoot "/var/www/html/iounix" <Directory "/var/www/html/iounix"> Options None AllowOverride None Require all granted </Directory> CustomLog "logs/iounix_access_log" combined </VirtualHost> 4. httpd -t systemctl restart httpd.service 5. 验证:不同IP,相同端口 ip addr add 192.168.209.10/24 dev eth0 6. 验证:相同IP,不同端口 需在配置文件中添加Listen 10080,修改IP地址; 使IP相同,port不同 ip addr del 192.168.209.10/24 dev eth0 7. 验证:相同IP,相同端口,不同主机名 可搭建DNS解析验证 问题:重启httpd服务Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details.
httpd内建的状态页面
httpd-2.4示例:
1 vim /etc/httpd/conf.d/10linux.conf <VirtualHost 192.168.209.8:80> ServerName www.10linux.com DocumentRoot "/var/www/html/10linux" <Directory "/var/www/html/10linux"> Options None AllowOverride None Require all granted </Directory> CustomLog "logs/10linux_access_log" <Location /server-status> SetHandler server-status <RequireAll> Require ip 172.16 </RequireAll> </Location> </VirtualHost> 2 查看:www.10linux.com/server-status 3 如要做认证: <Location /server-status> SetHandler server-status AuthType ... ... </Location>
原创文章,作者:s,如若转载,请注明出处:http://www.178linux.com/77502