I am trying to use php/apache in docker and I want to have a custom 500 page. I am trying it out on localhost and it never shows the page.
Dockerfile
FROM php:7.4-apache
COPY . /var/www/html/
COPY php.ini /usr/local/etc/php/
RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf
&& echo "<Directory /var/www/html/>" >> /etc/apache2/apache2.conf
&& echo " AllowOverride All" >> /etc/apache2/apache2.conf
&& echo " Require all granted" >> /etc/apache2/apache2.conf
&& echo "</Directory>" >> /etc/apache2/apache2.conf
RUN a2enmod rewrite
EXPOSE 80
CMD ["apache2-foreground"]
.htaccess
ErrorDocument 500 /error.html
PHP page
<?php
nonExistentFunction();
?>
Error html
<html>
<head>
<title>Error Page</title>
</head>
<body>
<h1>Unexpected Error</h1>
</body>
</html>
Standard browser error page is shown, there is nothing in apache logs
Run as follows:
docker run --rm -p8080:80 myimage
I did try a try/catch as per this post and it made no difference: /a/51793178/1033684