I made a Dockerfile, but when I run it and get into the container, thephp8.0-fpm service is not running.
How to make it run at build time? Note that I ran the commandservice php8.0-fpm start
in the Dockerfile, but even then it didn't run.
How to make the php8.0-fpm service start with the container?
The following is the Dockerfile I made:
FROM ubuntu:jammy ENV DEBIAN_FRONTEND=noninteractive # Instalação Apache e PHP RUN apt-get update && apt-get install software-properties-common -y && add-apt-repository ppa:ondrej/php -y && apt-get update && apt-get install -y apache2 libapache2-mod-php8.0 libapache2-mod-php php8.0-fpm libapache2-mod-fcgid # Alteração sequência index COPY /src/dir.conf /etc/apache2/mods-enabled # Commitando a nova configuração RUN service apache2 restart RUN service php8.0-fpm restart # Inserindo página info.php COPY /src/info.php /var/www/html # Alterando módulos de multiprocessamento RUN service apache2 stop && a2dismod php8.0 && a2dismod php8.1 && a2dismod mpm_prefork && a2enmod mpm_event && a2enconf php8.0-fpm && a2enmod proxy && a2enmod proxy_fcgi && service apache2 restart && service php8.0-fpm start # Entrypoint para o conteiner iniciar o Apache ENTRYPOINT ["apache2ctl", "-D", "FOREGROUND"]```
You need to run php fpm on startup. You can do this if bash is installed in your virtual machine operating system.
Stop signal SIGTERM
CMD ["/bin/bash", "-c", "php-fpm8 && include your apache here"]
Complete Guide:How to set up PHP 8, NGINX and PHP-FPM using docker
I managed to keep it in a container, PHP has an extension called Supervisor and after installation we were able to start two or more services inside the container.
Dockerfile looks like this:
I created two configuration files for Supervisor.
apache.conf
fpm.conf
At this point, the two services are started and running perfectly!