我正在尝试在Nginx上安装PHP。我的Nginx已经为Django网站配置好了。子目录/wiki
将运行php驱动的软件。
server {
server_name = my_domain_name.com;
# django stuff here
location/wiki {
alias /var/www/mediawiki;
try_files $uri =404;
index index.html index.htm index.php;
}
location ~ .php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; # i have verified that this does exist on my system
}
location ~ /.ht {
deny all;
}
# more django and certbot stuff
使用此配置,可以访问my_domain_name.com/wiki/index.html
,但my_domain_name.com/wiki/info.php
会生成404 Not Found nginx页面。然而,他们都居住在/var/www/mediawiki
。我的配置有什么问题?
根据Richard Smith的参考,我发现我需要包含一个嵌套的位置php标签:
location/wiki {
alias /var/www/mediawiki;
try_files $uri =404;
index index.html index.htm index.php;
location ~ .php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
}
}
现在提供php文件。