The Problem
When you install Apache 2, you would see the “Welcome Page” as shown below when you first open the URL IP of the server.
You may not find this page in the default Document Root “/var/www/html” as well. How can we disable this page and have our own page being displayed?
The Solution
In order to change this behaviour, check to see if there is a file called /etc/httpd/conf.d/welcome.conf. This is the page that is displayed as the Welcome Page.
Disabling Apache Welcome Page
Method 1 : removing/renaming Welcome Page
1. In order to disable this page, we have to rename the file /etc/httpd/conf.d/welcome.conf to something else or you can simply delete it if you don’t need it.
# mv /etc/httpd/conf.d/welcome.conf /etc/httpd/conf.d/welcome.conf_backup
2. Make sure that Apache is restarted (as root) with the command:
# systemctl restart httpd
Method 2 : allow Indexes in /etc/httpd/conf.d/welcome.conf
1. Without an index at the DocumentRoot, the default Apache Welcome page will display unless /etc/httpd/conf.d/welcome.conf is modified to allow Indexes. Edit /etc/httpd/conf.d/welcome.conf to allow Indexes.
2. Comment the Options line (add a # mark) in /etc/httpd/conf.d/welcome.conf as shown below:
# vi /etc/httpd/conf.d/welcome.conf <LocationMatch "^/+$"> # Options -Indexes ErrorDocument 403 /error/noindex.html </LocationMatch>
Or you can enable Indexes by changing the – to a +
# vi /etc/httpd/conf.d/welcome.conf <LocationMatch "^/+$"> Options +Indexes ErrorDocument 403 /error/noindex.html </LocationMatch>
3. The Apache service (httpd) is restarted for the changes to take effect.
# systemctl restart httpd
Verify
Lets add a smaple index.html page in the Document Root to verify if we have disabled the Welcome Page and can view the pages in the Document Root.
# echo "<h1>This is a Test Page</h1>" > /var/www/html/index.html
Open the browser and point it to the server IP address. The page should look like the one shown in the screenshot below.