apache基于IP和端口的虚拟主机
基于IP虚拟机主机
vim /etc/httpd/conf/httpd.conf
添加监听IP
Listen 192.168.0.1:80
Listen 192.168.0.10:80
添加虚拟主机和发布目录
第一台虚拟主机
<VirtualHost 192.168.0.1:80>
ServerAdmin www.123.com
DocumentRoot /webroot/192.168.0.1
ErrorLog logs/192.168.0.1-error_log
CustomLog logs/192.168.0.1-access_log common
</VirtualHost>
<Directory "/webroot/192.168.0.1" >
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from ALL
</Directory>
第二台虚拟主机
<VirtualHost 192.168.0.10:80>
ServerAdmin www.321.com
DocumentRoot /webroot/192.168.0.10
ErrorLog logs/192.168.0.10-error_log
CustomLog logs/192.168.0.10-access_log common
</VirtualHost>
<Directory "/webroot/192.168.0.10" >
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from ALL
</Directory>
基于端口虚拟主机
vim /etc/httpd/conf/httpd.conf
添加端口
Listen 80
Listen 8080
添加虚拟主机和发布目录
第一台虚拟主机
<VirtualHost *:80>
...配置省略
</VirtualHost>
<Directory "/webroot/xx" >
...配置省略
</Directory>
第一台虚拟主机
<VirtualHost *:8080>
...配置省略
</VirtualHost>
<Directory "/webroot/xx" >
...配置省略
</Directory>
原文地址:https://blog.csdn.net/u014516208/article/details/138508130
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!