How to Find Your Apache Configuration Folder

Apache makes use of configuration recordsdata to change its habits. It normally shops them at /and so on/apache2/ on Unix techniques, however the configuration listing can range, relying on the way it was put in and which working system you’re operating it on.

The Usual Places

The major method of configuring Apache is by modifying the principle configuration file, normally positioned at:

/and so on/apache2/apache2.conf

This file can be named httpd.conf on older installs. If it’s not there, it’s seemingly in one of many following locations:

  • /and so on/httpd/httpd.conf
  • /and so on/httpd/conf/httpd.conf
  • /usr/native/apache2/apache2.conf—should you’ve compiled from supply, Apache is put in to /usr/native/ or /choose/, fairly than /and so on/.

If you’ve put in Apache on Windows, you seemingly put in it to your C:Program Files listing,  below “Apache Software Foundation”:

C:Program FilesApache Software FoundationApache2.4

If you’re utilizing Apache on macOS (for native growth), the config folder is on the common /and so on/apache2/ location, should you’re utilizing the inventory model of Apache that comes with macOS. If you’ve put in an up-to-date model from brew, it as a substitute is at:

/usr/native/and so on/httpd/httpd.conf

Regardless of the working system or the small print of your set up, inside this root configuration folder you’ll discover a couple of recordsdata and directories:

  • apache2.conf or httpd.conf are the first configuration recordsdata.
  • ports.conf outline on what ports Apache ought to hear.
  • conf.d/ is used to retailer configuration snippets you’ll be able to embrace within the major config.
  • sites-available/ is a listing containing a novel config file for every web site your net server hosts. You can host a number of websites from the identical IP; Apache splits them by area identify and makes use of separate config recordsdata for every. It’s widespread follow to identify these recordsdata in accordance to your area identify, e.g. sites-available/instance.com. A default web site already exists you could copy.
  • sites-enabled/ determines which websites are literally in use. It’s a particular folder containing symlinks to the precise configuration recordsdata in sites-available. With this, you’ll be able to flip websites on and off simply with the a2ensite command.

Configuration with .htaccess Files

You may also configure Apache with out even touching the basis configuration. If the function is enabled, Apache makes an attempt to learn a file named .htaccess out of your web site’s doc root (the place the place you set your HTML and different web site content material).

It’s notably helpful for shared internet hosting. Most of the time, should you get low cost web site internet hosting from a service like GoDaddy or SquareSpace, you’re not renting a complete net server simply in your web site. Your web site is bundled with many different smaller websites and ran off one huge server, which cuts down on internet hosting prices considerably. The drawback with this setup is that you simply don’t need individuals to have the opportunity to modify the configuration for different individuals’s websites operating on the identical server, so you’ll be able to’t simply give entry to the first config folder.

.htaccess recordsdata remedy this subject by altering the habits of Apache based mostly on the folder from which the content material is being served. Doing so has a little bit of a efficiency overhead, so it’s not beneficial to be used except you’re pressured to by a shared internet hosting supplier.

In this case, the placement of your config folder is straightforward—create a brand new file merely named:

.htaccess

And place it in your doc root alongside your index.html or index.php pages. The .htaccess file will override the basis config for the entire listing, and in addition apply it to any subdirectories.

You can have a number of .htaccess recordsdata in separate directories; for instance, you probably have part of your web site hosted within the /admin/ folder, you may place an extra .htaccess in that folder and add primary HTTP auth to safe it.

How to Find The Configuration Folder Manually

On most distros, you’ll be able to normally use the whereis command to find packages and their related recordsdata:

whereis apache2

It outputs the placement of the Apache binary, in addition to the Apache configuration folder and all associated directories:

apache2: /usr/sbin/apache2 /and so on/apache2 /usr/lib/apache2 /usr/share/apache2 /usr/share/man/man8/apache2.8.gz

If you don’t have this command or it isn’t working, then use discover to search your complete drive for directories named “apache2“:

sudo discover / -type d -name "apache2"

You may also attempt looking for “httpd“, as Apache could also be put in below that identify. If each of these instructions don’t listing something, you seemingly don’t have Apache put in within the first place.



https://www.howtogeek.com/devops/how-to-find-your-apache-configuration-folder/

Related Posts