apache: Remove default welcome page

Closes: #1293.

Tests:

- Copy /usr/share/apache2/default-site/index.html to /var/www/html/index.html.
Apply the patches. The file in /var/www/html/index.html is removed.

- Create a new custom file in /var/www/html/index.html. Increment the setup
version so apache2 setup is run. The file is not removed.

- Copy the default file again and run setup again. The file is removed.

- Increment setup version again and there are no errors due to missing file.

[sunil: Add check to ensure that only default files are not removed]
Signed-off-by: Frederico Gomes <fredericojfgomes@gmail.com>
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Tested-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
Frederico Gomes authored and Sunil Mohan Adapa committed 2026-11-23 06:52:39 -08:00
1 parent 60c8f41f79
commit bb1a45ef0a
2 files changed
+11 -1

No files matched your search

+1 -1
View File
@@ -86,7 +86,7 @@ class ApacheApp(app_module.App):
app_id = 'apache'
_version = 17
_version = 18
def __init__(self) -> None:
"""Create components for the app."""
+10
View File
@@ -62,6 +62,15 @@ def _disable_mod_php(webserver):
webserver.disable('php' + version, kind='module')
def _remove_default_index_html():
"""Remove Apache's default welcome page."""
default_page = pathlib.Path('/var/www/html/index.html')
shipped_default_page = pathlib.Path(
'/usr/share/apache2/default-site/index.html')
if default_page.read_text() == shipped_default_page.read_text():
default_page.unlink(missing_ok=True)
@privileged
def setup(old_version: int):
"""Setup Apache configuration."""
@@ -81,6 +90,7 @@ def setup(old_version: int):
check=True)
_setup_oidc_config()
_remove_default_index_html()
with action_utils.WebserverChange() as webserver:
# Disable mod_php as we have switched to mod_fcgi + php-fpm. Disable