You can host your Moodle site on Microsoft Windows Server. The key to this is configuring PHP for use with Microsoft Internet Information Server (IIS). In this blog post we cover one issue we often encounter: configuring PHP’s upload_tmp_dir setting so that your server’s disk space isn’t filled with temporary files.


According to the PHP documentation this setting is the “temporary directory used for storing files when doing file upload. Must be writable by whatever user PHP is running as”.

On Microsoft Windows if this isn’t set then Windows Server’s default location is used: C:\Windows\Temp. As this location is writable it fits PHP’s criteria and when uploading a file to Moodle a temporary file is created here. When the upload completes it should then be copied to the Moodledata folder and the temporary file removed.

Default location and default permissions

IIS accesses files as a specific user account, IUSR by default, and whilst this user can write files to C:\Windows\Temp it can’t delete them. Consequently Moodle sites running on IIS often have a large number of old php*.tmp files left behind in this directory.

The solution

There are two ways to address this. The first is to make the default location, C:\Windows\Temp, modifyable by the IIS user. As Windows Server displays a warning if you do this I favour the second method.

The second method is to create a directory for upload_tmp_dir with the required permissions. I create this in C:\Inetpub\Temp, i.e. C:\Inetpub\Temp\upload_tmp_dir, and then add the IIS user to its ACL and allow Modify permission.

Then update php.ini setting upload_tmp_dir to this location.

Then restart IIS to apply the change (not needed if you’ve configured Monitor changes to file) and afterwards files uploaded to Moodle should be created in this new directory and — more importantly — deleted afterwards. You can upload a file to Moodle as a test and make sure there’s no corresponding file created in the old location, and that there’s no file left behind in the new location.

You can also delete the redundant php*.tmp files from C:\Windows\Temp.


The default PHP setting upload_tmp_dir should be explicitly configured when hosting Moodle on Windows Server with IIS to a location with the required permissions to avoid a build-up of temporary files. We’ve worked with Moodle on Microsoft Windows for many years and have encountered and resolved various issues on this platform. If you’d like to apply our expertise to your systems, please get in touch!

About This Author

Leon Stringer

Leon had been working in IT for over 25 years starting out with connectivity systems for ICL mainframes. He also worked for an NHS trust in the West Midlands for nine years but doesn’t like to talk about this. He first encountered Moodle in 2011...