Skip to main content

Basic Apache Configuration

This guide covers only the most important Apache configuration steps for Debian/Ubuntu and CentOS systems.


1. Main Config File

  • Main Config: /etc/apache2/apache2.conf

2. Change Default Web Root (Optional)

Edit the DocumentRoot directive:

sudo nano /etc/apache2/sites-available/000-default.conf

Look for DocumentRoot and change the path as needed.

3. Enable/Disable Modules

  • Enable: sudo a2enmod rewrite
  • Disable: sudo a2dismod rewrite
  • Reload: sudo systemctl reload apache2

4. Test Configuration

sudo apache2ctl configtest

5. Reload/Restart Apache

sudo systemctl reload apache2
# or
sudo systemctl restart apache2

Tip: After changes, always test config and reload Apache.