时间:2023-07-17 12:21:01 | 来源:网站运营
时间:2023-07-17 12:21:01 来源:网站运营
Apache 配置虚拟主机: 虚拟主机是在一台Web服务器上,可以为多个独立的IP地址、域名或端口号提供不同的Web站点。对于访问量不大的站点来说,这样可以降低单个站点的运营成本。mkdir /var/www/ip1 /var/www/ip2echo "this is 192.168.184.128's web"> /var/www/ip1/index.htmlecho "this is 192.168.184.129's web"> /var/www/ip2/index.html
<Virtualhost 192.168.184.128> DocumentRoot /var/www/ip1</Virtualhost><Virtualhost 192.168.184.129> DocumentRoot /var/www/ip2</Virtualhost>
systemctl restart httpd
setenforce 0firewall-cmd --add-service=http --permanentfirewall-cmd --reload
mkdir /var/www/www1 /var/www/www2echo "www1.test123.com's web."> /var/www/www1/index.htmlecho "www2.test123.com's web."> /var/www/www2/index.html
<Virtualhost 192.168.184.128> DocumentRoot /var/www/www1 ServerName www1.test123.com</Virtualhost><Virtualhost 192.168.184.128> DocumentRoot /var/www/www2 ServerName www2.test123.com</Virtualhost>
systemctl restart httpd
192.168.184.128 www1.test123.com192.168.184.128 www2.test123.com
Windows操作系统: 编辑C:/Windows/System32/drivers/etc/hosts,在配置文件后面添加一下内容192.168.184.128 www1.test123.com192.168.184.128 www2.test123.com
mkdir /var/www/8088 /var/www/8089echo "8088 port's web."> /var/www/8088/index.htmlecho "8089 port's web."> /var/www/8089/index.html
Listen 8088Listen 8089<Virtualhost 192.168.184.128:8088> DocumentRoot /var/www/8088</Virtualhost><Virtualhost 192.168.184.128:8089> DocumentRoot /var/www/8089</Virtualhost>
systemctl restart httpd
firewall-cmd --add-port=8088-8089/tcp --permanentfirewall-cmd --reload
关键词:主机,虚拟,配置