如何在nginx服务器上运行php文件?
目前我正在尝试在我的nginx服务器上运行一个php文件。我下载了所有的软件包,更改了配置文件,但它仍然不工作。我可以打开index.html,但当我打开php文件时,它只会下载它。如何在nginx服务器上运行php文件?,php,nginx,server,config,Php,Nginx,Server,Config,目前我正在尝试在我的nginx服务器上运行一个php文件。我下载了所有的软件包,更改了配置文件,但它仍然不工作。我可以打开index.html,但当我打开php文件时,它只会下载它。 配置文件的我的代码: 服务器{ 监听80个默认_服务器 root /var/www/html; index index.html index.htm index.php index.nginx-debian.html; server_name test; location / { try_fil
配置文件的我的代码: 服务器{ 监听80个默认_服务器
root /var/www/html;
index index.html index.htm index.php index.nginx-debian.html;
server_name test;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
try_files $uri $uri/ =404;
include snippets/fastcgi-php.conf;
fastcgi_pass unix: /var/run/php/php8.0-fpm.sock
}
}
请帮帮我。试试我从一台工作的服务器上拉过来的这个
server {
listen 80;
root /var/www/html;
index index.php index.html index.htm;
server_name 10.0.0.19;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;
}
}
我只更改了fpm和服务器名称,因为服务器使用的是7,服务器名称是服务器的ip…我将您的设置为您的配置文件无效,可能无法应用。尝试此操作并运行
sudo nginx-t&&sudo systemctl restart nginx
server {
listen 80 default_server;
root /var/www/html;
index index.html index.htm index.php index.nginx-debian.html;
server_name test;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
try_files $uri $uri/ =404;
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;
}
}
可能是php fpm导致的问题。你有
/run/php/php8.0-fpm.sock
吗?有,我已经检查过了嗯,我不知道怎么了。谢谢你的帮助,但对我来说不起作用。你可能错过了依赖项的某些内容。可能有些文件没有加载