• 微信:
  • hai764003
  • QQ:
  • 511211014
  • E-mail:
  • jaquery@163.com

案例总数51

访问总数312226

收藏总数310757

nginx配置多个站点返回列表

上传时间:2015-03-24 内容关键字:nginx配置多个站点

在/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
==========================================

 

小海哥推荐你看: 博客园  php教程分享网站  phpmywind  脚本之家