Cara menggunakan php ini sys_temp_dir

I am new to PHP frameworks having only ever created simple apps from scratch using my non-conformed and somewhat hectic standards. I read up about oven.php and am keen to see what it is made of.

Whilst installing it I had a few issues that I have solved however, there is a warning I can’t get rid of. It is not fatal from what I can see but I am keen to make good.

If you’re expecting big file uploads, some considerations have to be taken into account. Setups based on your needs can be configured.

General Considerations

  • Make sure that a version of PHP supported by ownCloud is installed.

  • Consider that user quotas may prevent big file uploads due to a user reaching the space limitation.

  • Though ownCloud already disables the PHP setting Output Buffering in the shipped

    PrivateTmp=false
    3 and
    PrivateTmp=false
    4 to prevent PHP memory-related errors, it can be the case that you must manually set it in your
    PrivateTmp=false
    5 or
    PrivateTmp=false
    6 when the other two configuration files can’t be used in your environment.

  • The directory used for

    PrivateTmp=false
    7 must be fully accessible by PHP / the webserver user, usually
    PrivateTmp=false
    8.

  • Your temp directory or partition has to be big enough to hold multiple parallel uploads from multiple users. The formula for this is

    PrivateTmp=false
    9
    For example, if the chunk size is 10MB (which is the default but might vary between different clients) and the average number of users uploading at the same time is 25, then you’ll need 250MB of temp space, as the formula below shows.

    10MB x 25 users = 250MB required temp space

  • The user’s upload directory, usually in

    sudo systemctl daemon-reload
    sudo systemctl restart httpd
    0 (see for details) also has to be big enough. The formula is a bit different, as this directory collects all chunks of a file for that upload for that user until the upload is completed. The space needed for this directory is temporarily the same size as for the final file size. As an example, if a user wants to upload a 4GB file, temporarily 4GB of space needs to be available in the upload directory to hold the chunks. When the upload has finished, all chunks are written to the final destination and the chunks are deleted afterwards freeing that temporary space. The formula for the upload directory’s temp space for all users is:
    sudo systemctl daemon-reload
    sudo systemctl restart httpd
    1. The location of the upload directory can be defined via the config setting .

The space temporarily consumed in the upload directory will not count against the user quota. If a user has no quota left in his peronal storage and the quota excludes external mounts, uploads to a windows network drive share as example will succeed. The file temporarily created in the upload directory will not count against his personal storage.

  • In Centos and RHEL, Apache has a few more default configurations within systemd.

    You will have to set the

    sudo systemctl daemon-reload
    sudo systemctl restart httpd
    2 directory in two places:

    1. In php.ini, e.g.,

      sudo systemctl daemon-reload
      sudo systemctl restart httpd
      3

    2. In Apache systemd file e.g.

      sudo systemctl daemon-reload
      sudo systemctl restart httpd
      4 and change/add:

      PrivateTmp=false

    When done, you need to reload the daemon and restart the service:

    sudo systemctl daemon-reload
    sudo systemctl restart httpd

    Please do not change

    sudo systemctl daemon-reload
    sudo systemctl restart httpd
    5 directly, only use
    sudo systemctl daemon-reload
    sudo systemctl restart httpd
    4. If not doing so, a httpd package upgrade may revert your changes.

Configuration via .htaccess/user.ini

ownCloud comes with its own

sudo systemctl daemon-reload
sudo systemctl restart httpd
7 file. When using
sudo systemctl daemon-reload
sudo systemctl restart httpd
8, PHP settings in
PrivateTmp=false
3 are not accessed. These settings must then be set in the
PrivateTmp=false
4 file.
sudo systemctl daemon-reload
sudo systemctl restart httpd
8 will read settings from any .user.ini file in the same directory as the .php file that is being served via a web server.

Set the following parameters inside the corresponding file using your own desired values, as in the following examples, both files are located in the ownCloud root folder:

.user.ini

post_max_size=16G
output_buffering=0
upload_max_filesize=16G
upload_tmp_dir=/mnt/php_big_temp/

.htaccess

php_value	post_max_size=16G
php_value	output_buffering=0
php_value	upload_max_filesize=16G
php_value	upload_tmp_dir=/mnt/php_big_temp/

If you see PHP timeouts in your log files, increase the timeout values, which are in seconds, as in the example below. Use the

post_max_size=16G
output_buffering=0
upload_max_filesize=16G
upload_tmp_dir=/mnt/php_big_temp/
2 prefix like above when configuring the
PrivateTmp=false
3 file:

max_input_time=3600
max_execution_time=3600

Consider that any settings made in

PrivateTmp=false
3 or
PrivateTmp=false
4 may need to be repopulated after an upgrade of ownCloud.

Configuring via PHP Global Settings

If you don’t want to use the ownCloud

PrivateTmp=false
3 or
PrivateTmp=false
4 file, you may configure PHP globally instead. Make sure to comment out or remove any lines in
PrivateTmp=false
3 if you added any like in the section above.

If you are running ownCloud on a 32-bit system, any

post_max_size=16G
output_buffering=0
upload_max_filesize=16G
upload_tmp_dir=/mnt/php_big_temp/
9 directive in your
PrivateTmp=false
5 file needs to be commented out.

See the Loaded Configuration File section of to find your relevant php.ini files.

Set the following parameters inside the corresponding php.ini file using your own desired file size values, as in the following example:

