W
W
WhiteApfel2018-11-05 18:31:25
PHP
WhiteApfel, 2018-11-05 18:31:25

Why is php not working when issuing index.php via try_files $uri/index.php?

There is a server that I used for about a year only for the sake of a proxy.
Then I wanted to learn how to write something simple in PHP and ran into a problem
When requesting site.com , index.php is issued, which lies at the root (classic). But the problem is that the php script is not processed. If we turn to site.com/index.php, then php is processed normally. It seems that the nginx settings were set correctly, but something didn’t work ...
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, I didn’t touch the settings there. I
looked for it on Google, but either I didn’t search it correctly, or there’s nothing like it in Google (rather the first one)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
WhiteApfel, 2018-11-09
@WhiteApfel

In location / {...}you need to write:

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

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question