Wordpress on Plesk Missing a temporary folder

The Issue

My hosting provider recently moved my WordPress environment between Servers and since then when attempting to upload images to my blog posts I got the dreaded, “Missing a temporary folder” message.

This is a windows host, shared hosting on plesk.

What the internet says

The internet says its an easy fix.

  1. Find your wp-config.php file
  2. Add the following line above /* That’s all, stop editing! Happy publishing. */
  3. Everything should work
define('WP_TEMP_DIR', dirname(__FILE__) . '/wp-content/temp/');

For me this did not work!

Trouble shooting

So, to see what was actually going on I wanted to see the PHP logs.

To do this I have the following section in my wp-config.php

//Enable debug lines when having issues
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', true);
define( 'SCRIPT_DEBUG', true );

With this on, I attempted my file upload and again got the “Missing a temporary folder” error.

On my plesk server the log location for my php errors was .\logs\php_errors\ntsblog.homedev.com.au\php_error.log

Looking in the log I found the following message..
PHP Warning: PHP Request Startup: open_basedir restriction in effect. File(C:\Users\IWAM_P~1\AppData\Local\Temp) is not within the allowed path(s): (C:\inetpub\vhosts\homedev.com.au\;C:\Windows\Temp) in Unknown on line 0

The fix

So it appears that WordPress is trying to open the %LOCALAPPDATA% path, which is for the Plesk User that is running the wordpress website that it does not have as a valid path.

On searching this open_basedir issue, it said you could set this in the php.ini file.

Hmm, on shared hosting I don’t have access to the php.ini file. A quick search on how to override the php.ini file suggests that from PHO >= 5.3 you can override in a sub-directory with a user.ini file.

So in the root of the WordPress site create a new file called user.ini and add I added this content:

[PHP]
open_basedir="C:/Inetpub/vhosts/homedev.com.au\;C:\Windows\Temp\;C:\Users\IWAM_P~1\AppData\Local\Temp"

Save this file.

Refresh your page and try again, and it is fixed.

Final Notes

It would appear that I had hit similar issues in the past as the user.ini file actually already existed. I think the c:\Windows\Temp was probably what was happing on the previous host, hence why the open_basedir line was already there as you could see from the original logged error message.

My full file looked like this.

[PHP]
open_basedir="C:/Inetpub/vhosts/homedev.com.au\;C:\Windows\Temp\;C:\Users\IWAM_P~1\AppData\Local\Temp"
error_reporting=22519
error_log="C:\Inetpub\vhosts\homedev.com.au\logs\php_errors\ntsblog.homedev.com.au\php_error.log"

The error_log entry is why my logfile sits where it does. The hard coded error_reporting code is related to PHP error logging, I don’t remember 🙂
Cheers

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.