今天用docker部署nginx+php环境时,访问php页面,提示404错误。查看docker日志发现下面错误:

[error] 6#6: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.248.1, server: 115.182.68.147, request: "GET /test.php HTTP/1.1", upstream: "fastcgi://172.18.0.2:9000", host: "192.168.248.129"

问题原因:
php默认监听的是本地的9000端口

解决方法:
修改php-fpm所在容器的/etc/php-fpm.d/www.conf文件
listen = 127.0.0.1:9000修改为
listen = 0.0.0.0:9000

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