Note: We know that this Joomla error has been covered in other places before – but in many cases, the solutions presented elsewhere do not solve the problem and none of the other places explains why this problem happens in the first place. We will try our best to present an actual solution that will work for anyone and we will also explain why this problem happens!
First we would like to apologize. We have seen and fixed this problem so many times now (for years) but we have never written about it. So here’s a post explaining when the “JFolder::create: Could not create directory” error happens, why it happens, and what you can do to solve the problem.
When does this problem happen?
The problem happens when you try to install an extension or a template from the backend on your Joomla website. Instead of seeing a Success message, you will see the JFolder::create: Could not create directory error message. The aforementioned error message is usually accompanied by the Warning: Failed to move file! error message.
Essentially, when you see this error then most likely you are not able to install any extensions or templates on your website.
Why does this problem happen?
This problem happens because of one of the following reasons:
- The tmp directory does not exist or is not correctly referenced in the configuration.php file.
-
The tmp directory exists, but Joomla doesn’t have the permissions to write to it.
-
Joomla doesn’t have the permissions to write to one of the following directories: /administrator/components, /administrator/modules, /administrator/templates, /components, /modules, /plugins, /templates.
The latter case is very common nowadays and usually happens when there is something wrong with Joomla’s hosting environment – for example, the Apache user is in a separate group than that of the cPanel user (the user responsible for uploading files through cPanel and FTP). We have seen this on both cPanel and Plesk environments (although we have to say that this issue is far more common on Plesk).
What can you do to fix this problem?
Besides creating the tmp directory if it doesn’t exist and give Joomla the proper permissions to write to it, a quick and dirty fix will be to chmod the following directories to 777 through your FTP client:
- /administrator
- /administrator/components
- /administrator/modules
- /administrator/templates
- /components
- /logs (not necessary to solve this problem but if Joomla has write permissions across the board then doing this will ensure that you don’t have a problem elsewhere on your website)
- /modules
- /plugins
- /templates
- /tmp
As we said – the above is a quick and dirty fix – but it will render your website completely insecure. So, you must leave the above as a last resort if you’re stranded on time and only as a temporary fix.
So, what’s a better solution?
A better solution would be to call your hosting company and tell them that you’re having a problem with your Apache user not being able to write on the Joomla directories. What they will do probably (if they decide to take any action) is that they’ll chown (change ownership) of all the Joomla files and directories to the Apache user, this will solve your problem immediately. Some lazy hosts may just chmod everything to 777 – make sure that they don’t do that!
OK, so what’s the best solution?
The best solution to this problem requires some work on your side – but it’s the cleanest solution and requires that you only have FTP access to your website. You see, the reason why the cPanel (or Plesk) user owned the Joomla files and directories in the first place is because that user was the one uploading the folders/files – in other words – that user was responsbile for creating those folders/files on the server’s filesystem. So, what can we do to make Apache create (own) those files instead? Easy! All we need to do is the following:
- Zip the Joomla website (all of it – e.g. all files and directories) using cPanel’s File Manager – call the resulting zip file joomlawebsitebackup.zip. The resulting zip file must be placed under the root directory of the website.
-
Append 1_ to all the top level folders and files in Joomla. This means renaming the folder administrator to 1_administrator, and index.php to 1_index.php
-
Create an unzip.php file that contains the following code:
<?php ini_set("memory_limit", "4096M"); set_time_limit (0); $objZip = new ZipArchive; $isZipOpen = $objZip->open('joomlawebsitebackup.zip'); if ($isZipOpen === TRUE) { $objZip->extractTo('/home/[yourcpanelusername]/public_html/'); $objZip->close(); echo "Finished unzipping"; } else { echo "Failed unzipping"; } ?>
-
Run the unzip.php by going to yourjoomlawebsite.com/unzip.php on your browser. The unzipping might take several minutes to several hours, depending on the size of your website. Please be patient. Once the process is done, you should see a message telling you that the PHP script has finished unzipping the file.
-
Now login to your Joomla's backend and you'll notice that you are now able to install any extension, while the permissions on your directories are still 755. This is because Apache is now the owner of all the Joomla files and folders, because it (Apache) was the one creating them with the unzip script.
-
Test your website thoroughly - once you are sure that everything works as it should, then delete all the folders and files that start with 1_. Once you do that, do another test on your website to make sure that everything's OK.
Can this error happen on Joomla 2.5 as well?
Yes - in fact, the JFolder::create error exists on nearly all versions of Joomla. You can run but you can't hide!
Do you still have this problem? Read on!
We have presented a solid solution to this problem - if it doesn't work for you, then please retrace your steps and double check that you're following the process with no modification whatsoever. If you're still experiencing problems doing the above (even after retracing your steps) or if you need help, then contact us! We're fast, we're professional, we're friendly, we're always there, and our rates are affordable!
Thanks for the solution with the unzip method. But this is starting a new problem. How to delete the files from the server? Even reset ownership will not help.
‘Write access to the directory containing pathname was not allowed for the process’s effective uid, or one of the directories in pathname did not allow search (execute) permission.’
Hi Peter,
It seems that you have some messed up permissions on your environment. This scenario usually happens when using DirectAdmin.
Your best long term option is to switch to WHM (cPanel).
A short term option would be to ssh as root to your server and delete the files. If you don’t have root ssh access, then another option would be to develop a small PHP file that will modify the permissions on a specific directory (you can contact us to do that for you) so you can delete them.
Hi,
I am trying to create a new folder in my media manager but I am getting the error message: “Warning
JFolder::create: Could not create directoryPath”
What could I do?
Thanks
Filip
Hi Filip,
Check 2 things:
– The website’s main folder and the images folders are owned by the user that your web environment uses to run the Joomla website (for example, in case of a WHM/cPanel environment, that user must be the same as the cPanel user)
– The permissions on the aforementioned folders are set to 755
The above should address the problem on any environment (Plesk, WHM, etc…)