Answer the question
In order to leave comments, you need to log in
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
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;
}
}
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/*;
}
Answer the question
In order to leave comments, you need to log in
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 questionAsk a Question
731 491 924 answers to any question