大佬教程收集整理的这篇文章主要介绍了配置Nginx虚拟主机,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
<h2 id="实验环境">实验环境
yum install -y epel-*
yum isntall -y Nginx vim
setenforce 0
systemctl stop firewalld
systemctl disable firewalld
vim /etc/Nginx/conf.d/vhosts.conf
server { listen 8081; root /var/wwwroot/site1; index index.html;LOCATIOn / { }
}
server {
listen 8082;
root /var/wwwroot/site2;
index index.html;
systemctl start Nginx
http://192.168.204.135:8081/
http://192.168.204.135:8082/
vim /etc/Nginx/conf.d/vhosts.conf
server { listen 80; server_name site1.test.com; root /var/wwwroot/site1; index index.html;LOCATIOn / { }
}
server {
listen 80;
server_name site2.test.com;
root /var/wwwroot/site2;
index index.html;
systemctl restart Nginx
编辑C:\Windows\System32\drivers\etc\hosts
文件,
添加以下内容(根据实际情况自己修改)
192.168.204.135 site1.test.com
192.168.204.135 site2.test.com
http://site1.test.com/
http://site2.test.com/
ifconfig ens33:1 192.168.204.151
ifconfig ens33:2 192.168.204.152
vim /etc/Nginx/conf.d/vhosts.conf
server { listen 192.168.204.151:80; root /var/wwwroot/site1; index index.html;LOCATIOn / { }
}
server {
listen 192.168.204.152:80;
root /var/wwwroot/site2;
index index.html;
systemctl restart Nginx
http://192.168.204.151/
http://192.168.204.152/
本文链接:Nginx-vhost.html" class="uri">https://www.cnblogs.com/connect/p/Nginx-vhost.html
以上是大佬教程为你收集整理的配置Nginx虚拟主机全部内容,希望文章能够帮你解决配置Nginx虚拟主机所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。