Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
419 views
in Technique[技术] by (71.8m points)

Cannot find php-fpm www.sock file on Docker with nginx and php-fpm

I am working to start the laravel app on Docker

I am having connect() to unix:/run/php-fpm/www.sock failed (2: No such file or directory) error and there is no php-fpm folder in run folder.

Why is not there a www.sock file created?

server.conf

server {
    listen      8080;
       root        /home/app/public_html/public;
       index       index.php;

       charset utf-8;
       gzip on;
    gzip_types text/css application/javascript text/javascript application/x-javascript  image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon;
    
        location / {
            try_files $uri $uri/ /index.php?$query_string;
        }
        

        location ~ .php {
                include fastcgi.conf;
                fastcgi_split_path_info ^(.+.php)(/.+)$;
                fastcgi_pass unix:/run/php-fpm/www.sock; //this crashes
        }
        location ~ /.ht {
                deny all;
        }     

}

Dockerfile

FROM centos:8

RUN dnf install nginx -y

RUN yum -y install yum-utils
RUN dnf install -y dnf-utils http://rpms.remirepo.net/enterprise/remi-release-8.rpm
RUN dnf module reset php
RUN dnf -y module enable php:remi-7.4

RUN dnf install -y php php-cli php-mysqlnd php-zip php-devel php-pdo php-gd php-mbstring php-curl php-xml php-pear php-bcmath php-json php-fileinfo php-intl
RUN yum -y install make
RUN yum -y install libmcrypt-devel
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

RUN rpm -Uvh http://www.city-fan.org/ftp/contrib/yum-repo/rhel7/x86_64/city-fan.org-release-2-1.rhel7.noarch.rpm

RUN mkdir -p /usr/local/lib/php/pecl
RUN pecl install mongodb
RUN pecl install mcrypt-1.0.4

RUN rm -v /etc/nginx/nginx.conf
ADD nginx.conf /etc/nginx/
ADD server.conf /etc/nginx/conf.d/

COPY . /home/app/public_html/
COPY mongodb.ini /etc/php.d/

RUN cd /home/app/public_html && composer update

EXPOSE 8080

CMD ["nginx", "-g", "daemon off;"]

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

In your DockerFile you need add php-fpm:

RUN dnf install -y php php-fpm php-cli php-mysqlnd php-zip php-devel php-pdo php-gd php-mbstring php-curl php-xml php-pear php-bcmath php-json php-fileinfo php-intl

Hope help you.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...