Fix Joomla Error 0
Created January 17, 2020
Updated March 11, 2024
3 min read

How to Fix Joomla Error 0 ‘Cannot open file for writing log while updating’?

Did you already try updating your Joomla website and you got this error:

"An error has occurred. 0 Cannot open file for writing log"

Don’t worry, you’re not alone, this may happen for different reasons. Here are a couple of them and solutions to fix each one of them.

If you have issues with updating the backend, you won’t probably be able to do it, so open the file “configuration.php” and find the path of tmp or log folders and replace with the correct path.

Here is an example of a path to Log and tmp Folder:

*/home/**yourusername**/public_html/logs*
or
*/home/**yourusername**/public_html/administrator/logs*

*/home/**yourusername**/public_html/tmp*

1. Permission Issue

Make sure all files and folders apart from the global configuration.php are writable. If they aren’t, then you will need to change the permissions, so that all folders are set to 755 and files are set to 644.

To check permission in the Joomla backend, go to:

System (top menu) >> System Information >> Directory Permissions

You can either do this using an FTP client such as FileZilla, SSH or a Joomla extension such as Admin Tools.

I usually use SSH and here are the normal permissions of any Joomla website, remember to go in the project folder before running these 2 commands.

find -type d -exec chmod 755 {} \; 
find -type f -exec chmod 644 {} \;

Admin Tools extensions is really helpful for this is you are not familiar with SSH, but even if you are, Admin Tools for Joomla is a good option to add protection to your Joomla or WordPress website.

Do not set the permission to 777!

2. Wrong Directory Paths for the Tmp/Log Directories, Defined in the Configuration File

You must configure your “/log” and or “/tmp” folder to a absolute links of your server, in the backend of Joomla.

To check/change the path, in Joomla backend, go to Global Configuration and then choose the Server tab and check if the Path to Log folder is correct:

  • log : $log_path
  • tmp : $tmp_path

If you are not sure what is your path, create a .php file and paste this code to know what is the absolute path to your server. Upload and call it on your browser: ex: www.domain.com/path.php, here is the code:

$path = getcwd(); 
echo "Your Absolute Path is:" . $path;

3. Directories and File Ownership

Check the ownership of the folder it can be set to root:root and this can be set from your /var/www/html folder.

A problem arises if you want to write something to files within your website (change existing files or upload new files). Root privileges would not allow you to do so.

To fix it you need to set ownership to www-data:www-data or apache:apache.

You need to pay attention to make sure that you set www-data or apache permissions only to directories (files) that you need to change from the website.

Setting it to /var/www/html or even /var/www is not recommended as it is big security hole.

If you need any help with web development don’t hesitate to contact our web development experts. We run the best custom web development agency in Montreal.