Reputation: 111
I have developed a Laravel app using PDT in Eclipse. Everything runs perfectly on my development machine. I have deployed to a Centos 7 server running PHP 7.1, PHP-FPM in socket mode and NGINX and all I get is a blank white screen. If I set up another virtual NGINX site with just a phpinfo() script then it works so I know that PHP is working fine.
I have researched all the answers I can find and have tried all the usual things relating to permissions on the storage directories and bootstrap/cache directory etc.
Nothing is written to the storage/logs directory and there are no errors in the NGINX logs or the PHP-FPM logs. Without any indication of what is happening, I am now lost as to how to proceed to find the source of the error
If I start a server using:
php artisan serve
then the application runs without any issues!
What other debug/trace methods can I use to find the source of the problem?
Thanks
Upvotes: 2
Views: 2716
Reputation: 111
For anyone who stumbles on this question in the future, I have finally solved my issue after a lot of head scratching.
The issue was with my NGINX configuration for the virtual host. I used the sample configuration (adjusted to my local config) that is given in the Laravel Deployment guide. The section relating to PHP files is shown as:
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
I decided to try installing a basic installation following a tutorial I found on howtoforge. This worked perfectly and the only difference I could see between that process and what I had for my virtual host was the section relating to PHP files. Once I changed the virtual host to match the tutorial my application worked immediately. The updated section is:
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
The only difference between these two configs is the addition of the line:
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
This makes ALL the difference
Looking at the NGINX site I found this note on the PHP Fast CGI page (My server is CentOS 7:
The SCRIPT_FILENAME parameter is required as it is passed to PHP FPM to determine the script name.
In the builds of NGINX for a lot of Linux distributions, this parameter has been added in fastcgi_params file, i.e. /etc/nginx/fastcgi_params so the users could import all the CGI params via the include directive, i.e. include fastcgi_params . But for some distributions, such as CentOS, this parameter does not exist in fastcgi_params file.
If this parameter is not set, PHP FPM responses 200 OK with empty content, and there is no error or warning. For more informaton about the CGI params, please refer to nginx beginners guide, $_SERVER in PHP and RFC3875.
Hope this helps someone else in the future.
Upvotes: 9