post_max_size=16G
output_buffering=0
upload_max_filesize=16G
upload_tmp_dir=/mnt/php_big_temp/

If you see PHP timeouts in your log files, increase the timeout values, which are in seconds, as in the example below:

max_input_time=3600
max_execution_time=3600

Configuring via a Virtual Host

You can configure php parameters also per virtual host - if you have access to the Apache configuration file. This eliminates the need to maintain custom settings in a

PrivateTmp=false
4 or
PrivateTmp=false
3 file especially on upgrades. Note the mandatory prefix
php_value	post_max_size=16G
php_value	output_buffering=0
php_value	upload_max_filesize=16G
php_value	upload_tmp_dir=/mnt/php_big_temp/
3 before the php parameter.

<VirtualHost *:443>

	DocumentRoot /var/www/owncloud
	ServerName myowncloud.com

	php_admin_value	post_max_size 16G
	php_admin_value	output_buffering 0
	php_admin_value	upload_max_filesize 16G
	php_admin_value	upload_tmp_dir /mnt/php_big_temp/

	...

If you see PHP timeouts in your log files, increase the timeout values, which are in seconds, as in the example below:

php_admin_value max_input_time 3600
php_admin_value max_execution_time 3600

Configuring via ownCloud

As an alternative to the

PrivateTmp=false
7 of PHP (e.g., if you don’t have access to your
PrivateTmp=false
5) you can also configure some parameters in
php_value	post_max_size=16G
php_value	output_buffering=0
php_value	upload_max_filesize=16G
php_value	upload_tmp_dir=/mnt/php_big_temp/
6.

  • Set a temporary location for uploaded files by using the

    php_value	post_max_size=16G
    php_value	output_buffering=0
    php_value	upload_max_filesize=16G
    php_value	upload_tmp_dir=/mnt/php_big_temp/
    7 setting.

  • If you have configured the

    php_value	post_max_size=16G
    php_value	output_buffering=0
    php_value	upload_max_filesize=16G
    php_value	upload_tmp_dir=/mnt/php_big_temp/
    8 setting in your
    php_value	post_max_size=16G
    php_value	output_buffering=0
    php_value	upload_max_filesize=16G
    php_value	upload_tmp_dir=/mnt/php_big_temp/
    6, see Sample Config PHP Parameters, make sure it is not too low. This setting needs to be configured to at least the time (in seconds) that the longest upload will take. If unsure, remove this entirely from your configuration to reset it to the default shown in the
    max_input_time=3600
    max_execution_time=3600
    0.

General Upload Issues

Various environmental factors could cause a restriction of the upload size. Examples are:

  • The

    max_input_time=3600
    max_execution_time=3600
    1 of
    max_input_time=3600
    max_execution_time=3600
    2 which sets an
    max_input_time=3600
    max_execution_time=3600
    3.

  • Some services like

    max_input_time=3600
    max_execution_time=3600
    4 are also known to cause uploading issues.

  • Upload limits enforced by proxies used by your clients.

  • Other web server modules like described in General Troubleshooting.

Apache Directives

Apache with mod_reqtimeout

The mod_reqtimeout Apache module could also stop large uploads from completing. If you’re using this module and uploads of large files fail, either disable it in your Apache config or increase the configured

max_input_time=3600
max_execution_time=3600
5 values.

Disable mod_reqtimeout on Ubuntu

On Ubuntu, you can disable the module by running the following command:

PrivateTmp=false
0

Disable mod_reqtimeout on CentOS

On CentOS, comment out the following line in

max_input_time=3600
max_execution_time=3600
6:

PrivateTmp=false
1

When you have run

max_input_time=3600
max_execution_time=3600
7 or updated
max_input_time=3600
max_execution_time=3600
6, restart Apache.

There are also several other configuration options in your web server config which could prevent the upload of larger files. Refer to your web server’s manual for how to configure those values correctly:

Apache with mod_fcgid

If you are using Apache 2.4 with mod_fcgid, as of February/March 2016,

max_input_time=3600
max_execution_time=3600
9 still needs to be significantly increased from its default value to avoid the occurrence of segmentation faults when uploading big files. This is not a regular setting but serves as a workaround for Apache with mod_fcgid bug #51747.

Setting

max_input_time=3600
max_execution_time=3600
9 significantly higher than usual may no longer be necessary, once bug #51747 is fixed.

Long-Running Uploads

For very long-running uploads those lasting longer than 1h to public folders, when chunking is not in effect,

post_max_size=16G
output_buffering=0
upload_max_filesize=16G
upload_tmp_dir=/mnt/php_big_temp/
1 should be set to a significantly large value in
php_value	post_max_size=16G
php_value	output_buffering=0
php_value	upload_max_filesize=16G
php_value	upload_tmp_dir=/mnt/php_big_temp/
6. If not, large file uploads will fail with a file locking error, because the Redis garbage collection will delete the initially acquired file lock after 1 hour by default.

To estimate a good value, use the following formula:

PrivateTmp=false
2

For the value of "slowest assumed upload connection", take the upload speed of the user with the slowest connection and divide it by two. For example, let’s assume that the user with the slowest connection has an 8MBit/s DSL connection; which usually indicates the download speed. This type of connection would, usually, have 1MBit/s upload speed (but confirm with the ISP). Divide this value in half, to have a buffer when there is network congestion, to arrive at 512KBit/s as the final value.