我是靠谱客的博主 坚定长颈鹿,最近开发中收集的这篇文章主要介绍nginx一个域名多站点配置,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

一个域名多站点nginx配置:

server {                                                                                
        listen 80;                                                                      
        server_name loc.com;             
        index index.php index.html index.htm;                                           
      
        error_page 404 /404.html;                                                       
        error_page   500 502 503 504  /50x.html;                                        
       
        ## boss端
        location ^~ /boss {
            alias /usr/boss/src/public/;
            try_files $uri $uri/ @boss;            
            location ~ .php$ {
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $request_filename;
                include fastcgi_params;
            }
        }
        location @boss{
          rewrite /boss/(.*)$ /boss/index.php?/$1 last;
        }
        
        ## shop端
        location ^~ /shop {
            alias /usr/shop/src/public/;
            try_files $uri $uri/ @shop;
            location ~ .php$ {
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $request_filename;
                include fastcgi_params;
            }
        }
        location @shop{
          rewrite /shop/(.*)$ /shop/index.php?/$1 last;
        }
        
        ## 商品
        location ^~ /goods{
            alias /usr/goods/src/public/;
            try_files $uri $uri/ @goods;
            location ~ .php$ {
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $request_filename;
                include fastcgi_params;
            }
        }
        location @goods{
          rewrite /goods/(.*)$ /goods/index.php?/$1 last;
        }

        location ~ .php$ {
           fastcgi_pass 127.0.0.1:9000;
           fastcgi_index index.php;
           fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
           include fastcgi_params;
        }
        location ~ /.ht {
           deny all;
        }

        error_log /log/nginx.error.log error;               
} 

最后

以上就是坚定长颈鹿为你收集整理的nginx一个域名多站点配置的全部内容,希望文章能够帮你解决nginx一个域名多站点配置所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(71)

评论列表共有 0 条评论

立即
投稿
返回
顶部