用docker部署nginx+php环境时,访问php页面,提示404错误。查看docker日志发现下面错误:
[error] 6#6: *1 connect() failed (111: Connection refused) while connecting to upstream, client: /test.php, server: localhost, request: "GET /test.php HTTP/1.1", upstream: "fastcgi://172.19.0.2:9000", host: "localhost"
问题原因:
php默认监听的是本地的9000端口
解决方法:
修改php-fpm所在容器的/etc/php-fpm.d/www.conf文件
把listen = 127.0.0.1:9000修改为
listen = 0.0.0.0:9000