91 Views

Nginx下多站点配置

使用VPS后,没有安装控制面板,什么都需要自己配置,还真是麻烦,这里记录了nginx下多站点的配置(ubuntu环境)。

在/usr/local/nginx/下新建vhosts文件夹:

mkdir vhosts

进入,新建第一个站点的配置文件, 如:

vi yilee.info.conf

内容为:

server
        {
                listen       80;
                server_name yilee.info www.yilee.info;
                index index.html index.htm index.php;
                root  /home/wwwroot;
                include ../conf/wordpress.conf;
                location ~ .*\.(php|php5)?$
                        {
                                fastcgi_pass  unix:/tmp/php-cgi.sock;
                                fastcgi_index index.php;
                                include fcgi.conf;
                        }

                location /status {
                        stub_status on;
                        access_log   off;
                }

                location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
                        {
                                expires      30d;
                        }

                location ~ .*\.(js|css)?$
                        {
                                expires      12h;
                        }

        }

这里需要注意server_name为域名,root为站点的位置。

其他站点的配置文件和上面类似,只需更改server_name和root即可。

打开nginx的配置文件:

vi ../conf/nginx.conf

引入上面的配置文件即可,可以用通配符。

include /usr/local/nginx/vhosts/*.conf;

最后重启nginx即可:

/usr/local/nginx/sbin/nginx -s  reload

无觅相关文章插件,快速提升流量

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注

*


*

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>