RockyLinux 9 || HTTPD (Apache 2.4) || PHP-FPM 7.4, 8.0, 8.1, 8.2, 8.3 8.4 (from remi-repo)
1.9K
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)
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
~]$ 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
~]$ 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
~]$ sudo docker exec -it main_site bash -l
~]$ sudo docker logs -f main_site
| option | value | Describe |
|---|---|---|
--name | main_site | Set to Container name |
--restart | unless-stopped | Container is not recently stopped, it'll be start |
--publish | 9000:80 | docker_proxy Host:9000 to Container:80 |
--env | TZ=Asia/Seoul | Set Container Timezone to Asia/Seoul |
| option | value | HOST OS | HOST volume | Container volume |
|---|---|---|---|---|
--mount | type=bind,source=/free/home/project/html,target=/var/www/html | Linux | /free/home/project/html | /var/www/html |
--mount | type=bind,source=d:\project\abc.com\html,target=/var/www/html | Windows | D:\project\abc.com\html | /var/www/html |
/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
/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].
/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>
~]$ 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
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
Content type
Image
Digest
sha256:74f879c73…
Size
162.9 MB
Last updated
11 months ago
docker pull san0123/rocky9-http-php:8.4