在我的网站 "craff.ddns.net"(还没有上线247)上,我还没有安装php到nginx,因为我不确定是否需要,当我访问我的网站时,它只是下载 "index.php"。我已经问过我的一个比我更懂网站服务器的朋友,他说我应该把index设置成 "index.php",但我已经设置了,还没有用。然后他问我有没有安装php,我没有安装。如果我没有安装php到nginx,它会自动开始下载 "index.php "吗?我是否需要安装php,或者还有其他需要安装的东西?
另外,我的nginx上还没有安装任何东西,而且我在Windows上运行nginx。
Nginx需要一个程序来处理php文件。你需要安装php-fpm包。这里是一个例子,你需要从官方文档中输入服务器块的位置。
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
# Mitigate https://httpoxy.org/ vulnerabilities
fastcgi_param HTTP_PROXY "";
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
# include the fastcgi_param setting
include fastcgi_params;
# SCRIPT_FILENAME parameter is used for PHP FPM determining
# the script name. If it is not set in fastcgi_params file,
# i.e. /etc/nginx/fastcgi_params or in the parent contexts,
# please comment off following line:
# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}