gpt4 book ai didi

php - nginx,在主网站子目录中安装 laravel,显示空白页面

转载 作者:可可西里 更新时间:2023-11-01 00:41:14 26 4
gpt4 key购买 nike

我正在运行 nginx。当前设置是

main_site.local(主站点)物理路径:/var/www/html/test/testme/bla/main_site/public_html

main_site.local/laravel物理路径:/var/www/html/test/testme/bla/main_site/public_html/laravel/public

基于此:Config nginx for Laravel In a subfolder

我有

server {
listen 81;
#listen [::]:81 default ipv6only=on; ## listen for ipv6

root /var/www/html/test/testme/bla/main_site/public_html;
index index.php index.html index.htm;

server_name main_site.local;

location / {
try_files $uri $uri/ /index.php?$query_string;
}


location ^~ /laravel {
alias /var/www/html/test/testme/bla/main_site/public_html/laravel/public;
try_files $uri $uri/ @laravel;

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

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


location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

当我点击 main_site.local/laravel 时,它显示一个空白页面,而不是 laravel 欢迎页面。

我在/var/www/html/test/testme/bla/main_site/public_html/laravel/public/index.php 中放入了一个骰子,它没有执行。

更新 1

基于此:https://mnshankar.wordpress.com/2014/03/19/nginx-config-for-hosting-multiple-projects-in-sibling-folders/

我有

server {
listen 81;
root /var/www/html/test/testme/igloo/igloosof/public_html;
index index.html index.htm index.php app.php app_dev.php;

server_name main-site.local;

charset utf-8;

location /laravel{
rewrite ^/laravel/(.*)$ /laravel/public/index.php?$1 last;
}

location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}

错误:RouteCollection.php 第 161 行中的 NotFoundHttpException我正在访问默认的 laravel 主页(欢迎页面)

最佳答案

如果您仍然没有解决这个问题,请尝试将 fastcgi_param SCRIPT_FILENAME 添加到第一个示例的位置->php block 中。

这是我如何设置我的 location block ,它非常适合我:

location ^~ /facebookschedule {  
alias /home/netcans/facebookschedule/public;
try_files $uri $uri/ @foobar;

location ~ \.php {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(.*)$;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME /var/wwww/facebookschedule/public/index.php;
}
}

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

我也遇到了类似的白屏(空白页)和与找不到路由相关的 404 错误,但能够按照这篇文章中的完整 Nginx Conf 文件示例修复所有内容:
http://shubhank.gaur.io/setup-laravel-5-in-subfolder-with-nginx/

关于php - nginx,在主网站子目录中安装 laravel,显示空白页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36493631/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com