Nginx多站点/域名配置

栏目: 服务器 · Nginx · 发布时间: 7年前

内容简介:Nginx多站点/域名配置

假设有两个域名,joker.moe和blog.joker.moe,要为每个域名建立一个站点http://joker.moe访问/www目录,http://blog.joker.moe访问/www/bolog目录。

在nginx.conf同目录下新建文件夹vhosts,在nginx.conf里添加 include vhosts/*.conf; ,如:

worker_processes auto;
events {
        use epoll;
        ......
}
http
    {
        include       mime.types;
        default_type  application/octet-stream;

        ......

server
    {
        listen 80 default_server;
        #listen [::]:80 default_server ipv6only=on;
        server_name _;
        index index.html index.htm index.php;
        root  /www;
        location ~ .*\.php(\/.*)*$ {
            root           /www;
            fastcgi_pass   unix:/run/php-fpm/php-fpm.sock;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
        ......
    }
include vhosts/*.conf;
}

在vhosts目录里新建blog.joker.moe.conf,当然可以随便命名,后缀是 .conf 就可以了。一下为参考内容

server
    {
        listen 80;
        #listen [::]:80;
        server_name blog.joker.moe ;
        index index.html index.htm index.php default.html default.htm default.php;
        root  /www/blog.joker.moe;


        #error_page   404   /404.html;

        # Deny access to PHP files in specific directory
        #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }

        location ~ .*\.php(\/.*)*$ {
            root           /www/blog.joker.moe;
            fastcgi_pass   unix:/run/php-fpm/php-fpm.sock;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

        ......
    }

最后重启nginx即可。

标签:nginx


以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Music Recommendation and Discovery

Music Recommendation and Discovery

Òscar Celma / Springer / 2010-9-7 / USD 49.95

With so much more music available these days, traditional ways of finding music have diminished. Today radio shows are often programmed by large corporations that create playlists drawn from a limited......一起来看看 《Music Recommendation and Discovery》 这本书的介绍吧!

URL 编码/解码
URL 编码/解码

URL 编码/解码

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试