nginx - laravel - hhvm-Fastcgi get error 500

霸气de小男生 提交于 2019-12-07 05:17:41

问题


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

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

the storage directory Permissions is 777

and my nginx.conf and vhosts file have basic configuration

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

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;

回答1:


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

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

Check the HHVM logs!

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

Check your Laravel logs!

$ 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. Insert the 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

Now add this for Laravel, edit as needed:

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:

$ sudo service nginx reload



回答2:


Since the X-Powered-By header 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 *\.php block?

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




回答3:


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

Full details here: 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.



来源:https://stackoverflow.com/questions/23240375/nginx-laravel-hhvm-fastcgi-get-error-500

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!