php - 带有 PHP-FPM 的容器 nginx 不执行 PHP 文件
问题描述
我正在尝试按照教程(http://geekyplatypus.com/dockerise-your-php-application-with-nginx-and-php7-fpm/)使用 PHP-FPM 运行 Nginx,但我在 docker 中运行的 nginx 不解释 PHP文件并返回“403”错误。
我的“site.conf”
server {
index index.php index.html;
server_name learn-wordpress.com;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /usr/share/nginx/html;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
我的“docker-compose.yml”
version: "3"
services:
web:
image: nginx:latest
ports:
- "80:80"
container_name: 'wp'
volumes:
- "./:/usr/share/nginx/html"
- ./site.conf:/etc/nginx/conf.d/site.conf
php:
image: 'php:7.4-fpm'
volumes:
- "./:/var/www/html"
我的 PHP 应用程序是 Wordpress,没有任何更改。
解决方案
推荐阅读
- mysql - 查询以显示日期范围内的数据
- javascript - 当我尝试使用 ng build --prod 构建应用程序时,它说“属性'invited_by'不存在于类型'any []'”
- android - 如何将*多种*前台服务类型分配给一项 Android 服务
- ubuntu - 在 ubuntu 18.04 中升级 GStreamer
- ionic-framework - 在 ionic 中显示搜索历史
- discord.js - 我的 discord.js 嵌入消息未发送到特定频道
- selenium - 如何获取未在 Chrome 网上商店注册的扩展程序的 CRX 文件?
- android - 包裹:去另一个活动时无法编组
- angular - 异步/等待和服务更新
- python - 如何从网站中提取链接并使用python在网络抓取中提取其内容