Sign inSign up

san0123/rocky9-http-php

By san0123

•Updated 11 months ago

RockyLinux 9 || HTTPD (Apache 2.4) || PHP-FPM 7.4, 8.0, 8.1, 8.2, 8.3 8.4 (from remi-repo)

Image
Web servers
2

1.9K

san0123/rocky9-http-php repository overview

This Docker images for posting on my blog. (https://www.enteroa.com/2024/04/27/oci-arm-인스턴스에서-docker로-web-was-사용/⁠)
Purpose is share to know-how. About WEB and WAS with docker.
It's can use on developer PC(mac, Windows, etc). If you make server then you need it also (https://hub.docker.com/r/san0123/rocky9-nginx⁠)

  • Static Badge
    • Static Badge
    • Static Badge OR Static Badge OR Static Badge OR Static Badge OR Static Badge OR Static Badge

⁠HOW TO USE:

⁠Run Container(Windows): (in Windows for tasting. source from d:\project\abc.com\html)
C:\> docker run -d -p 80:80 -e TZ=Asia/Seoul --mount type=bind,source=d:\project\abc.com\html,target=/var/www/html san0123/rocky9-http-php:8.3
⁠Preparation for run on Mac/Linux
~]$ sudo groupadd -g 48 apache
~]$ sudo useradd -s /sbin/nologin -u 48 -g apache -d /usr/share/httpd -c Apache apache
~]$ sudo chown apache: /free/home/project/html
⁠Run Container(Linux/Mac):
~]$ sudo docker run --detach --restart unless-stopped \
                    --name main_site --publish 9000:80 \
                    --env TZ=Asia/Seoul \
                    --mount type=bind,source=/free/home/project/html,target=/var/www/html \
                    san0123/rocky9-http-php:8.3

Get inside the Container
~]$ sudo docker exec -it main_site bash -l
Realtime logs from Container
~]$ sudo docker logs -f main_site
Describe Important Option for Run
optionvalueDescribe
--namemain_siteSet to Container name
--restartunless-stoppedContainer is not recently stopped, it'll be start
--publish9000:80docker_proxy Host:9000 to Container:80
--envTZ=Asia/SeoulSet Container Timezone to Asia/Seoul
optionvalueHOST OSHOST volumeContainer volume
--mounttype=bind,source=/free/home/project/html,target=/var/www/htmlLinux/free/home/project/html/var/www/html
--mounttype=bind,source=d:\project\abc.com\html,target=/var/www/htmlWindowsD:\project\abc.com\html/var/www/html
Adjusted APACHE, PHP-FPM Setting
⁠Apache and PHP-FPM connecting FastCGI with PORT(:9000). coz some PC or Server are cannot run PHP-FPM with unix socket file.

/etc/php.ini was edited some like below.

short_open_tag            = On
upload_max_filesize       = 100M
post_max_size             = 120M
mysqli.allow_local_infile = On
⁠The /etc/httpd/conf/httpd.conf file contains the trusted private IPs. and .htaccess file allowed in httpd.conf file.
<Files ".ht*">
  Require all granted
</Files>
...
...
RemoteIPHeader X-Forwarded-For
RemoteIPTrustedProxy 10.0.0.0/8
RemoteIPTrustedProxy 172.16.0.0/12
RemoteIPTrustedProxy 192.168.0.0/16

If you proxy from Public-IP then should add to RemoteIPTrustedProxy [Public-IP].

⁠It's contain a Apache security setting like below on /etc/httpd/conf.d/userdir.conf
<DirectoryMatch ".*\.(git|svn)/.*">
  Require all denied
</DirectoryMatch>
<FilesMatch "\.(inc|ini|conf|cfg|properties)$">
  Require all denied
</FilesMatch>
<Files ~ "\.(env|json|config.js|md|gitignore|gitattributes|lock)$">
  Require all denied
</Files>
How to use CI4
~]$ sudo docker exec main_site composer create-project codeigniter4/appstarter html
~]$ sudo docker exec main_site chown -R apache: html
~]$ sudo docker exec main_site sed -i "s+DocumentRoot \"/var/www/html+DocumentRoot \"/var/www/html/public+g" /etc/httpd/conf/httpd.conf
~]$ sudo docker restart main_site
Set health_check as the first page of the site.

By configuring health_check as the main page, Docker can automatically restart in the event of PHP-FPM or MySQL connection failures. While this additional monitoring allows Docker to handle connection failures gracefully, frequent restarts of the website may not be desirable.

~]$ sudo docker exec -it main_site sed -i 's=health_check /var/www/health=health_check /var/www/html=g' /etc/httpd/conf/httpd.conf
~]$ sudo docker restart main_site

Tag summary

Content type

Image

Digest

sha256:74f879c73…

Size

162.9 MB

Last updated

11 months ago

docker pull san0123/rocky9-http-php:8.4