Hello. I bought a HP t630 and wanted to learn some ubuntuServer+Docker. My file structure looks like this:


/home/bg/docker_stacks (main folder)
/home/bg/docker_stacks/prod_php-maria-apache (this project folder)
/home/bg/docker_stacks/prod_php-maria-apache/docker-compose.yml

/home/bg/docker_stacks/prod_php-maria-apache/apache/

/home/bg/docker_stacks/prod_php-maria-apache/html/
/home/bg/docker_stacks/prod_php-maria-apache/html/test.php

/home/bg/docker_stacks/prod_php-maria-apache/php/
/home/bg/docker_stacks/prod_php-maria-apache/php/php.ini empty

inside test.php there’s


inside docker-compose.yml there’s:

GNU nano 6.2                                                                                                                                                                                       docker-compose.yml                                                                                                                                                                                                 
 web:
   image: php:8.2-cli
   ports:
     - '80:80'
   volumes:
     - /home/bg/docker_stacks/prod_maria-php-apache/apache:/etc/apache2/sites-enabled
     - /home/bg/docker_stacks/prod_maria-php-apache/html:/var/www/html
     - /home/bg/docker_stacks/prod_maria-php-apache/php/php.ini:/usr/local/etc/php/php.ini
   depends_on:
     - mariadb
   extra_hosts:
     - 'ax710.test:127.0.0.1'
     # - 'some-other-host.test:127.0.0.1'
   networks:
     - dev-env
 phpmyadmin:
   image: phpmyadmin:latest
   ports:
     - 8080:80
   environment:
     - PMA_ARBITRARY=1
     - PMA_HOST=mariadb
   depends_on:
     - mariadb
   volumes:
     - /home/bg/docker_stacks/prod_maria-php-apache/php/php.ini:/usr/local/etc/php/php.ini
   networks:
     - dev-env
 mariadb:
   image: mariadb:latest
   restart: always
   environment:
     MYSQL_ROOT_PASSWORD: '123'
     MYSQL_USER: 'bg'
     MYSQL_PASSWORD: '123'
     MYSQL_DATABASE: 'db'
   volumes:
     - mysqldata:/var/lib/mysql
   ports:
     - 3306:3306
   networks:
     - dev-env

volumes:
 mysqldata: {}

networks:
 dev-env: {}

When on my laptop I open:

192.168.1.208:9090 - cockpit works fine

192.168.1.208:8080 - phpMyAdmin works fine

heidiSQL - at 192.168.1.208 opens the database without problems

192.168.1.208:80/test.php or 192.168.1.208/test.php does not work

Any ideas how can I make test.php open in my browser? Any other suggestions are appreciated as I’am newbie in Docker.

    • feecoomeeq@lemmy.worldOP
      link
      fedilink
      English
      arrow-up
      1
      ·
      1 year ago

      while having web: image: php:8.2-cli I was getting prod_maria-php-apache-web-1 exited with code 0 but after changing it to web: image: php:8.2-fpm it’s not giving errors anymore. Still haven’t found the solution for the test.php being not accessible

    • feecoomeeq@lemmy.worldOP
      link
      fedilink
      English
      arrow-up
      1
      ·
      edit-2
      1 year ago

      sadly it did not help, http://192.168.1.208:8081/test.php is unreachable by the browser.

      also after making changes to the .yml I cannot restart the containers with sudo docker compose restart. Web container restarts ok, but two of them give me “permission denied”.

      How about if I dont need phpMyAdmin (I’ll access the database through heidiSQL, but I want of course the php to work), can I change the container to be php-fpm? Or maybe changing the config to use nginx?

  • feecoomeeq@lemmy.worldOP
    link
    fedilink
    English
    arrow-up
    2
    ·
    1 year ago

    SOLVED After watching videos about ngnix, I thought - ok, I have mariadb, phpMyAdmin to manage the DB and “web” with PHP, but where’s the apache actually or ngnix in this config to handle the traffic? I added image: php:8.2-apache instead of image: php:8.2-cli and voila - hello world in browser.