doumingchen3628 2015-05-20 09:34
浏览 83
已采纳

php-fpm错误“没有指定输入文件”与Docker

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
WORKDIR /tmp
RUN yum -y update

RUN rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm; rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

#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"]

EXPOSE 9000

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

Check by docker ps

aab4f8ce0fe8        jason/fpm:v1        "/usr/sbin/php-fpm -   6 minutes ago       Up 6 minutes        0.0.0.0:9002->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": "0.0.0.0",
                    "HostPort": "9002"
                }
            ]
        }

localhost nginx website config:

listen 80;
server_name admin.local.lumen.com;
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_pass   127.0.0.1:9002;
        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: 172.16.1.19, server: admin.local.lumen.com, request: "GET /favicon.ico HTTP/1.1", upstream: "fastcgi://127.0.0.1:9002", host: "admin.local.lumen.com"

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 C++数组中找第二小的数字程序纠错
  • ¥50 MATLAB APP 制作出现问题
  • ¥15 wannier复现图像时berry曲率极值点与高对称点严重偏移
  • ¥15 利用决策森林为什么会出现这样·的问题(关键词-情感分析)
  • ¥15 DispatcherServlet.noHandlerFound No mapping found for HTTP request with URI[/untitled30_war_e
  • ¥15 使用deepspeed训练,发现想要训练的参数没有梯度
  • ¥15 寻找一块做为智能割草机的驱动板(标签-stm32|关键词-m3)
  • ¥15 信息管理系统的查找和排序
  • ¥15 基于STM32,电机驱动模块为L298N,四路运放电磁传感器,三轮智能小车电磁组电磁循迹(两个电机,一个万向轮),怎么用读取的电磁传感器信号表示小车所在的位置
  • ¥15 如何解决y_true和y_predict数据类型不匹配的问题(相关搜索:机器学习)