Y
Y
Yuri Velmesov2019-05-25 20:01:38
PHP
Yuri Velmesov, 2019-05-25 20:01:38

Why are .php files not being processed in the Nginx + PHP-FPM bundle?

Please tell me what could be the problem.
Ubuntu Server 18.04
Installed Nginx 1.14 and PHP 7.2 FPM
.html files open fine and when accessing .php just a blank page, no error.
The logs are empty, only access logs.
Host config

Host config

server {
  listen      80;
    listen      [::]:80;
  server_name site.ru www.site.ru;

    root        /var/www/site.ru;
    index       index.php index.html;
    charset     utf-8;

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

    location ~ \.php$ {
        fastcgi_pass  unix:/run/php/php7.2-fpm.sock;
        fastcgi_index index.php;
        include       fastcgi_params;
    }
}


php.ini standard
Changed only this
cgi.fix_pathinfo=0 (was 1)
nginx.conf config
nginx.conf config

user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
  worker_connections 768;
  # multi_accept on;
}

http {
  sendfile on;
  tcp_nopush on;
  tcp_nodelay on;
  keepalive_timeout 65;
  types_hash_max_size 2048;

  server_names_hash_bucket_size 64;

  include /etc/nginx/mime.types;
  default_type application/octet-stream;

  ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
  ssl_prefer_server_ciphers on;

  access_log /var/log/nginx/access.log;
  error_log /var/log/nginx/error.log;

  gzip on;

  include /etc/nginx/conf.d/*.conf;
  include /etc/nginx/sites-enabled/*;
}


I did not touch it either, standard.
The www.conf config is also standard
. In the site directory, all folders and files were owned by www-data, before that it was root
. What could be the problem that I did not configure?
Naturally, every time I changed the configs, I rebooted both nginx and php-fpm
systemctl restart nginx && systemctl restart php7.2-fpm

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Gennick's Macleo, 2019-05-25
@yury-gubsky

Try this conf:

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

location ~ [^/]\.php(/|$) {
        fastcgi_split_path_info ^(.+?\.php)(/.*)$;
        if (!-f $document_root$fastcgi_script_name) {return 404;}
        fastcgi_param HTTP_PROXY "";
        include fastcgi_params;
        fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $request_filename;
    }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question