怎么在 localhost 下访问多个 Laravel 项目,通过一个IP访问多个项目(不仅仅是改变端口哦)

淺唱寂寞╮ 提交于 2019-11-30 18:50:53
server {
    listen 80;

    server_name blog.sweetsunnyflower.com;

    index index.html index.htm index.php;
    charset utf-8;

     # 项目1
    location ^~ /project1/ {
        alias /var/www/project1/public/;
        try_files $uri $uri/ @project1;
        location ~ \.php$ {
            fastcgi_pass  unix:/run/php/php7.1-fpm.sock;
            fastcgi_index  index.php;
            #fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  SCRIPT_FILENAME  $request_filename;
            include        fastcgi_params;
        }
    }
    location @project1 {
        rewrite /project1/(.*)$ /project1/index.php?/$1 last;
    }

    # 项目2
    location ^~ /project2/ {
        alias /var/www/project2/public/;
        try_files $uri $uri/ @project2;
        location ~ \.php$ {
            fastcgi_pass   unix:/run/php/php7.1-fpm.sock;
            fastcgi_index  index.php;
            #fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  SCRIPT_FILENAME  $request_filename;
            include        fastcgi_params;
        }
    }
    location @project2 {
        rewrite /project2/(.*)$ /project2/index.php?/$1 last;
    }

    access_log /var/log/nginx/access.log;
    error_log  /var/log/nginx/error.log error;

    sendfile off;

}

  

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!