我无法正确配置PHP-fpm的Nginx.当我得到任何PHP脚本时,我在浏览器中收到Nginx 404 Not found错误:
File not found.
在我的PHP-fpm日志中,我得到:
172.17.42.1 - 28/Apr/2015:09:15:15 +0000 "GET /index.PHP" 404
[error] 28105#0: *1 FastCGI sent in stderr: "Primary script unkNown" while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "GET /index.PHP HTTP/1.1", upstream: "fastcgi://127.168.66.66:9000", host: "localhost"
我的Nginx vitualhost配置是:
server {
listen 80;
root /var/www/html;
index index.html;
server_name localhost;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
location ~* \.PHP${
fastcgi_index index.PHP;
fastcgi_pass 127.168.66.66:9000;
#fastcgi_pass unix:/var/run/PHP5-fpm.sock;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
}
}
我从official php repository开始运行PHP-fpm Docker镜像,运行方式为:
docker run -it -p 127.168.66.66:9000:9000 PHP:fpm
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
dbf9f7d1c6f9 PHP:fpm "PHP-fpm" 8 seconds ago Up 7 seconds 127.168.66.66:9000->9000/tcp serene_curie
我的配置有什么问题?
附:任何静态文件(css,js,images)都适用于Nginx.
解决方法:
此外,还需要共享文件到PHP:fpm docker容器.答案是运行docker PHP:fpm image with volume too:
docker run -it -p 127.168.66.66:9000:9000 -v /var/www/html/:/var/www/html/ PHP:fpm
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。