我正在尝试在我的nginx安装上安装一个新的Laravel。
我得到一个空白页面,我的错误日志显示如下:
PHP message: PHP Fatal error: require(): Failed opening required '/srv/laravel/public/../bootstrap/autoload.php' (include_path='.:/usr/share/php:/usr/share/pear') in /srv/laravel/public/index.php on line 21" while reading response header from upstream, client: **.***.***.**, server: laravel.{domain}.nl, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fcgi-laravel-php-fcgi-0.sock:", host: "laravel.{domain}.nl"
我已经检查了文件是否存在。在cli中,如果我使用
,它实际上返回1php -r "echo file_exists(__DIR__.'../bootstrap/autoload.php');"
我也检查了我的PHP版本是否是最新的。版本号为5.4.4
我还在应用程序根文件夹中运行了composer update,但无济于事。
我认为这与我的nginx设置无关,因为它加载了index.php。我没有太多使用nginx的经验,所以我可能是错的。
更新:我将在这里发布nginx配置
server {
listen *:80;
server_name laravel.{domain}.nl;
access_log /var/log/nginx/laravel.access.log;
error_log /var/log/nginx/laravel.error.log;
root /srv/laravel/public;
index index.html index.htm index.php;
# serve static files directly
location ~* '.(jpg|jpeg|gif|css|png|js|ico|html)$ {
access_log off;
expires max;
}
location / {
index index.html index.htm index.php; #try static .html file first
##try_files $uri $uri/ /index.php; <<Wrong!! this will break bundles like OneAuth for example
try_files $uri $uri/ /index.php?q=$uri&$args;
}
# catch all
error_page 404 /index.php;
location ~ [^/]'.php(/|$) {
fastcgi_index index.php;
include fcgi.conf;
fastcgi_pass unix:/var/run/php-fcgi-laravel-php-fcgi-0.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
我现在很茫然……有人能帮我吗?
如果需要的话,我会提供更多的信息。请原谅我的英语不好,谢谢。1 -你是如何安装Laravel的?
2 -你又试着转储自动加载文件了吗?如果不是:
composer dump-autoload
来源:Laravel docs
我发现open_basedir没有设置,所以我无法访问该文件夹。将open_basedir设置为%app%/public,可以正常工作
您也可以为特定的域禁用open_basedir,遵循以下步骤:
-
在ispconfig3选项卡中,单击sites选项卡2.点击基于laravel的站点的域3.现在单击options选项卡3.把"none"放在PHP的open_basedir字段
没有
4。然后在nginx指令中,设置以下命令以使url工作:
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}