From 37430ea6173b5a31a505cd543f17397983a24bc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antoni=20Nu=C3=B1ez=20Romeu?= Date: Mon, 13 Apr 2026 18:00:11 +0200 Subject: [PATCH] Fix Apache-PHP integration: Add proper httpd.conf with proxy_fcgi configuration to enable PHP-FPM communication --- apache/Dockerfile | 6 +- apache/conf/extra/httpd-autoindex.conf | 0 apache/conf/extra/httpd-default.conf | 0 apache/conf/extra/httpd-info.conf | 0 apache/conf/extra/httpd-languages.conf | 0 apache/conf/extra/httpd-manual.conf | 0 apache/conf/extra/httpd-mpm.conf | 0 apache/conf/extra/httpd-userdir.conf | 0 apache/conf/extra/httpd-vhosts.conf | 0 apache/conf/httpd.conf | 92 ++++++++++++++++++++++++++ html/test.php | 3 + 11 files changed, 98 insertions(+), 3 deletions(-) create mode 100644 apache/conf/extra/httpd-autoindex.conf create mode 100644 apache/conf/extra/httpd-default.conf create mode 100644 apache/conf/extra/httpd-info.conf create mode 100644 apache/conf/extra/httpd-languages.conf create mode 100644 apache/conf/extra/httpd-manual.conf create mode 100644 apache/conf/extra/httpd-mpm.conf create mode 100644 apache/conf/extra/httpd-userdir.conf create mode 100644 apache/conf/extra/httpd-vhosts.conf create mode 100644 apache/conf/httpd.conf create mode 100644 html/test.php diff --git a/apache/Dockerfile b/apache/Dockerfile index ee41778..c808dde 100644 --- a/apache/Dockerfile +++ b/apache/Dockerfile @@ -1,7 +1,7 @@ FROM httpd:2.4-alpine -# Copy custom httpd.conf if needed (optional) -# COPY httpd.conf /usr/local/apache2/conf/httpd.conf +# Copy custom httpd.conf +COPY conf/httpd.conf /usr/local/apache2/conf/httpd.conf # Enable Apache modules (rewrite, etc.) if needed RUN sed -i 's/^#\(LoadModule rewrite_module\)/\1/' /usr/local/apache2/conf/httpd.conf && \ @@ -15,7 +15,7 @@ RUN sed -ri -e 's!/usr/local/apache2/htdocs!${APACHE_DOCUMENT_ROOT}!g' /usr/loca EXPOSE 80 # Copy virtual host configuration (will be mounted via docker-compose) -# COPY vhosts/ /etc/apache2/sites-enabled/ +COPY vhosts/ /etc/apache2/sites-enabled/ # Start Apache in foreground CMD ["httpd-foreground"] \ No newline at end of file diff --git a/apache/conf/extra/httpd-autoindex.conf b/apache/conf/extra/httpd-autoindex.conf new file mode 100644 index 0000000..e69de29 diff --git a/apache/conf/extra/httpd-default.conf b/apache/conf/extra/httpd-default.conf new file mode 100644 index 0000000..e69de29 diff --git a/apache/conf/extra/httpd-info.conf b/apache/conf/extra/httpd-info.conf new file mode 100644 index 0000000..e69de29 diff --git a/apache/conf/extra/httpd-languages.conf b/apache/conf/extra/httpd-languages.conf new file mode 100644 index 0000000..e69de29 diff --git a/apache/conf/extra/httpd-manual.conf b/apache/conf/extra/httpd-manual.conf new file mode 100644 index 0000000..e69de29 diff --git a/apache/conf/extra/httpd-mpm.conf b/apache/conf/extra/httpd-mpm.conf new file mode 100644 index 0000000..e69de29 diff --git a/apache/conf/extra/httpd-userdir.conf b/apache/conf/extra/httpd-userdir.conf new file mode 100644 index 0000000..e69de29 diff --git a/apache/conf/extra/httpd-vhosts.conf b/apache/conf/extra/httpd-vhosts.conf new file mode 100644 index 0000000..e69de29 diff --git a/apache/conf/httpd.conf b/apache/conf/httpd.conf new file mode 100644 index 0000000..dc7cb02 --- /dev/null +++ b/apache/conf/httpd.conf @@ -0,0 +1,92 @@ +ServerRoot "/usr/local/apache2" +Listen 80 + +# Load essential modules +LoadModule mpm_event_module modules/mod_mpm_event.so +LoadModule authn_file_module modules/mod_authn_file.so +LoadModule authn_core_module modules/mod_authn_core.so +LoadModule authz_host_module modules/mod_authz_host.so +LoadModule authz_groupfile_module modules/mod_authz_groupfile.so +LoadModule authz_user_module modules/mod_authz_user.so +LoadModule authz_core_module modules/mod_authz_core.so +LoadModule access_compat_module modules/mod_access_compat.so +LoadModule auth_basic_module modules/mod_auth_basic.so +LoadModule reqtimeout_module modules/mod_reqtimeout.so +LoadModule filter_module modules/mod_filter.so +LoadModule mime_module modules/mod_mime.so +LoadModule log_config_module modules/mod_log_config.so +LoadModule env_module modules/mod_env.so +LoadModule headers_module modules/mod_headers.so +LoadModule setenvif_module modules/mod_setenvif.so +LoadModule version_module modules/mod_version.so +LoadModule unixd_module modules/mod_unixd.so +LoadModule status_module modules/mod_status.so +LoadModule autoindex_module modules/mod_autoindex.so +LoadModule dir_module modules/mod_dir.so +LoadModule alias_module modules/mod_alias.so +LoadModule rewrite_module modules/mod_rewrite.so +LoadModule proxy_module modules/mod_proxy.so +LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so + + +User daemon +Group daemon + + +ServerAdmin you@example.com + + + AllowOverride none + Require all denied + + +DocumentRoot "/usr/local/apache2/htdocs" + + Options Indexes FollowSymLinks + AllowOverride None + Require all granted + + + + DirectoryIndex index.html index.php + + + + Require all denied + + +ErrorLog "/proc/self/fd/2" +LogLevel warn + + + LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined + LogFormat "%h %l %u %t \"%r\" %>s %b" common + CustomLog "/proc/self/fd/1" common + + + + ScriptAlias /cgi-bin/ "/usr/local/apache2/cgi-bin/" + + + + AllowOverride None + Options None + Require all granted + + + + RequestHeader unset Proxy early + + + + TypesConfig conf/mime.types + AddType application/x-compress .Z + AddType application/x-gzip .gz .tgz + AddType application/x-httpd-php .php + AddType application/x-httpd-php-source .phps + + + + # Proxy PHP requests to PHP-FPM + ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://php:9000/var/www/html/$1 + \ No newline at end of file diff --git a/html/test.php b/html/test.php new file mode 100644 index 0000000..5392879 --- /dev/null +++ b/html/test.php @@ -0,0 +1,3 @@ + \ No newline at end of file