Joomla Error – “JFolder::create: Could not create directory” while installing extension

Problem:

I recently got the following error while trying to install a custom extension on Joomla.

JFolder::create: Could not create directory

Solution:

This kind of error is generally related with folder permission. I checked for the folder permission in my Joomla installation and it seems to be fine. The folders have 755 permission.

The other reason is the folder owner. This kind of error occurs if your folders’ owner is other than your Apache server’s user. If so then you have to change your folders’ owner to Apache user.

You can find the apache server user with the following command:

ps aux | grep -v root | grep apache | cut -d\ -f1 | sort | uniq

Source: http://serverfault.com/questions/125865/finding-out-what-user-apache-is-running-as

For Ubuntu, it’s www-data.

After you know the apache user name, then you can change the owner of all the folders and files of your Joomla installation. You can use the following command to do so:

(I suppose that your apache user is www-data)

sudo chown -R www-data:www-data /path/to/your/joomla

If you are already inside your Joomla directory, then you can run the following command:

sudo chown -R www-data:www-data .

Now, you should be able to install any custom extension from your Joomla admin.

Hope this helps.
Thanks.