Nginx配置虚拟主机(外部文件引入方式)

步骤1:打开Nginx主配置文件(nginx.conf)引入外部虚拟主机配置文件
shell> vi /php/server/nginx/conf/nginx.conf
http{}中加入:include vhosts/*.conf;

步骤2:新建外部虚拟主机目录(vhosts)
shell> mkdir -p /php/server/nginx/conf/vhosts
步骤3:新建新建虚拟主机
shell> cd /php/server/nginx/conf/vhosts
shell> vi nginx1.conf

server {
    # 监听端口
    listen 80;
    # 绑定域名(多个之间用空格隔开)
    server_name blog.com;

    location / {
        # 项目根目录
        root /php/wwwroot/blog;
        # 默认首页
        index index.html index.htm;
   }
}

步骤4:重启服务即可
shell> /php/server/nginx/sbin/nginx -s reload

猜你喜欢

转载自blog.csdn.net/csdn_heshangzhou/article/details/82765576
今日推荐