Help with Apache Configuration in Dockerized PHP Application

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,

I’m working on Dockerizing a PHP application and configuring Apache, but I’m encountering an issue related to `.htaccess` that I can’t seem to resolve. I’d greatly appreciate any guidance from the community!

Here’s the setup I’m working with:

Docker Compose File (docker-compose.yml):
services:
  php:
    image: php:8.1.29-fpm-alpine
    volumes:
      - ./admin:/usr/src/admin
    extra_hosts:
      - "docker-admin.localhost:127.0.0.1"
    expose:
      - "9000"
    entrypoint: ["php-fpm"]

  apache-server:
    build: .
    ports:
      - 8080:80
    volumes:
      - ./admin:/usr/local/apache2/htdocs/admin
    depends_on:
      - php

Dockerfile:

FROM httpd:2.4.52-alpine3.15

RUN mkdir -p /usr/local/apache2/conf/vhosts
COPY ./conf/* /usr/local/apache2/conf/vhosts
COPY ./httpd.conf /usr/local/apache2/conf/httpd.conf

Apache Virtual Host Configuration (admin.conf`):
<VirtualHost *:80>
    ServerName docker-admin.localhost
    DocumentRoot /usr/local/apache2/htdocs/apps/admin/public_html

    <Directory /usr/local/apache2/htdocs/apps/admin/public_html>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>

    <FilesMatch \.php$>
        SetHandler "proxy:fcgi://php:9000"
    </FilesMatch>

    ErrorLog /usr/local/apache2/error.log
    LogLevel warn
    CustomLog /usr/local/apache2/access.log combined
</VirtualHost>

The error I’m seeing:
[Sun Oct 06 10:02:48.889047 2024] [authz_core:error] [pid 10:tid 131326541519672] [client 192.168.16.1:49194] AH01630: client denied by server configuration: /usr/local/apache2/htdocs/apps/admin/public_html/.htaccess

My .htaccess file:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|robots\.txt|favicon\.ico)
RewriteRule ^(.*)$ /index.php/$1 [L]

I’ve tried clearing the `.htaccess` file and verifying permissions, but the issue persists. I’m relatively new to Docker and Apache configuration, so I may be missing something simple.

I’ve attached the [httpd.conf](https://drive.google.com/file/d/1-v0fzBVOcmFI5NRLsjdecSIkZRQSicz2/view?usp=sharing) file.  
Directory permissions reference:  
-rw-r--r--    1 504      dialout         45 Jun 11  2007 index.html  
drwxrwxr-x   12 www-data www-data      4096 Oct  6 09:57 apps  

Any advice or suggestions would be greatly appreciated!

Thanks

[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux