PrestaShop / docker

🐳
https://hub.docker.com/r/prestashop/prestashop/
MIT License
257 stars 176 forks source link

NPM + Nginx 1.24 + PS 8.1.2 php 8.1 fpm #358

Closed elclay7 closed 6 months ago

elclay7 commented 7 months ago

I'm trying PrestaShop 8.1-fpm but I'm having problems configuring Nginx. I don't know what I should configure to communicate with fpm. This is docker compose:

version: "3.6"
services:

  dev-app-ps81:
    image: prestashop/prestashop:8.1.2-8.1-fpm
    container_name: dev-app-ps81
    restart: unless-stopped
    environment:
      - DB_SERVER=dev-db-ps81
      - DB_USER=devuser
      - DB_PASSWD=devpass
      - DB_PREFIX=dev_
      - DB_NAME=devdb
      - PS_INSTALL_AUTO=1
      - PS_DOMAIN=somedomain.com
      - PS_LANGUAGE=es
      - PS_COUNTRY=cl
      - PS_FOLDER_ADMIN=WsEWs
      - PS_FOLDER_INSTALL=installXsXs
      - PS_ENABLE_SSL=1
      - ADMIN_MAIL=someemail@gmail.com
      - ADMIN_PASSWD=somepass
      - TZ=America/Santiago
    expose:
      - 80
      - 9000
    volumes:
      - /storage05/devps8.1/app/html:/var/www/html

  dev-db-ps81:
    image: mariadb:10.5.8
    container_name: dev-db-ps81
    restart: unless-stopped
    environment:
      - MYSQL_ROOT_PASSWORD=devpassroot
      - MYSQL_DATABASE=devdb
      - MYSQL_USER=devuser
      - MYSQL_PASSWORD=devpass
      - MYSQL_ALLOW_EMPTY_PASSWORD=no
      - TZ=America/Santiago
    expose:
      - 3306
    volumes:
      - /storage05/devps8.1/db/data:/var/lib/mysql

  dev-ngnix-ps81:
    image: nginx:stable-bullseye
    container_name: dev-ngnix-ps81
    restart: unless-stopped
    environment:
      - TZ=America/Santiago
    ports:
      - 8094:80
    volumes:
      - /storage05/devps8.1/app/html:/var/www/html
      - /storage05/devps8.1/nginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf:ro
    networks:
      - npm_default
      - dev-ps81_default

networks:
  npm_default:
    name: npm_default
  dev-ps81_default:
    name: dev-ps81_default

Nginx container: dev-ngnix-ps81 etc/nginx/conf.d/default.conf

server {
    listen       80;
    listen  [::]:80;
    server_name  localhost;

    location / {
        root   /var/www/html;
        index index.html index.htm index.php;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    location ~ \.php$ {
        root           /var/www/html;
        fastcgi_pass   dev-app-ps81:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        include        fastcgi_params;
    }

}

Test access a test.php file from the nginx container dev-ngnix-ps81 test.php file permissions: -rwxrwxrwx 1 www-data www-data 33 Dec 13 10:18 /var/www/html/test.php The file is visible from the nginx container

root@84a514ad54c7:/# php /var/www/html/test.php 
bash: php: command not found

Is it necessary to have php installed in the nginx container?

I try to enter the site url https://somedomain.com/test.php

Nginx container log dev-ngnix-ps81: 172.24.0.1 - - [13/Dec/2023:11:41:08 -0300] "GET /test.php HTTP/1.1" 404 27 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36" "10.0.0.145"

Prestashop container log dev-app-ps81: 172.24.0.4 - 13/Dec/2023:11:41:08 -0300 "GET /test.php" 404

What am I failing? Do I need to have php or php-fpm installed in the nginx container or am I just missing some configuration in the nginx If someone could please guide or help me it would be incredible.

elclay7 commented 5 months ago

Solved here #367