Nginx下多虚拟主机的配置(入门级的)
1:下载安装nginx(省落 。。。。。。)
2: vi /opt/nginx/conf/nginx.conf
在 #gzip on;后添加如下部分:
server {
listen 99;
server_name localhost;
location / {
index index.html;
root /var/www/vhost1/htdocs;
}
}
server {
listen 88;
server_name localhost;
location / {
index index.html;
root /var/www/vhost2/htdocs;
}
}
|
4:mkdir -p /var/www/vhost1/htdocs
cd /var/www/vhost1/htdocs
echo "1111111111111" >index.html
mkdir -p /var/www/vhost2/htdocs
cd /var/www/vhost2/htdocs
echo "22222222222">index.html
5:pkill nginx杀死nginx(如果nginx已经启动),开启nginx /opt/nginx/sbin/nginx
6:测试:(我的机器的ip为172.17.61.150)
99端口 如图:
88端口 如图:
到目前为止一个ip上实现, 不同端口的不同显示!
阅读(1831) | 评论(0) | 转发(0) |