2015-05-20 09:34
浏览 82


I am trying to setup a docker container for php-fpm. But encountering this error when visiting the web directory configured on localhost. I have been stuck here for over 5 hours. Here is my Dockerfile:

FROM centos:latest
RUN yum -y update

RUN rpm -Uvh; rpm -Uvh

#RUN yum -y groupinstall "Development Tools"
RUN systemctl stop firewalld; systemctl disable firewalld

RUN yum -y install php56w php56w-opcache php56w-cli php56w-common php56w-devel php56w-fpm php56w-gd  php56w-mbstring  php56w-mcrypt php56w-pdo php56w-mysqlnd php56w-pecl-xdebug php56w-pecl-memcache

RUN sed -i "s/;date.timezone =.*/date.timezone = UTC/" /etc/php.ini && \
    sed -i "s/display_errors = Off/display_errors = stderr/" /etc/php.ini && \
    sed -i "s/upload_max_filesize = 2M/upload_max_filesize = 30M/" /etc/php.ini && \
    sed -i -e "s/;daemonize\s*=\s*yes/daemonize = no/g" /etc/php-fpm.conf && \
    sed -i '/^listen = /c listen = 9000' /etc/php-fpm.d/www.conf && \
    sed -i '/^listen.allowed_clients/c ;listen.allowed_clients =' /etc/php-fpm.d/www.conf

RUN mkdir -p /home/www
VOLUME ["/home/www"]


ENTRYPOINT ["/usr/sbin/php-fpm", "-F"]

Check by docker ps

aab4f8ce0fe8        jason/fpm:v1        "/usr/sbin/php-fpm -   6 minutes ago       Up 6 minutes>9000/tcp   fpm

The data volume does exist. check by docker inspect

"Volumes": {
        "/home/www": "/home/www"
    "VolumesRW": {
        "/home/www": true
"Ports": {
            "9000/tcp": [
                    "HostIp": "",
                    "HostPort": "9002"

localhost nginx website config:

listen 80;
index index.php index.html index.htm ;
root  /home/www/lumenback/public_admin;
error_log /home/wwwlogs/lumenback_error.log;
location / {
        try_files $uri $uri/ /index.php?$query_string;
location ~ .*\.php?$
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include fastcgi_params;
        #include        fastcgi.conf;

Error logged by php-fpm:

[error] 5322#0: *3798 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client:, server:, request: "GET /favicon.ico HTTP/1.1", upstream: "fastcgi://", host: ""

Many people online said the error is caused by fastcgi_param SCRIPT_FILENAME. Seems it is not the reason in my case.

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

  • dtcuv8044 2015-05-21 02:29

    You may have got an incorrect file permission -- the process in the container cannot read php files. You can either change the php files readable by the user running php-fpm in the container. Note that the user name in the container differs from the names on the host, so specifying user ID is probably a better way (or simply make them world readable).

    解决 无用
    打赏 举报

相关推荐 更多相似问题