keepcalculator

06 Numbers and Powers

Apache Default Page Showing Instead of WordPress: Fix

Card No. 06·15474 · Updated · Standard formula, shown below

If you see the Apache default page instead of your WordPress site, it means Apache is serving its own index.html file before WordPress’s index.php. The fix is to configure Apache’s DirectoryIndex directive to prioritize index.php and ensure your virtual host’s document root points to your WordPress directory. Below is a step-by-step guide to resolve this issue quickly.

Why the Apache Default Page Appears

Apache ships with a default configuration that includes a placeholder page at /var/www/html/index.html. When you install WordPress, you typically upload its files to the same directory, but Apache’s default DirectoryIndex setting often lists index.html before index.php. As a result, when a visitor requests the site root, Apache serves the static HTML file instead of executing WordPress’s PHP index file.

This is common on fresh LAMP/LEMP setups, especially after installing WordPress manually or using a one-click installer that doesn’t adjust Apache’s configuration. The issue can also occur if the virtual host’s document root points to the wrong directory, such as /var/www/html instead of /var/www/html/wordpress.

How to Fix the DirectoryIndex Order

The most direct fix is to edit Apache’s configuration to prioritize index.php. Here’s how:

  1. Open the Apache configuration file for your site. On Debian/Ubuntu, this is usually /etc/apache2/sites-available/000-default.conf or a file in /etc/apache2/conf-available/. On CentOS/RHEL, it’s /etc/httpd/conf/httpd.conf or a file in /etc/httpd/conf.d/.
  2. Find the <Directory> block for your document root (e.g., /var/www/html). If there isn’t one, add it.
  3. Inside that block, add or modify the DirectoryIndex directive to list index.php first: DirectoryIndex index.php index.html.
  4. Save the file and restart Apache: sudo systemctl restart apache2 (Debian/Ubuntu) or sudo systemctl restart httpd (CentOS/RHEL).

After restarting, refresh your browser. If WordPress still doesn’t load, check the document root setting.

Check the Virtual Host Document Root

If the DirectoryIndex is correct but the default page persists, your virtual host may be pointing to the wrong directory. For example, if you installed WordPress in /var/www/html/wordpress but your virtual host’s DocumentRoot is /var/www/html, Apache will look for files directly in /var/www/html and find the default index.html there.

To fix this, edit your virtual host file (e.g., /etc/apache2/sites-available/example.com.conf) and change the DocumentRoot to the actual WordPress directory:

DocumentRoot /var/www/html/wordpress
<Directory /var/www/html/wordpress>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

Then restart Apache. Also ensure that the AllowOverride All directive is present so WordPress’s .htaccess file can work correctly for permalinks.

Rename or Remove the Default index.html

Sometimes the simplest fix is to remove or rename the default index.html file. If you are sure you don’t need it, delete it:

sudo rm /var/www/html/index.html

Or rename it to something like index.html.bak to keep a backup. This forces Apache to fall back to index.php even if the DirectoryIndex order isn’t changed. However, this is a workaround, not a permanent fix, because future updates may recreate the file.

Enable the PHP Module and WordPress Dependencies

If Apache still shows a blank page or a file download prompt, PHP may not be installed or enabled. On Ubuntu/Debian, install PHP and the necessary modules:

sudo apt install php libapache2-mod-php php-mysql
sudo a2enmod php
sudo systemctl restart apache2

On CentOS/RHEL, use sudo yum install php php-mysql and then restart httpd. Also ensure that the mod_rewrite module is enabled for WordPress permalinks: sudo a2enmod rewrite (Debian/Ubuntu) or uncomment the LoadModule rewrite_module line in httpd.conf (CentOS/RHEL).

Common Mistakes and Misconceptions

A frequent mistake is editing the wrong configuration file. On Debian/Ubuntu, the main configuration is /etc/apache2/apache2.conf, but site-specific settings are in /etc/apache2/sites-available/. If you edit the main file but the virtual host overrides it, your changes won’t take effect. Always check the virtual host for the site you are accessing.

Another misconception is that the default page means WordPress is not installed. In most cases, WordPress files are present, but Apache simply isn’t serving them. Check the file permissions: the web server user (www-data on Debian/Ubuntu, apache on CentOS) needs read access to the WordPress files and execute access to the directories. Use sudo chown -R www-data:www-data /var/www/html/wordpress if needed.

Frequently Asked Questions

Why is my WordPress site showing the Apache default page after a server restart?

This often happens if the default index.html was recreated by a system update or if the Apache configuration was reset to defaults. Check the DirectoryIndex directive and the document root again; also verify that the WordPress files are still present in the expected directory.

Can I fix this without editing Apache configuration files?

Yes, you can rename or delete the default index.html file, but this is a temporary workaround. The proper fix is to adjust the DirectoryIndex order or the virtual host document root, as described above.

What if I see a 403 Forbidden error instead of the default page?

A 403 error usually means the directory permissions are too restrictive or the Require directive is set to deny access. Ensure the <Directory> block allows access with Require all granted and that file permissions are at least 644 for files and 755 for directories.

Does this fix work for Nginx as well?

No, Nginx uses a different configuration system. In Nginx, you would need to set index index.php index.html; in the server block and ensure the try_files directive is configured correctly for WordPress. The Apache-specific steps here do not apply.

Why does my WordPress site work with the default page but not with my custom theme?

If the default page appears, it’s not a theme issue; it’s a server configuration issue. Once Apache serves WordPress’s index.php, the theme will load normally. If you see a blank page after fixing this, check the PHP error logs for syntax errors or missing files.

Is it safe to delete the default index.html?

Yes, it is safe to delete or rename it. It’s just a placeholder page and is not required for Apache to function. However, if you are unsure, rename it to index.html.bak instead of deleting it.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.

More cards in this drawer

The whole Numbers and Powers drawer →