doumingchen3628 2015-05-20 09:34
浏览 83


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).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?



  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序