博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Nginx 配置多站点
阅读量:7102 次
发布时间:2019-06-28

本文共 955 字,大约阅读时间需要 3 分钟。

hot3.png

在/etc/nginx/下建一个文件夹放站点的配置文件,如example 地址是:/etc/nginx/example
在example文件夹里建多个站点的conf文件,如:example1.conf , example2.conf
每个conf配置文件如下,可修改server_name 和 location地址设置多个站点。
server {
    listen  80;
    server_name  michaelaschmidt.com www.michaelaschmidt.com;
    access_log  /var/www/access_michaelaschmidt.log;
    location / {
      root  /var/www/michaelaschmidt.com;
      index  index.php index.html index.htm;
    }
    error_page  500 502 503 504  /50x.html;
    location = /50x.html {
      root  /usr/share/nginx/html;
    }
    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    location ~ /.php$ {
      fastcgi_pass  127.0.0.1:9000;
      fastcgi_index  index.php;
      fastcgi_param  SCRIPT_FILENAME  /var/www/michaelaschmidt.com/$fastcgi_script_name;
      include     fastcgi_params;
    }
    location ~ //.ht {
      deny  all;
    }
}
保存后在/etc/nginx/nginx.conf里面的http{} 里面加入:
include /etc/nginx/example/*.conf;  #将example文件夹下的所有.conf包含入nginx.conf配置文件
最后记得重启nginx:
/etc/init.d/nginx restart

转载于:https://my.oschina.net/ailingling/blog/496441

你可能感兴趣的文章
服务器性能优化
查看>>
Python 中的赋值、拷贝、引用
查看>>
织梦后台不显示验证码的解决
查看>>
pta l2-7(家庭房产)
查看>>
c++模板实现 linq
查看>>
spring security基本知识(三) 过滤详细说明
查看>>
python with语句上下文管理的两种实现方法
查看>>
谭永基来JNU Zhuhai开讲座了。
查看>>
HashMap和Hashtable的区别
查看>>
CCF NOI1067 最匹配的矩阵
查看>>
POJ3048 HDU2710 Max Factor
查看>>
KMP算法(C语言版)
查看>>
HDU 5726 GCD 求给定序列中与查询段相等的GCD个数
查看>>
Ionic + Cordova 跨平台移动开发环境配置
查看>>
Fedora 17配置Postgresql自动启动
查看>>
运行 python *.py 文件出错,如:python a.py
查看>>
docker基础总结
查看>>
Kafka~消费的有效期
查看>>
openSUSE Linux常用命令行记录
查看>>
JavaScript中如何判断两变量是否“相等”?
查看>>