返回

nginxinclude多个conf

发布时间:2023-02-06 05:21:37 236
# html# php# nginx

nginx conf写多个server可以实现多站点吗

在/etc/nginx/下建一个文件夹放站点的配置文件,如example地址是:/etc/nginx/example

在example文件夹里建多个站点的conf文件,如:example1.conf,example2.conf

每个conf配置文件如下,可修改server_name和location地址设置多个站点。

server{
listen80;
server_namemichaelaschmidt.com
www.michaelaschmidt.com;
access_log/var/www/access_michaelaschmidt.log;
location/{
root/var/www/michaelaschmidt.com;
indexindex.phpindex.htmlindex.htm;
error_page500502503504/50x.html;
location=/50x.html{
root/usr/share/nginx/html;
#passthePHPscriptstoFastCGIserverlisteningon127.0.0.1:9000
location~/.php${
fastcgi_pass127.0.0.1:9000;
fastcgi_indexindex.php;
fastcgi_paramSCRIPT_FILENAME/var/www/michaelaschmidt.com/$fastcgi_script_name;
includefastcgi_params;
location~//.ht{
denyall;

保存后在/etc/nginx/nginx.conf里面的http{}里面加入:

include/etc/nginx/example/*.conf;#将example文件夹下的所有.conf包含入nginx.conf配置文件

最后记得重启nginx:

/etc/init.d/nginxrestart

本回答由提问者推荐

为什么在Nginx的nginx.conf配置文件中,加入include rewrite.conf 就无法重启Nginx

可能性很多.你rewrite.conf文件 内有严重错误,肯定会启动失败,.rewrite.conf路径不对也会启动失败.基本就这俩问题了吧

特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报
评论区(0)
按点赞数排序
用户头像
精选文章
thumb 中国研究员首次曝光美国国安局顶级后门—“方程式组织”
thumb 俄乌线上战争,网络攻击弥漫着数字硝烟
thumb 从网络安全角度了解俄罗斯入侵乌克兰的相关事件时间线
下一篇
nginx location规则优先级 2023-02-06 04:41:08