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


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

查看所有标签

猜你喜欢:

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

Java RESTful Web Service实战

Java RESTful Web Service实战

韩陆 / 机械工业出版社 / 2014-10-1 / 69.00

国内首本完整、深度地讲解如何基于Java标准规范实现REST风格的Web服务的专著,阿里巴巴Java技术专家12年开发经验结晶,3位业内著名技术专家联袂推荐!不仅深刻解读了最新的JAX-RS标准和其API设计,以及Jersey的使用要点和实现原理,而且系统讲解了REST的基本理论,更重要的是从实践角度深度讲解了如何基于Jersey实现完整的、安全的、高性能的REST式的Web服务。 《Jav......一起来看看 《Java RESTful Web Service实战》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码