Basic Apache Configuration
This guide covers only the most important Apache configuration steps for Debian/Ubuntu and CentOS systems.
1. Main Config File
- Debian/Ubuntu
- CentOS
- Main Config:
/etc/apache2/apache2.conf
- Main Config:
/etc/httpd/conf/httpd.conf
2. Change Default Web Root (Optional)
- Debian/Ubuntu
- CentOS
Edit the DocumentRoot directive:
sudo nano /etc/apache2/sites-available/000-default.conf
Look for DocumentRoot and change the path as needed.
Edit the DocumentRoot directive:
sudo nano /etc/httpd/conf/httpd.conf
Look for DocumentRoot and change the path as needed.
3. Enable/Disable Modules
- Debian/Ubuntu
- CentOS
- Enable:
sudo a2enmod rewrite - Disable:
sudo a2dismod rewrite - Reload:
sudo systemctl reload apache2
- Most modules are enabled by default. Edit
/etc/httpd/conf.modules.d/*.confif needed. - Reload:
sudo systemctl reload httpd
4. Test Configuration
- Debian/Ubuntu
- CentOS
sudo apache2ctl configtest
sudo apachectl configtest
5. Reload/Restart Apache
- Debian/Ubuntu
- CentOS
sudo systemctl reload apache2
# or
sudo systemctl restart apache2
sudo systemctl reload httpd
# or
sudo systemctl restart httpd
Tip: After changes, always test config and reload Apache.