Docker for PHP application

Kindly help to resolve this error
PHP Version : php:5.4-apache in docker file
APache version :Apache/2.4.6

PHP app:PHP Version 5.4.16

Error:

.htaccess: Invalid command ‘EnableBasicAuth’, perhaps misspelled or defined by a module not included in the server configuration

I don’t think that EnableBasicAuth is a valid command in .htaccess. The definitive documentation is Authentication and Authorization - Apache HTTP Server Version 2.4 This article seems to be a decent guide to setting up basic auth. https://tecadmin.net/configure-basic-authentication-in-apache-using-htaccess/

2 Likes

Nothing seems to work

If you still want help, you need to provide more information than that, although @edgreenberg gave you a perfectly good answer pointing to the right documentation. Why did you think that “EnableBasicAuth” would work in an .htaccess file and why do you think the error is related to Docker?

The only docker-related help I can give you is my HTTPD image. I also have an example how you can enable Basic HTTP auth with that:

https://httpd24-docker-image.readthedocs.io/en/latest/examples.html#http-authentication

docker run --rm -i itsziget/httpd24 /bin/bash -c "htpasswd -nb YOURUSERNAME YOURPASSWORD" >> .htpasswd
docker run -d \
   -v `pwd`/.htpasswd:/usr/local/apache2/.htpasswd \
   --env SRV_AUTH="true" \
   -p 80:80 \
   itsziget/httpd24:2.0

or just generate htpasswd inside the container

docker run -d \
   --env SRV_AUTH="true" \
   --env SRV_AUTH_USERS="admin1 password1\
 admin2 password2"
   -p 80:80 \
   itsziget/httpd24:2.0

Now the access issue is not displayed it prompts the internal server error

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at [no address given] to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

THE HTTPD service had issue and that prompts the .ht access issue

Also unless you give us more information for example how exactly you run the container, we can’t help. The error message is just an HTTPD error message and the details are in the logs.

docker logs containername

Here is a blogpost based on my presentation to help you find the logs and find more information about errors.

We can help only if you share what you do.