企业级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
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

猜你喜欢

转载自www.cnblogs.com/ftl1012/p/9296142.html
今日推荐