Configuring the temporary directory
I have recently moved a site from a localhost to a VPS. I have managed to make the public and private files writable; however, I am not sure where to find the temporary folder and how to change the permissions. I keep getting this message:
The specified file temporary://file3Hl91E could not be copied, because the destination directory is not properly configured. This may be caused by a problem with file or directory permissions. More information is available in the system log.
I am using Virtualmin, Drupal 7, and a Debian server. My current temporary directory is
Check Administrator -> Configuration -> Media -> File System to personalize your tmp path. Make sure to use relative paths and have the right privileges for the Apache user.
I personally like this article fix file upload. He has good observations. It worked for me.
Recently, I downloaded my site to my Mac computer. It happens that in my Mac I was using
mod_userdirfor Apache and I forgot that in
/etc/apache2/users/nameofuser.confI need to set
AllowOverride All, otherwise I will have the following message:
The specified file temporary could not be copied because the destination directory is not properly configured.
absolutely! I would add more. I just want to give a quick answer that you can try right away. If not, they can take a look for more info. I would try to add more info without loosing briefness.
In your settings.php
$conf['file_temporary_path'] = '/tmp';
This will work on unix systems 99% of the time.
Usually the /tmp directory exists on UNIX systems with open permissions, and it exists specifically for temporary files and is often set up to improve performance.
You can check permissions by running
ls -al /tmpon the command line.
If you're interested in further reading on this, see https://en.wikipedia.org/wiki/Temporary_folder
This is not really a good answer in my opinion. There's no explanation and it's likely to not work if `/tmp` doesn't have the right permissions. It even contradicts with the accepted answer (which is not great on its own either).
I don't think the answer requires much explanation, I'd say that how the $conf variable works in settings.php is general knowledge for Drupal developers. One of the nice things about this answer is that it's concise. I'm not sure that it contradicts the accepted answer, the accepted answer will work and this is an alternative. The difference between this method and doing it through the UI is that this will work across multiple environments, but you would have to set it individually in the UI for each environment.
It's important to understand that a permissions problem can exist in BOTH your specified temporary directory (which is defined at admin/config/media/file-system) AND at the folder where that temporary file is going to be copied. I've seen this error a few times and it's usually not an issue with the temporary folder, but the final folder where that file is copied after living in the temp folder.
Also ensure that the public file system path is set correctly.
This was the case for me. In my case, I needed to set the ownership of the newly-created /sites/default/files directory to USERNAME:apache (on some systems that group would be called nobody).
I had this exact problem and made sure to use relative path (sites/default/files/tmp) for my tmp folder location as suggested and i also changed the permissions on the tmp folder to ensure it was writable by apache but my problem still existed. so i decided to check the log messages(Reports>>Recent log messages) to see if i could get a better understanding of what the problem was. By doing this i got a more specific message:
The file permissions could not be set on public://js.
This prompted me to check the permissions on the js folder in sites/default/files and as it turns out apache could not write to it so by changing the permissions to 775 on that folder i got rid of my error message. So i would suggest that you check the permissions for all the sub-folders in sites/default/files and not only the tmp folder if you have not solved your problem as yet. Just thought i would share this info.
My issue was the same as this but I use the following to correct it: sudo chgrp -R www-data /var/www/mysite
Assuming you're combining `sudo chgrp -R www-data /var/www/mysite` with _"changing the permissions to 775"_. This is **NOT** needed. Drupal does not need to write to _every_ folder. Only your public, private and tmp files folders.
Yes - the crucial thing here, that no other answer is mentioned, is finding the **destination** directory (typically somewhere under sites/default/files - /css and /js are prime candidates if you have JS/CSS concatenation turned on) and you can only get that by viewing the log.
The error message can somteimes be misleading
If it says the problem is to do with the destination directory, the apache probably doesn't have the permissions to write to the sites/default/files subfolder that Drupal wants tot put the file in.
A good solution is to make the apache user the owner of all files and directories under sites/default/files
cd /path/to/sites/default sudo chown -R _www:_www files
Or something similar should reslove destination directory issues. Double check that the owner has write and execute permissions on all subdirectories.
The files directory: Troubleshooting Apache-based Web Servers
If the directory files is not "owned" by the Web server there are two ways to proceed. These instructions assume you have shell access to the Web server. If you do not have shell access, please contact your hosting provider for additional support.
Ideally you will be able to change the "owner" of the directory files to match the name of the Web server. On a Unix or Linux-based server you may verify "who" the Web server is running as by issuing the following commands:
$ ps aux |grep apache # for Apache 2.x $ ps aux |grep httpd # for Apache 1.x
Depending on your Web server one of these commands will return a series of lines like this:
www-data 13612 0.1 0.9 50640 20340 ? S 12:29 0:08 /usr/sbin/apache2 -k start
The first column in the returned text is the "user" that your Web server is operating as. In this case the user is www-data. To make your files directory writeable by the Web server you need to reassign its ownership using the following command:
$ chown -R www-data sites/default/files $ chmod -R 0700 sites/default/files
If you do not have sufficient permissions on your server to change the ownership of the folder, the next best option is to provide group-write access to the folder with the following command:
$ chmod -R 0770 sites/default/files
You should also be able to adjust the directory's permissions using an FTP program as outlined above.
Once you've completed these steps confirm the appropriate permissions have been assigned by navigating to Administer -> Reports -> Status report. Scroll to the section labelled, "File system" and confirm your settings are now correct.
Source: The files directory
In some situations this can be easily fixed by deleting the 'ctools' and 'js' folders within default/files. These folders are recreated by the system if needed. Sometimes when making a new install of an existing site these folders existing already cause problems. Also if your CSS isn't working after making a new install of an existing site this can also be fixed by deleting these files and letting drupal recreate them.
If you run across this problem using Pantheon and continue to get the error after setting the (temp) files directory path(s), you may also need to switch the Connection mode on your dev instance dashboard from Git to SFTP.
Your Drupal site may be attempting to save files to a directory managed by Git (e.g. if you are changing layout settings and the like in an Adaptive Themes theme). In order to do so, switch to SFTP. Once the files have been saved, you can switch back to Git, and the dashboard will prompt you to commit the changes that have been made on the server.