Location of Apache Log- and Configuration Files

Where to find the apache configuration- and log files in Ubuntu.

1820 views

Edited: 2019-11-21 05:49

The Apache files are usually stored in /etc/apache2/ and /var/log/apache2/ respectively, but it may depend on your configuration.

Sometimes you want to delete the log files, or edit the configuration files from a FTP client. The problem is that these files are write protected, so you will have to either change the permissions to the files temporarily, or create a different user for your FTP client.

Typically, you may just want to change the permissions temporarily from a terminal or from the putty client on windows, and then change them back once you are done working with the files.

Server log files

Log files are normally stored under /var/log/ in Ubuntu. Specifically for the Apache log files, this will likely be /var/log/apache2/

You can read the logfile with a text editor such as notepad on windows or gedit on linux.

After deleting log files remember to restart the server.

To delete log Apache files you may type the below command in terminal:

rm -rf /var/log/apache2/*

The rm command is used to remove files and directories in linux. The -rf options forcefully remove all files, including subdirectories and files within. The r stands for recursive, and will remove subdirectories and files within, while the f forcefully removes files that are write-protected without prompting.

Configuration files

The location of Apaches configuration files depends on how you installed the server. If you installed the official package the files will usually be located in /etc/apache2/

The vhost configuration is located in /etc/apache2/sites-enabled. The file you need to edit when configuring virtual hosts is likely called default or 000-default.

The apache2.conf file is located in the root of the /etc/apache2/ directory.

The mudule configuration files are located in a subdirectory of the /etc/apache2/ directory, but you should not normally have to modify the files manually. Instead try using the terminal commands for installing, enabling and disabling apache mods. I.e.:

sudo apt-get install libapache2-modsecurity

To enable a mod type the following:

sudo a2enmod module_name

And to disable mods:

sudo a2dismod module_name

Remember to restart apache after making changes. See also: Starting, Stopping and Restarting Web-servers in terminal

Tell us what you think:

  1. Understanding file permissions in Unix / Linux based systems, and how to make files immutable.
  2. In this article I will explain how to enable a swapfile on small instances, and why it might be useful, even if you do have enough physical memory.
  3. How to determine an optimal value for pm.max_children and related php-fpm settings for your server and web applications.
  4. Tutorial showing how to configure a VirtualBox Guest VM with HOST-only and NAT adapter, while using the WWW folder from the HOST OS.
  5. You may have wondered what the /etc/php/8.0/conf.d/ directory is for in Debian and Ubuntu, and whether it is better to edit the conf.d files than editing php.ini directly; find out in this Tutorial.

More in: Linux servers