我有一台运行 Debian 10 的服务器。我已经安装了 nginx (1.18.0) 和 php 以及 php-fpm (7.4.28)。按照本指南https://landchad.net/index我能够通过 certbot 运行获得经过认证的 html 网站。然后我想使用 php 在我的网站上动态显示菜单。当我访问网页时,它会下载而不是打开。
我的文件树如下:我的网页存储在/var/www/dragallur,有一个文件php信息.php使用以下代码(如果我输入dragallur.xyz/phpinfo.php它要求我下载网页):
<?php phpinfo(); ?>
在目录中/etc/nginx/站点可用有两个文件,默认和我的网站,默认有以下内容:
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.php index.html;
server_name _;
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
location ~ /.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;}}
以及文件mywebsite:
server {
server_name dragallur.xyz ;
root /var/www/dragallur ;
index index.php index.html index.htm index.nginx-debian.html ;
location / {
try_files $uri $uri/ =404 ;
#try_files $uri $uri/ /index.php?q=$uri&$args;
}
location ~ /.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
}
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/dragallur.xyz/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/dragallur.xyz/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot}
server {
if ($host = dragallur.xyz) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80 ;
listen [::]:80 ;
server_name dragallur.xyz ;
return 404; # managed by Certbot}
这个问题似乎经常发生在人们身上。我尝试清理缓存,对上述两个文件进行了无数次更改,但我仍然遇到同样的问题。可能还有其他关键配置文件,所以只要告诉我,我就会分享内容。每次我认为可能有用的更改之后,我都会运行命令
systemctl restart nginx