@great_77

Под docker нет файла /var/run/php/php7.4.1-fpm.sock, где его искать?

Разворачиваю проект под docker, взял стандартный конфиг nginx сайта Symfony. Но под докер в папке run нет файла /var/run/php/php7.4.1-fpm.sock(Заходил в контейнер php-fpm)
Подскажите в чем причина?

error.log
[crit] 6#6: *8 connect() to unix:/var/run/php/php7.4.1-fpm.sock failed

docker-compose.yml
version: '3'
services:

  nginx:
    image: nginx
    ports:
      - "8090:80"
    links:
      - php-fpm
    volumes:
      - "./nginx/default.conf:/etc/nginx/conf.d/default.conf"
      - ./symfonyproject:/var/www/html
      #- ./nginx/default:/etc/nginx/sites-availible/default
      #- ./nginx/default:/etc/nginx/sites-enabled/default
      #- ./nginx/default:/etc/nginx/conf.d/nginx.conf
      #- ./nginx/default:/etc/nginx/conf.d/nginx.conf

      - ./logs/access.log:/var/log/nginx/access.log
      - ./logs/error.log:/var/log/nginx/error.log

  db:
    image: postgres:12.1
    ports:
      - 5432:5432
    restart: always
    volumes:
      - ${DB_PATH_HOST}:/data/postgresql
    environment:
      POSTGRES_USER: ${DB_USER}
      POSTGRES_PASSWORD: ${DB_PASSWORD}

  php-fpm:
    build: ./php-fpm
    ports:
      - "9000:9000"
    volumes:
      - ./symfonyproject:/var/www/html
      - ./xdebug/xdebug.ini:/usr/local/etc/php/conf.d/xdebug.ini
    depends_on:
      - db

  adminer:
    image: adminer
    restart: always
    ports:
      - 6080:8080


php-fpm/Dockerfile
FROM php:7.4-fpm

RUN apt-get update \
        && apt-get install -y \
        git \
        curl \
        wget \
        libfreetype6-dev \
        libjpeg62-turbo-dev \
        libpq-dev \
        libzip-dev \
        zip

RUN pecl install xdebug \
    && docker-php-ext-enable xdebug \
    && docker-php-ext-install zip

 
RUN docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \
    && docker-php-ext-install pgsql pdo_pgsql

CMD ["php-fpm"]

WORKDIR "/var/www/html"

# Install composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer


RUN groupadd -g 1000 www
RUN useradd -u 1000 -ms /bin/bash -g www www


nginx/default.conf
server {
    server_name symfony.local;
    root /var/www/html;

    location / {
        # try to serve file directly, fallback to index.php
        try_files $uri /index.php$is_args$args;
    }

    # optionally disable falling back to PHP script for the asset directories;
    # nginx will return a 404 error when files are not found instead of passing the
    # request to Symfony (improves performance but Symfony's 404 page is not displayed)
    # location /bundles {
    #     try_files $uri =404;
    # }

    location ~ ^/index\.php(/|$) {
        fastcgi_pass unix:/var/run/php/php7.4.1-fpm.sock;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;

        # optionally set the value of the environment variables used in the application
        # fastcgi_param APP_ENV prod;
        # fastcgi_param APP_SECRET <app-secret-id>;
        # fastcgi_param DATABASE_URL "mysql://db_user:db_pass@host:3306/db_name";

        # When you are using symlinks to link the document root to the
        # current version of your application, you should pass the real
        # application path instead of the path to the symlink to PHP
        # FPM.
        # Otherwise, PHP's OPcache may not properly detect changes to
        # your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126
        # for more information).
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        fastcgi_param DOCUMENT_ROOT $realpath_root;
        # Prevents URIs that include the front controller. This will 404:
        # http://domain.tld/index.php/some-path
        # Remove the internal directive to allow URIs like this
        internal;
    }

    # return 404 for all other php files not matching the front controller
    # this prevents access to other php files you don't want to be accessible.
    location ~ \.php$ {
        return 404;
    }

    error_log /var/log/nginx/error.log;
    access_log /var/log/nginx/access.log;
}
  • Вопрос задан
  • 1527 просмотров
Решения вопроса 1
@great_77 Автор вопроса
fastcgi_pass php-fpm:9000;
server {
server_name symfony.local;
root /var/www/html/public;

location / {
try_files $uri @rewriteapp;
}

location @rewriteapp {
rewrite ^(.*)$ /index.php/$1 last;
}

location ~ ^/index\.php(/|$) {
fastcgi_pass php-fpm:9000;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param HTTPS off;
}

error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
}
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы