企业级Ngnix基于域名的配置_include

使用include进行nginx.conf文件
1. 编辑文件

vim /usr/local/nginx/conf/nginx.conf
worker_processes  1;
events {
    worker_connecti
    ons  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    include  extra/baobaotao.conf; 
    include  extra/etiantian.conf;
    include  extra/blog.conf;
}

2.创建目录 

mkdir -p /usr/local/nginx/conf/extra


3.创建文件(其他的etiantian/baobaotao.conf类似)

vim /usr/local/nginx/conf/extra/baobaotao.conf
server {
    listen       80;
    server_name  www.baobaotao.com;
    location / {
        root   html/baobaotao;
        index  index.html index.htm;
    }
}

4. 检查配置,重启服务

cd /usr/local/nginx/sbin
./nginx -t              【测试ok后重启服务】


5. 配置hosts(这里全部是宿主主机的IP)

echo "192.168.25.144 www.baobaotao.com" >> /etc/hosts
echo "192.168.25.144 www.etiantian.com" >> /etc/hosts
echo "192.168.25.144 www.blog.com" >> /etc/hosts
tail /etc/hosts

6. 测试

image

posted @ 2018-07-11 18:37  小a玖拾柒  阅读(212)  评论(0编辑  收藏  举报