Noob Noob - 1 year ago 174
PHP Question

ZF3 Nginx Serve index.php As Download File

I installed debian 8 with nginx and php 7 for creating an endpoint with zendframework. When i follow the website i have to add these to my virtual host config in nginx. Like i did see the code below:

server {
listen 80;
listen [::]:80;

root /var/www/endpoint/html/public;

server_name my_ip;

location / {
index index.php
try_files $uri $uri/ @php;

location @php {
# Pass the PHP requests to FastCGI server (php-fpm) on
fastcgi_param SCRIPT_FILENAME /var/www/endpoint/html/public/index.php;
include fastcgi_params;

But when i visit the website its downloading the index.php instead of executing the index.php.

I hope anyone can help me resolving this issue.

Answer Source

I think you need to replace the fastcgi_pass value with socket path instead of server address and port.

fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;

Then restart your php7-fpm by type this command

sudo systemctl restart php7-fpm
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download