There is a server that I used for about a proxy for about a year. Then I wanted to learn how to write something simple in PHP and ran into a problem.

When you request site.com issued index.php, lying in the root (classic). But the problem is that the php script is not processed. If you go to site.com/index.php, then php is processed normally. It seems that the settings nginx set correctly, but something in any way ...

Server config:

location / { autoindex off; try_files $uri/index.php $uri/index.html =404; } location ~ \.php$ { try_files $uri $uri/index.php =404; include /etc/nginx/fastcgi.conf; fastcgi_pass unix:/run/php/php7.0-fpm.sock; } 

PHP 7.0, there settings, like, did not touch

I searched for Google, but I’ve either searched for it incorrectly, or there’s no such thing in Google (most likely the first)

Solution: Added

  include /etc/nginx/fastcgi.conf; fastcgi_pass unix:/run/php/php7.0-fpm.sock; 

in location / {...}. Now everything is working properly!

    1 answer 1

    When accessing site.com, nginx uses location / , and for it, you have not declared fastcgi_pass .