简体   繁体   English

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

[英]nginx - laravel - hhvm-Fastcgi get error 500

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 我在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;

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.conf if it doesn't exist yet. 如果文件尚未存在,请创建文件/etc/nginx/hhvm.conf Insert the ff: 插入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. 然后将其包含在您的nginx虚拟主机配置中。
eg. 例如。 /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

Since the X-Powered-By header is set by HHVM I assume your NGINX is configured correct. 由于X-Powered-By标头由HHVM设置,我假设您的NGINX配置正确。 A 500 error mostly comes from a syntax error or an exception thrown in your application. 500错误主要来自语法错误或应用程序中抛出的异常。 Maybe your fastcgi settings in NGINX are still wrong. 也许你在NGINX中的fastcgi设置仍然是错误的。 What's inside the location *\\.php block? location *\\.php内有什么location *\\.php块?

Try for a less error-prone setup and run php artisan serve to locally host your project. 尝试一个不易出错的设置并运行php artisan serve来本地托管您的项目。

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上运行良好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM