当我输入 PHP 文件时,它们会永久加载。但不会显示在浏览器中。几分钟后,浏览器就会超时。
Html 文件可以正确显示/呈现。
这是我的虚拟主机:
server {
listen 80;
server_name localhost;
root /var/www/site;
index index.php index.html;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
以下是 www.conf 中最重要的内容:
listen = /var/run/php/php7.2-fpm.sock
user = www-data
group = www-data
在 php.ini 中我有:
cgi.fix_pathinfo=0
当然,我重启了 php 和 nginx。我不知道问题出在哪里
版本:
nginx version: nginx/1.18.0 (Ubuntu)
PHP 7.2.34-36+ubuntu20.04.1+deb.sury.org+1 (cli) (built: Oct 28 2022 18:25:54) ( NTS )
有人可以帮忙吗?
评论中要求的其他数据:
nginx:conf
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
#upstream php {
#this should match value of "listen" directive in php-fpm pool
# server unix:var/run/php-fpm.so;
# server 127.0.0.1:9000;
# }
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
fastcgi.conf
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REQUEST_SCHEME $scheme;
fastcgi_param HTTPS $https if_not_empty;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
ls -la ../sites-available/
total 12
drwxr-xr-x 2 root root 4096 lis 30 22:02 .
drwxr-xr-x 8 root root 4096 lis 30 22:39 ..
-rw-r--r-- 1 root root 552 lis 30 22:02 site
ls -la ../sites-enabled/
total 8
drwxr-xr-x 2 root root 4096 lis 30 20:10 .
drwxr-xr-x 8 root root 4096 lis 30 22:39 ..
lrwxrwxrwx 1 root root 28 lis 30 18:17 site -> ../sites-available/site