docker中執行lnmp環境介面502,nginx錯誤日誌提示/run/php/php7.0-fpm.sock failed
阿新 • • 發佈:2018-12-26
docker中中執行lnmp開發環境,介面報502錯誤進入docker
docker exec -it createID bash
tailf /var/log/nginx/error.log
錯誤資訊:
2017/06/26 14:45:14 [crit] 11#11: *21 connect() to unix:/run/php/php7.0-fpm.sock failed (2: No such file or directory) while connecting to upstream, client: 172.19.0.1, server: 127.0.0.1, request: "GET /user/index HTTP/1.1" , upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "127.0.0.1"
提示是找不到/run/php/php7.0-fpm.sock檔案,進入/run, 發現只有/run/php7.0-fpm.sock。將docker的nginx配置檔案中的fastcgi_pass配置改成/run/php7.0-fpm.sock,重啟docker即可
location ~ \.php$ {
include snippets/fastcgi-php.conf;
# With php7.0-cgi alone:
#fastcgi_pass 127.0.0.1:9000;
# With php7.0-fpm:
fastcgi_pass unix:/run/php7.0-fpm.sock;
}