~r1w1s1/dockerfiles

5a78ec0e121c16f2e953a6d14b71cb0ae1a661c2 — r1w1s1 1 year, 1 month ago 9b1eef0
apache+php container
3 files changed, 73 insertions(+), 0 deletions(-)

A httpd-php80/Dockerfile
A httpd-php80/httpd-foreground
A httpd-php80/index.php
A httpd-php80/Dockerfile => httpd-php80/Dockerfile +43 -0
@@ 0,0 1,43 @@
# AUTHOR:        https://github.com/r1w1s1
# COMMENTS:
#    Apache 2.4 with PHP8 based on Almalinux 9
#
# USAGE:
#    # Download Dockerfile
#    wget https://raw.githubusercontent.com/r1w1s1/dockerfiles/master/httpd-php80/Dockerfile
#
#    # Build image
#    docker build -t httpd-php80 .
#
#    # Run the image
#    docker run -p 80:80 -d httpd-php80 
#
#
FROM almalinux:9

COPY httpd-foreground /usr/local/bin/

RUN \
    dnf -y update \
    && dnf -y install \
    php \
    php-mysqlnd \
    mod_ssl \
    procps-ng \
    && mkdir /run/php-fpm \
    && chmod +x /usr/local/bin/httpd-foreground \
    && /usr/libexec/httpd-ssl-gencerts \
    && chmod 644 /etc/pki/tls/private/localhost.key \
    && sed -ri 's/#ServerName www.example.com:80/ServerName localhost:80/g' /etc/httpd/conf/httpd.conf \
    && sed -ri 's/AllowOverride None/AllowOverride All/g' /etc/httpd/conf/httpd.conf \
    && sed -ri -e 's!^(\s*CustomLog)\s+\S+!\1 /proc/self/fd/1!g' \
	       -e 's!^(\s*ErrorLog)\s+\S+!\1 /proc/self/fd/2!g' \
	       /etc/httpd/conf/httpd.conf
            
COPY index.php /var/www/html

WORKDIR /var/www/html

EXPOSE 80

CMD ["httpd-foreground"]

A httpd-php80/httpd-foreground => httpd-php80/httpd-foreground +8 -0
@@ 0,0 1,8 @@
#!/bin/sh
set -e

##Start php-fpm
exec /usr/sbin/php-fpm & 

##Start apache 2.4
exec httpd -DFOREGROUND "$@"

A httpd-php80/index.php => httpd-php80/index.php +22 -0
@@ 0,0 1,22 @@
<!DOCTYPE html>
<html>
<head>
<title>Apache with PHP Support - Almalinux 9</title>
<style>
    body {
        text-align: center;
        font-family: Tahoma, Geneva, Verdana, sans-serif;
    }
</style>
</head>
<body>
<h1>Apache with PHP Support.</h1>
<p>If you see PHP info below, Apache with PHP container works.</p>

<?php 

   phpinfo()
   
?>
</body>
</html>