Share via:

Location of Apache Log- and Configuration Files

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


Edited: 2017-03-18 02:51

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