I have a website that I would like to host in a php-fpm environment and Apache.
The host page.conf looks like this.
<VirtualHost *:443>
#LoadModule http2_module modules/mod_http2.so
<IfModule http2_module>
Protocols h2 http/1.1
LogLevel http2:info
</IfModule>
#ServerName test.lan-maniac.com
#ServerAlias test.lan-maniac.com
ServerAdmin [email protected]
#DocumentRoot /var/www/sub_lan-maniac/test
SSLENGINE on
SSLCertificateFile /etc/letsencrypt/live/test.lan-maniac.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/test.lan-maniac.com/privkey.pem
ProxyPassMatch ^/(.*.php(/.*)?)$ fcgi://localhost:9000/var/www/html/$1
ProxyPass / http://localhost:8123/
ProxyPassReverse / http://localhost:8123/
<Directory />
Order deny,allow
deny from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
The container files look like this.
docker-compose.yml
version: '3'
services:
php:
image: php:7.4-fpm
volumes:
- ./src:/var/www/html
expose:
- "9000"
apache:
image: httpd:alpine
volumes:
- ./src:/usr/local/apache2/htdocs
- ./apache/httpd.conf:/usr/local/apache2/conf/httpd.conf
ports:
- "8123:80"
httpd.conf
# Notwendige Module laden
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
LoadModule mpm_event_module modules/mod_mpm_event.so
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule dir_module modules/mod_dir.so
LoadModule mime_module modules/mod_mime.so
ServerRoot "/usr/local/apache2"
Listen 80
# Listen 8123
ServerName test.lan-maniac.com
<VirtualHost *:80>
DocumentRoot "/usr/local/apache2/htdocs"
ServerName test.lan-maniac.com
<Directory "/usr/local/apache2/htdocs">
AllowOverride All
Require all granted
</Directory>
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
#ProxyPassMatch ^/(.*.php(/.*)?)$ fcgi://php-fpm:9000/usr/local/apache2/htdocs/$1
<FilesMatch .php$>
SetHandler "proxy:fcgi://php:9000"
</FilesMatch>
</VirtualHost>
Unfortunately, when I start the container, I always get an exit code 1. This means that the Apache server does not start. I am at a loss. Does anyone know the answer.
Log didn’t give me a helpful answer:
apache2 host log,
[Thu Dec 12 23:38:56.654575 2024] [proxy:error] [pid 1621236] (111)Connection refused: AH00957: FCGI: attempt to connect to 127.0.0.1:9000 (localhost) failed
[Thu Dec 12 23:38:56.654629 2024] [proxy_fcgi:error] [pid 1621236] [client 109.42.176.94:6136] AH01079: failed to make connection to backend: localhost
[Thu Dec 12 23:38:56.985445 2024] [proxy:error] [pid 1620597] (111)Connection refused: AH00957: http: attempt to connect to 127.0.0.1:8123 (localhost) failed
[Thu Dec 12 23:38:56.985497 2024] [proxy_http:error] [pid 1620597] [client 109.42.176.94:8899] AH01114: HTTP: failed to make connection to backend: localhost, referer: https://test.lan-maniac.com/index.php
this by starting apachde container.
usr@instance-20221216-2317:/home/ubuntu/docker-test# docker-compose up apache
Creating network "docker-test_default" with the default driver
Creating docker-test_apache_1 ... done
Attaching to docker-test_apache_1
docker-test_apache_1 exited with code 1
14