基于域名的虚拟主机
Posted ray-mmss
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了基于域名的虚拟主机相关的知识,希望对你有一定的参考价值。
修改nginx服务配置
[[email protected] ~]# vim /usr/local/nginx/conf/nginx.conf .. .. server { listen 80; //端口 server_name www.a.com; //域名 auth_basic "Input Password:"; //认证提示符 auth_basic_user_file "/usr/local/nginx/pass"; //认证密码文件 location / { root html; //指定网站根路径 index index.html index.htm; } } … … server { listen 80; //端口 server_name www.b.com; //域名 location / { root www; //指定网站根路径 index index.html index.htm; } }
创建网站根目录及对应首页文件
[[email protected] ~]# mkdir /usr/local/nginx/www [[email protected] ~]# echo "www" > /usr/local/nginx/www/index.html
重启nginx服务
[[email protected] ~]# /usr/local/nginx/sbin/nginx -s reload // nginx -s reload
以上是关于基于域名的虚拟主机的主要内容,如果未能解决你的问题,请参考以下文章