If you’re used to working with Nginx on Debian 12, you’ve likely mastered the sites-available and sites-enabled directory structure to manage virtual hosts. Interestingly, Apache2 adopts the same concept , just with a few differences in how things are enabled and maintained.

This article walks through setting up Apache2 and draws parallels to the Nginx workflow, so you can feel right at home.

Apache2 Directory Structure

Apache’s site configuration lives in two primary directories:

  • /etc/apache2/sites-available/: Where all virtual host config files reside.
  • /etc/apache2/sites-enabled/: Where symbolic links to active configs live.

Just like Nginx, only the files symlinked into sites-enabled are actually loaded by the server.

Enabling Sites, Apache vs Nginx

With Nginx:
You manually enable sites using symlinks:

And disable them by removing the link:

With Apache,
Apache provides helper commands to manage this:

These commands create or remove symlinks from sites-enabled, just like you’d do manually in Nginx.

After any change, reload the config:

Example Virtual Host File in Apache

Let’s say you want to host example.com. Here’s a basic config file:

/etc/apache2/sites-available/example.com.conf

To activate it:

Make sure the directory /var/www/example.com exists and contains your site files.

Apache vs Nginx, Side-by-Side

FeatureNginxApache2
EngineEvent-drivenProcess/thread-based
Enabling sitesManual symlinka2ensite, a2dissite
Module systemEdit config manuallya2enmod, a2dismod
.htaccess supportNot supportedSupported (if enabled)
Config reloadsystemctl reload nginxsystemctl reload apache2

Why Switch or Use Both?

Apache2 and Nginx each have strengths:

  • Apache is easier for .htaccess users, legacy systems, and dynamic PHP apps.
  • Nginx excels in performance and is great as a reverse proxy or static file server.

In some setups, you may even use both — with Nginx in front as a reverse proxy and Apache handling backend logic.

Final Thoughts

If you’re comfortable with Nginx on Debian, you’ll find Apache2’s structure familiar. Tools like a2ensite and a2enmod make managing configurations easy, especially when you’re dealing with multiple domains or legacy apps that rely on .htaccess.

Whether you’re exploring Apache for compatibility reasons, migrating from Nginx, or just curious, this transition is smooth , and sometimes, even fun.

Leave A Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.