diff --git a/server/conf/php-cgi-starter.master b/server/conf/php-cgi-starter.master
index be309932210ff16b8540e960b208a8562db50a77..03d0554a5754ddf8c80ecdfef9a3dfcbf6994a02 100644
--- a/server/conf/php-cgi-starter.master
+++ b/server/conf/php-cgi-starter.master
@@ -4,6 +4,10 @@
 export PHPRC="<tmpl_var name='php_ini_path'>"
 </tmpl_if>
 
+export TMP=<tmpl_var name='document_root'>/tmp
+export TMPDIR=<tmpl_var name='document_root'>/tmp
+export TEMP=<tmpl_var name='document_root'>/tmp
+
 exec <tmpl_var name='php_cgi_bin'> \
 -d open_basedir=<tmpl_var name='open_basedir'> \
 -d upload_tmp_dir=<tmpl_var name='document_root'>/tmp \
diff --git a/server/conf/php-fcgi-starter.master b/server/conf/php-fcgi-starter.master
index 92edf86c53089898fcd1805bf0d8f4424a7dd60e..679f1b21ab8931f800fe0ee319cbc70d49630a8c 100644
--- a/server/conf/php-fcgi-starter.master
+++ b/server/conf/php-fcgi-starter.master
@@ -9,6 +9,9 @@ export PHP_DOCUMENT_ROOT
 # export PHP_FCGI_CHILDREN
 PHP_FCGI_MAX_REQUESTS=<tmpl_var name='php_fcgi_max_requests'>
 export PHP_FCGI_MAX_REQUESTS
+export TMP=<tmpl_var name='document_root'>/tmp
+export TMPDIR=<tmpl_var name='document_root'>/tmp
+export TEMP=<tmpl_var name='document_root'>/tmp
 exec <tmpl_var name='php_fcgi_bin'> \
 <tmpl_if name="security_level" op="==" value="20"> -d open_basedir="<tmpl_var name='open_basedir'>" \
 -d disable_functions="" \
diff --git a/server/conf/php_fpm_pool.conf.master b/server/conf/php_fpm_pool.conf.master
index 7f5c8e13c77261d941052dd34e452f36200f32e1..d7a34786f1f54531aa893abd6aa40c251f65148f 100644
--- a/server/conf/php_fpm_pool.conf.master
+++ b/server/conf/php_fpm_pool.conf.master
@@ -28,6 +28,10 @@ pm.max_requests = <tmpl_var name='pm_max_requests'>
 
 chdir = /
 
+env[TMP] = <tmpl_var name='document_root'>/tmp
+env[TMPDIR] = <tmpl_var name='document_root'>/tmp
+env[TEMP] = <tmpl_var name='document_root'>/tmp
+
 <tmpl_if name='security_level' op='==' value='20'>
 <tmpl_var name='enable_php_open_basedir'>php_admin_value[open_basedir] = <tmpl_var name='php_open_basedir'>
 php_admin_value[session.save_path] = <tmpl_var name='document_root'>/tmp
diff --git a/server/conf/vhost.conf.master b/server/conf/vhost.conf.master
index 955b18a31add0733c928eccfbc9bb4b9d52c16aa..e7a50356a129b938251964d442ed7b707e8065c9 100644
--- a/server/conf/vhost.conf.master
+++ b/server/conf/vhost.conf.master
@@ -204,6 +204,9 @@
 <tmpl_if name='php' op='==' value='mod'>
 		# mod_php enabled
 		AddType application/x-httpd-php .php .php3 .php4 .php5
+		SetEnv TMP <tmpl_var name='document_root'>/tmp
+		SetEnv TMPDIR <tmpl_var name='document_root'>/tmp
+		SetEnv TEMP <tmpl_var name='document_root'>/tmp
 		php_admin_value sendmail_path "/usr/sbin/sendmail -t -i -fwebmaster@<tmpl_var name='domain'>"
 		php_admin_value upload_tmp_dir <tmpl_var name='document_root'>/tmp
 		php_admin_value session.save_path <tmpl_var name='document_root'>/tmp