T
T
TostPOST2020-04-14 13:08:59
PHP
TostPOST, 2020-04-14 13:08:59

Why only index.php works?

I launched nginx + php7.4-fpm on the vagrant, everything seems to be fine, I did the routing, everything works, but as soon as I had to open one php file, I immediately had problems, instead of executing php, nginx just throws it to me on the page, although index.php works perfect and php is executed.
Host php section config:

location ~ \.php$ {
                #include snippets/fastcgi-php.conf;
                # With php7.0-fpm:
                fastcgi_read_timeout 300;
                fastcgi_pass unix:/run/php/php7.4-fpm.sock;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
        }

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maksim Fedorov, 2020-04-14
@TostPOST

you did not bring the entire config, most likely you have something like this:

location / {
      try_files $uri /index.php?$args;
}

It's a common practice to direct ALL requests to one entry point, and then parse it in the application.
If you have some other wishes, then add a new rule above this one, but this comes in handy very rarely
. If you need some paths, you can do something like this:
location / {
      try_files $uri @rewrite;
}

location @rewrite {
      rewrite ^/first/?$  first.php;
      rewrite ^/second/?$ second.php;

      rewrite ^ /index.php;
}

V
vreitech, 2020-04-14
@fzfx

what does he say nginx -T?
after systemctl reload nginxthe problem does not go away?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question