Difference between revisions of "Uploadtmpdir"

From SME Server
Jump to navigationJump to search
(Created page with "=== upload_tmp_dir === Since SME Server V8, you could have sometime an error is thrown by PHP and you will need to specify a temporary directory (e.g. upload_tmp_dir) which ...")
 
 
(14 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
{{Warning box| this information is outdated and incompatible with SME10. Please refer to [[PHP]] page }}
 +
 
=== upload_tmp_dir ===
 
=== upload_tmp_dir ===
  
Line 5: Line 7:
 
An easy way is to make a Custom Template to resolve this issue.
 
An easy way is to make a Custom Template to resolve this issue.
  
 +
=== Template of php.ini ===
 +
{{Note box|With this configuration, It appears that the tmp folder is set for all web applications on your server. For a better matter of security it is preferable to set each virtual host of your httpd server. See [[Uploadtmpdir#Template of httpd.conf]]}}
  
  mkdir /etc/e-smith/templates-custom/etc/php.ini/               
+
  mkdir -p /etc/e-smith/templates-custom/etc/php.ini/               
 
  nano /etc/e-smith/templates-custom/etc/php.ini/12phptmpfolder
 
  nano /etc/e-smith/templates-custom/etc/php.ini/12phptmpfolder
  
Line 21: Line 25:
 
  rm -rf /etc/e-smith/templates-custom/etc/php.ini/
 
  rm -rf /etc/e-smith/templates-custom/etc/php.ini/
 
and
 
and
 +
signal-event console-save
 +
 +
=== Template of httpd.conf ===
 +
{{Note box|With this configuration, It appears that the tmp folder will be set only for this web application and not for all other virtual host. It is a better matter for security, but in the example below the tmp folder is the /tmp which is used by all. You should create your own tmp/ in the application folder, see [[Uploadtmpdir#Specify_the_application_tmp_folder]]}}
 +
You can do the same thing by adding the following in the httpd.conf template of your contrib or special apache virtual host.
 +
php_admin_value upload_tmp_dir /tmp
 +
 +
with [[Web_Application_RPM]] the special line to put in the config of your virtual host is
 +
$OUT .= "    php_admin_value upload_tmp_dir /tmp\n";
 +
 +
Example for /etc/e-smith/templates/etc/httpd/conf/httpd.conf/92foo
 +
$OUT .= "    php_value mysql.default_user $foo{DbUser}\n";
 +
$OUT .= "    php_value mysql.default_password $foo{DbPassword}\n";
 +
'''$OUT .= "    php_admin_value upload_tmp_dir /tmp\n";'''
 +
if ($pass)
 +
{
 +
 +
and then do
 +
 +
signal-event console-save
 +
====Specify the application tmp folder ====
 +
or you can make a folder /tmp in the path of the foo application (example /opt/foo/tmp)
 +
 +
Example for /etc/e-smith/templates/etc/httpd/conf/httpd.conf/92foo
 +
$OUT .= "    php_value mysql.default_user $foo{DbUser}\n";
 +
$OUT .= "    php_value mysql.default_password $foo{DbPassword}\n";
 +
'''$OUT .= "    php_admin_value upload_tmp_dir /opt/foo/tmp\n";'''
 +
if ($pass)
 +
{
 +
 +
and then do
 +
 
  signal-event console-save  
 
  signal-event console-save  
  
 +
If you want to erase this setting you have to remove the file and the folder if necessary
 +
rm /etc/e-smith/templates/etc/httpd/conf/httpd.conf/92foo
 +
and
 +
signal-event console-save
 +
 +
=== Template of Ibays ===
 +
 +
As php file_upload is on, but the default upload_tmp_dir (/tmp) is not included in the default open_basedir for security reasons, why not create a tmp folder for each ibay and set that as the upload_tmp_dir for each ibay? [[bugzilla:7011]]<br />
 +
 +
In a near future this ability will be in the default configuration of smeserver.
 
[[Category:Howto]]
 
[[Category:Howto]]
 +
[[Category:developer]]

Latest revision as of 00:11, 25 April 2022

Warning.png Warning:
this information is outdated and incompatible with SME10. Please refer to PHP page


upload_tmp_dir

Since SME Server V8, you could have sometime an error is thrown by PHP and you will need to specify a temporary directory (e.g. upload_tmp_dir) which is not set in php.ini. see bugzilla:6650 and bugzilla:7652. Many Php applications needs this setting, most of known are wordpress, roudcube, egroupware, etc. Symptoms are that you can't upload contents to the PHP application.

An easy way is to make a Custom Template to resolve this issue.

Template of php.ini

Important.png Note:
With this configuration, It appears that the tmp folder is set for all web applications on your server. For a better matter of security it is preferable to set each virtual host of your httpd server. See Uploadtmpdir#Template of httpd.conf


mkdir -p /etc/e-smith/templates-custom/etc/php.ini/              
nano /etc/e-smith/templates-custom/etc/php.ini/12phptmpfolder

then paste this and save the file by ctrl+x

upload_tmp_dir = /tmp

and then do

signal-event console-save 

If you want to erase this setting you have to remove the file and the folder if necessary

rm /etc/e-smith/templates-custom/etc/php.ini/12phptmpfolder
rm -rf /etc/e-smith/templates-custom/etc/php.ini/

and

signal-event console-save

Template of httpd.conf

Important.png Note:
With this configuration, It appears that the tmp folder will be set only for this web application and not for all other virtual host. It is a better matter for security, but in the example below the tmp folder is the /tmp which is used by all. You should create your own tmp/ in the application folder, see Uploadtmpdir#Specify_the_application_tmp_folder


You can do the same thing by adding the following in the httpd.conf template of your contrib or special apache virtual host.

php_admin_value upload_tmp_dir /tmp

with Web_Application_RPM the special line to put in the config of your virtual host is

$OUT .= "    php_admin_value upload_tmp_dir /tmp\n";

Example for /etc/e-smith/templates/etc/httpd/conf/httpd.conf/92foo

$OUT .= "    php_value mysql.default_user $foo{DbUser}\n";
$OUT .= "    php_value mysql.default_password $foo{DbPassword}\n";
$OUT .= "    php_admin_value upload_tmp_dir /tmp\n";
if ($pass)
{

and then do

signal-event console-save 

Specify the application tmp folder

or you can make a folder /tmp in the path of the foo application (example /opt/foo/tmp)

Example for /etc/e-smith/templates/etc/httpd/conf/httpd.conf/92foo

$OUT .= "    php_value mysql.default_user $foo{DbUser}\n";
$OUT .= "    php_value mysql.default_password $foo{DbPassword}\n";
$OUT .= "    php_admin_value upload_tmp_dir /opt/foo/tmp\n";
if ($pass)
{

and then do

signal-event console-save 

If you want to erase this setting you have to remove the file and the folder if necessary

rm /etc/e-smith/templates/etc/httpd/conf/httpd.conf/92foo

and

signal-event console-save

Template of Ibays

As php file_upload is on, but the default upload_tmp_dir (/tmp) is not included in the default open_basedir for security reasons, why not create a tmp folder for each ibay and set that as the upload_tmp_dir for each ibay? bugzilla:7011

In a near future this ability will be in the default configuration of smeserver.