Report this

What is the reason for this report?

PHP files are DOWNLOADING instead of EXECUTING on nginx

Posted on July 18, 2014

Hi All,

It looks like Nginx can’t pass the php file to php-fpm.sock which results in download of php files instead of execution. Please help.

I set cgi.fix_pathinfo=0 inside /etc/php5/fpm/php.ini

I set listen = /var/run/php5-fpm.sock inside /etc/php5/fpm/pool.d/www.conf

My Droplet: Ubuntu 14.04 x64\Laravel 4\nginx\PHP-FPC

All packages seem to be latest - I got everything yesterday via apt-get update/upgrade.

//////////////////Start nginx config /etc/nginx/sites-available/default////////////

server {
        listen 80 default_server;
        listen [::]:80 default_server ipv6only=on;

        root /var/www/laravel/public;
        index index.php index.html index.htm;

        server_name MY_SERVER_IP_IS_HERE;

        location / {
                try_files $uri $uri/ =404;
        }

        location ~ \.php$ {
                try_files $uri /index.php =404;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
        }
}

//////////////////End nginx config/////////////////

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.