Closed adelkedjour closed 3 months ago
@adelkedjour is your container running? Using your Dockerfile
it fails to start:
AH00526: Syntax error on line 101 of /etc/httpd/conf.d/ssl.conf:
SSLCertificateFile: file '/etc/pki/tls/certs/localhost.crt' does not exist or is empty
@adelkedjour is your container running? Using your
Dockerfile
it fails to start:AH00526: Syntax error on line 101 of /etc/httpd/conf.d/ssl.conf: SSLCertificateFile: file '/etc/pki/tls/certs/localhost.crt' does not exist or is empty
I removed some code lines in the dockerfile I shared here. In the original one I do generate the certificate, and the container is up and running.
@adelkedjour If you expect to reach your container via localhost:port
from host it won't work unless you specifically publish it at runtime. 0.0.0.0
means any address but 127.0.0.1
@zcobol I have no problem reaching my container via localhost:port
from my host machine. As I mentioned, my issue is with php scripts are not working. As you see in the screenshot, html files are working fine and can reach them via localhost:port
but php throw the 503 Service Unavailable
issue. The apache syntax config is OK, digging more I found that the current default apache use php-fpm
and if I try to switch to mod_php
all the php scripts return the source code in the browser instead this due the apache php_module
missing. I believe this library is completely missing from the docker image or amazon linux 2023 packages repo.
@adelkedjour you need php-fpm
service running also.
@adelkedjour you need
php-fpm
service running also.
That's the problem, it doesn't want to start for example if I run php-fpm -F
I got:
[root@a2156192f9c8 ~]# php-fpm -F
[14-Mar-2024 19:37:58] ERROR: unable to bind listening socket for address '/run/php-fpm/www.sock': No such file or directory (2)
[14-Mar-2024 19:37:58] ERROR: FPM initialization failed
This my dockerfile:
FROM amazonlinux:2023
RUN dnf update -y && dnf upgrade -y && \
dnf install -y nc gcc-c++ ncurses make gcc make mod_ssl openssh openssl which nano libzip libzip-devel dos2unix \
httpd php8.2 php-pear php8.2-{devel,common,fpm,mbstring,gd,mysqlnd,bcmath,xml,intl,zip,sodium}
# Generate SSL certificate
RUN openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/pki/tls/private/localhost.key -out /etc/pki/tls/certs/localhost.crt -subj "/C=GB/ST=London/L=London/O=localhost/OU=localhost/CN=localhost"
WORKDIR /var/www/html
# Expose the HTTP and HTTPS ports
EXPOSE 80
EXPOSE 443
CMD ["httpd", "-D", "FOREGROUND"]
CMD ["php-fpm", "-F"]
PS: I tried the docker httpd
image worked fine, also the php:8.2-fpm
image worked fine and even noticed some difference comparing to amazonlinux:2023
so I am not sure why is not working in AL2023
? Any idea why mod_php
is not found I can't switch into it as the package doesn't exists at all in the packages repository.
Please could you try it yourself and let me know if you will be able to run it without any issues?
I tried also to create a container without any custom configuration, just I SSH into it and installed httpd
and php
didn't work tbh!
docker run -it amazonlinux:2023 /bin/bash
Regards, Adel
@elsaco @zcobol I fixed the issue by creating the /run/php-fpm/
folder manually that's why I was getting this error:
ERROR: unable to bind listening socket for address '/run/php-fpm/www.sock': No such file or directory (2)
Checking if the folder /run/php-fpm/
exists:
[root@8bca94ae883b ~]# ls -al /run/
total 56
drwxr-xr-x 1 root root 4096 Mar 14 20:03 .
drwxr-xr-x 1 root root 4096 Mar 14 20:05 ..
drwxr-xr-x 2 root root 4096 Mar 13 01:52 blkid
drwxr-xr-x 2 root root 4096 Jan 29 03:53 console
drwxr-xr-x 2 root root 4096 Jan 29 03:53 faillock
drwx--x--- 1 root apache 4096 Mar 14 20:06 httpd
drwxr-xr-x 3 root root 4096 Mar 14 20:03 lock
drwxr-xr-x 2 root root 4096 Mar 14 20:03 log
-rw-r--r-- 1 root root 0 Jan 30 2023 motd
drwxr-xr-x 2 root root 4096 Jan 30 2023 motd.d
drwxr-xr-x 2 root root 4096 Jan 29 03:53 sepermit
drwxr-xr-x 2 root root 4096 Jan 30 2023 setrans
drwxr-xr-x 9 root root 4096 Mar 14 20:03 systemd
drwxr-xr-x 2 root root 4096 Mar 14 20:03 user
Manually creating the folder /run/php-fpm/
[root@8bca94ae883b ~]# mkdir -p /run/php-fpm/
[root@8bca94ae883b ~]# ls -al /run/
total 60
drwxr-xr-x 1 root root 4096 Mar 14 20:10 .
drwxr-xr-x 1 root root 4096 Mar 14 20:05 ..
drwxr-xr-x 2 root root 4096 Mar 13 01:52 blkid
drwxr-xr-x 2 root root 4096 Jan 29 03:53 console
drwxr-xr-x 2 root root 4096 Jan 29 03:53 faillock
drwx--x--- 1 root apache 4096 Mar 14 20:06 httpd
drwxr-xr-x 3 root root 4096 Mar 14 20:03 lock
drwxr-xr-x 2 root root 4096 Mar 14 20:03 log
-rw-r--r-- 1 root root 0 Jan 30 2023 motd
drwxr-xr-x 2 root root 4096 Jan 30 2023 motd.d
drwxr-xr-x 2 root root 4096 Mar 14 20:10 php-fpm
drwxr-xr-x 2 root root 4096 Jan 29 03:53 sepermit
drwxr-xr-x 2 root root 4096 Jan 30 2023 setrans
drwxr-xr-x 9 root root 4096 Mar 14 20:03 systemd
drwxr-xr-x 2 root root 4096 Mar 14 20:03 user
Starting the PHP FPM service:
[root@8bca94ae883b ~]# php-fpm -F
[14-Mar-2024 20:10:54] NOTICE: fpm is running, pid 269
[14-Mar-2024 20:10:54] NOTICE: ready to handle connections
[14-Mar-2024 20:10:54] NOTICE: systemd monitor interval set to 10000ms
Now:
Describe the bug not able to run Apache server with PHP 8.2 using docker image
To Reproduce Steps to reproduce the behavior: Create a docker container using the
amazonlinux:2023
:Expected behavior I should be able to access to the
phpinfo.php
that I created, also if I try to switch fromphp-fpm
tophp
I can't because the apachephp_module
is not getting installed and it doesn't found at all.Screenshots
Desktop (please complete the following information):
Additional context Add any other context about the problem here.