【问题标题】:Nginx multiple projects in one domain blank page laravelNginx 一个域中的多个项目空白页 laravel
【发布时间】:2018-01-28 15:34:54
【问题描述】:

这是我的 Nginx 配置。我有一个名为 tstdmn 的域和两个 Laravel 项目第一个 tstdmn.com 项目和第二个 florist 项目我想将 florist 项目部署到 tstdmn.com/florist,我设置了所有内容,但它在 tstdmn.com/florist 返回一个空白页面我的问题在这里?!而且我知道问题出在我的 Nginx 配置上,因为我将花店项目切换到主项目并且它可以工作,它不是来自我的 Laravel 配置

    root /var/www/html/tstdmn.com/public;

 
    # Add index.php to the list if you are using PHP
    index index.html index.php index.htm index.nginx-debian.html;

    server_name tstdmn.com www.tstdmn.com;

    location / {

            # First attempt to serve request as file, then
            # as directory, then fall back to displaying a 404.
            try_files $uri $uri/ /index.php?$query_string;
    }

    location ^~ /florist {
alias /var/www/html/florist/florist_backend/public;
try_files $uri $uri/ @laravel1;

location ~ \.php {
    fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
    fastcgi_split_path_info ^(.+\.php)(.*)$;
    include /etc/nginx/fastcgi_params;
     }
}

location @laravel1 {    
        rewrite /florist/(.*)$ /florist/index.php?/$1 last;
    }

        location ~ \.php$ {
              include snippets/fastcgi-php.conf;
              fastcgi_pass unix:/run/php/php7.1-fpm.sock;
     }

因此项目展示的另一条路径是空白,例如 /register

【问题讨论】:

  • 您是否授予了项目文件夹所需的权限?如果您使用的是 linux,请禁用 selinux
  • @Mohsen 是的,我为该文件夹提供了所有需要的权限,当我将项目直接连接到它工作的域时,我提到了

标签: php laravel ubuntu nginx


【解决方案1】:

我在 laracasts 上通过某人的解决方案解决了这个问题: 使用子域而不是路由

server { listen 80; listen [::]:80;

root /var/www/html/florist/florist_backend/public;

# Add index.php to the list if you are using PHP
index index.html index.php index.htm index.nginx-debian.html;

server_name florist.tstdmn.com;

location / {

        # First attempt to serve request as file, then
        # as directory, then fall back to displaying a 404.
        try_files $uri $uri/ /index.php?$query_string;
}

.....还有一些不相关的代码

laracast中的问题地址https://laracasts.com/discuss/channels/servers/nginx-multiple-projects-in-one-domain-errors

【讨论】:

    猜你喜欢
    • 2020-01-06
    • 1970-01-01
    • 1970-01-01
    • 2016-09-08
    • 1970-01-01
    • 2021-10-09
    • 1970-01-01
    • 2019-03-30
    • 2021-11-17
    相关资源
    最近更新 更多