您的位置:首页 > 运维架构 > Nginx

nginx默认虚拟主机

2018-01-04 10:09 204 查看
vim /usr/local/nginx/conf/nginx.conf //删除server部分
增加
include vhost/*.conf //在conf下面创建一个vhost子目录

[root@localhost conf]# pwd
/usr/local/nginx/conf
mkdir vhost
cd vhost/
vim default.conf //加入如下内容
server
{
listen 80 default_server; // default_server有这个标记的就是默认虚拟主机
server_name aaa.com; //域名
index index.html index.htm index.php;
root /data/wwwroot/default; //网站根目录。Apache的是Document
}
mkdir -p /data/wwwroot/default/
echo “This is a default site.”>/data/wwwroot/default/index.html
/usr/local/nginx/sbin/nginx -t //检测语法
/usr/local/nginx/sbin/nginx -s reload //#重新加载
curl localhost
curl -x127.0.0.1:80 123.com
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  默认虚拟主机
相关文章推荐