在使用nginx和php-fpm的Docker上找不到php-fpmwww.sock文件



我正在Docker 上启动laravel应用程序

我有connect() to unix:/run/php-fpm/www.sock failed (2: No such file or directory)错误,运行文件夹中没有php-fpm文件夹。

为什么没有创建www.sock文件?

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

在DockerFile中,您需要添加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

希望能帮助你。

最新更新