nginx - laravel - hhvm-Fastcgi get error 500

2019-04-30 00:14发布

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

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;

3条回答
Luminary・发光体
2楼-- · 2019-04-30 00:53

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
查看更多
beautiful°
3楼-- · 2019-04-30 00:58

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.

查看更多
We Are One
4楼-- · 2019-04-30 01:08

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.

查看更多
登录 后发表回答