nginx - laravel - hhvm-Fastcgi 得到错误 500

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23240375/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 09:24:22  来源:igfitidea点击:

nginx - laravel - hhvm-Fastcgi get error 500

phpnginxlaravellaravel-4hhvm

提问by Mohammad

I install a LEMP server in ubuntu 12.04 LTS 64 whit HHVM Fastcgi Service and i install laravel via laravel.phar ( and test via composer too ) when in get my site in brwoser do not display any error but in chrome developer console get error 500 enter image description here

我在 ubuntu 12.04 LTS 64 whit HHVM Fastcgi 服务中安装了一个 LEMP 服务器,我通过 laravel.phar 安装 laravel(并通过 composer 测试),当我在 brwoser 中获取我的站点时不显示任何错误,但在 chrome 开发者控制台中出现错误 500 在此处输入图片说明

i can't see any error in error.log file ( laravel - hhvm , nginx )

我在 error.log 文件中看不到任何错误(laravel - hhvm , nginx )

the storage directory Permissions is 777

存储目录权限为 777

and my nginx.conf and vhosts file have basic configuration

我的 nginx.conf 和 vhosts 文件有基本配置

when i use PHP CLI or hhvm command it's worked good

当我使用 PHP CLI 或 hhvm 命令时,它运行良好

thanks for help me :)

谢谢你的帮助:)

my location block

我的位置块

location ~ \.(hh|php)$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_keep_conn on;
fastcgi_pass   127.0.0.1:9000;
fastcgi_index  index.php;
fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
include        fastcgi_params;

回答by majidarif

The problem with HHVM is it doesn't show much error, You have to keep watching the HHVM or Laravel error logs.

HHVM 的问题是它没有显示太多错误,您必须继续观察 HHVM 或 Laravel 错误日志。

You'll want to pay close attention to your error logs. HHVM doesn't report errors to the browser by default.

您需要密切注意您的错误日志。默认情况下,HHVM 不会向浏览器报告错误。

Check the HHVM logs!

检查 HHVM 日志!

$ tail -n 50 -f /var/log/hhvm/error.log

Check your Laravel logs!

检查你的 Laravel 日志!

$ tail -n 50 -f /path/to/laravel/app/storage/logs/laravel.log


config reference

配置参考

Create a file /etc/nginx/hhvm.confif it doesn't exist yet. Insert the ff:

/etc/nginx/hhvm.conf如果文件尚不存在,则创建一个文件。插入ff:

location ~ \.(hh|php)$ {
    fastcgi_keep_conn on;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include        fastcgi_params;
}

Then include it on your nginx virtual host config.
eg. /etc/nginx/sites-available/laravel

然后将它包含在您的 nginx 虚拟主机配置中。
例如。/etc/nginx/sites-available/laravel

Now add this for Laravel, edit as needed:

现在为 Laravel 添加这个,根据需要编辑:

server {
    listen 80 default_server;

    root /vagrant/laravel/public;
    index index.html index.htm index.php;

    server_name localhost;

    access_log /var/log/nginx/localhost.laravel-access.log;
    error_log  /var/log/nginx/locahost.laravel-error.log error;

    charset utf-8;

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

    location = /favicon.ico { log_not_found off; access_log off; }
    location = /robots.txt  { log_not_found off; access_log off; }

    error_page 404 /index.php;      

    include hhvm.conf;  # INCLUDE HHVM HERE

    # Deny .htaccess file access
    location ~ /\.ht {
        deny all;
    }
}

Then reload Nginx:

然后重新加载 Nginx:

$ sudo service nginx reload

回答by hannesvdvreken

Since the X-Powered-Byheader is set by HHVM I assume your NGINX is configured correct. A 500 error mostly comes from a syntax error or an exception thrown in your application. Maybe your fastcgi settings in NGINX are still wrong. What's inside the location *\.phpblock?

由于X-Powered-By标头是由 HHVM 设置的,因此我假设您的 NGINX 配置正确。500 错误主要来自语法错误或应用程序中抛出的异常。也许你在 NGINX 中的 fastcgi 设置仍然是错误的。location *\.php方块里面有什么?

Try for a less error-prone setup and run php artisan serveto locally host your project.

尝试更不容易出错的设置并运行php artisan serve以在本地托管您的项目。

回答by Ali Haris

You can modify Laravel's handle exception class to display the errors while HHVM is being used.

您可以修改 Laravel 的句柄异常类以在使用 HHVM 时显示错误。

Full details here: https://github.com/laravel/framework/issues/8744#issue-76454458

详细信息在这里:https: //github.com/laravel/framework/issues/8744#issue-76454458

I have tested this and It works well on Laravel 5.2/5.3 on Homestead with HHVM.

我已经对此进行了测试,它在带有 HHVM 的 Homestead 上的 Laravel 5.2/5.3 上运行良好。