Linux – Apache places uploaded files in /tmp. Can I change that to another directory

apache-2.2fileslinuxupload

Is there a configuration that changes the directory where apache web server temporarily places uploaded files? I have access to httpd/conf.d

I'm on a machine where /tmp is very size constrained and have a requirement to allow file uploads that are larger than the available space on /tmp.

Environment: fedora 18, apache web server 2.4.6-2, passenger and ruby on rails.

EDIT: there's some discussion around the office that it's passenger (because this is a ruby on rails app) not apache that determines the location of the temporary file upload. I'm going under the assumption that it's apache but please correct me if I'm wrong.

Best Answer

The temporary file location seems to be set by the scripting program that you choose. In PHP, for example, the temporary upload location is set by the upload_temp_dir directive.

upload_temp_dir = /somewhere/else

As far as Ruby on Rails goes, I found this ServerFault question that describes it as a change to the 'tmpdir' property of Rails' initializer object.

class Dir
  def self.tmpdir
    "/your_directory/"
  end
end

To parrot the user who answered this question in the other thread, make sure that the folder you specify is writable by the user for Apache.