简体   繁体   中英

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM