Apache uses configuration files to modify its behavior. It usually stores them at /etc/apache2/ on Unix systems, but the configuration directory may vary depending on how it was installed and the operating system you are running it on.

The usual places

The main way to configure Apache is to modify the main configuration file, usually located at:


This file can also be named httpd.conf on old installations. If it’s not there, it’s probably in one of the following places:

  • /etc/httpd/httpd.conf
  • /etc/httpd/conf/httpd.conf
  • /usr/local/apache2/apache2.conf—If you compiled from source, Apache is installed on /usr/local/ or /opt/, rather than /etc/.

If you installed Apache on Windows, you probably installed it on your C:Program Files directory, under “Apache Software Foundation”:

C:Program FilesApache Software FoundationApache2.4

If you are using Apache on macOS (for local development), the config folder is normal /etc/apache2/ location, if you are using the stock version of Apache that came with macOS. If you have installed an updated version of brew, it is rather to:


Regardless of the operating system or the details of your installation, in this root configuration folder you will find a few files and directories:

  • apache2.conf or httpd.conf are the main configuration files.
  • ports.conf define on which ports Apache should listen.
  • conf.d/ is used to store configuration snippets that you can include in the master configuration.
  • sites-available/ is a directory containing a unique configuration file for each website hosted by your web server. You can host multiple sites from the same IP; Apache divides them by domain name and uses separate configuration files for each. It is common to name these files according to your domain name, for example sites-available/example.com. There is already a default site that you can copy.
  • sites-enabled/ determines which sites are actually used. This is a special folder containing symbolic links to the actual configuration files in sites-available. With this, you can activate and deactivate sites easily with the a2ensite order.

Configuration with .htaccess files

You can also configure Apache without even touching the root configuration. If the feature is enabled, Apache tries to read a file named .htaccess from your site’s document root (where you place your HTML and other site content).

This is particularly useful for shared hosting. Most of the time, if you get cheap website hosting from a service like GoDaddy or SquareSpace, you aren’t renting a full web server just for your site. Your site is bundled with many other smaller sites and runs on a single large server, which significantly reduces hosting costs. The problem with this setup is that you don’t want people to be able to change the configuration of other people’s sites running on the same server, so you can’t just give access to the main config folder.

.htaccess The files solve this problem by changing the behavior of Apache depending on the folder from which the content is served. This has a bit of a performance overhead, so it is not recommended to use it unless you are forced to do so by a shared hosting provider.

In this case, the location of your configuration folder is simple: create a new file simply named:


And place it in the root of your document next to your index.html or index.php pages. the .htaccess file will override the root config for the whole directory and apply it to all subdirectories as well.

You can have several .htaccess files in separate directories; for example, if you have part of your website hosted in the /admin/ folder, you can place a .htaccess in that folder and add basic HTTP authentication to secure it.

How to find the configuration folder manually

On most distributions, you can usually use the whereis command to locate programs and their associated files:

whereis apache2

It displays the location of the Apache binary, as well as the Apache configuration folder and all associated directories:

apache2: /usr/sbin/apache2 /etc/apache2 /usr/lib/apache2 /usr/share/apache2 /usr/share/man/man8/apache2.8.gz

If you don’t have this command or if it doesn’t work, use find to search your entire disk for directories named “apache2“:

sudo find / -type d -name "apache2"

You can also try to search for “httpd“, because Apache can be installed under that name. If those two commands don’t list anything, you probably didn’t install Apache in the first place.


Please enter your comment!
Please enter your name here