Hi. How can we help?

PHP Configuration Problems

Last updated: 16 June 2022

Dealing with large files

PHP Settings

To handle large file uploads you need to adapt the following PHP settings. The value should be the size of largest file you wish to upload, for example if you want to upload files as large as 50MB you need the following settings.

  1. upload_max_filesize: 50MB
  2. post_max_size: 51MB
  3. memory_limit: 55MB
  4. max_input_time: -1 (default) or a very high value example 600 (10 minutes)

You need to make sure that memory_limit is larger then post_max_size which should be slightly larger then upload_max_filesize.

Not all hosts allow to change PHP configuration values through php.ini files or .htaccess files. Sometimes only some items can be changed and others can't.

For example, your PHP memory limit is set to 8M, but you want to double that. In your .htaccess file, you have this line: php_value memory_limit 16M

To make sure a change you made is actually making any difference, you can use Joomla's System Info (Help > System Info > PHP Information).

Now search for memory_limit on that page. In the 'Master Value' column on the right, you see the original value of 8M. In the left 'Local Value' column, you see the actual value. If this isn't your new value of 16M, then your host doesn't support overriding this value. You'll have to ask your host to change it.

Some resources on how to set up PHP to allow large uploads:

Joomla Settings

Make sure Joomla's sessions lifetime is long enough to allow for large (or slow) uploads.

  1. Global Configuration
  2. System tab
  3. Set 'Session Lifetime'

A good value is at least 30min, if you are dealing with large uploads.

Temporary folder

PHP uploads files to it's temporary directory as specified by the upload_tmp_dir setting. The directory must be writable by whatever user PHP is running as. If not specified PHP will use the system's default.

In Unix, the /tmp directory will often be a separate disk partition, often the size of the partition is 16MB. When you are trying to upload large files make sure this partition is big enough, or change your upload_tmp_dir settings to point to a different directory.

Please be aware that if the directory specified in upload_tmp_dir is not writable, PHP falls back to the system default temporary directory. If open_basedir is on, then the system default directory must be allowed for an upload to succeed.

Web server

Depending on which web server you are using, you might need to change the configuration as well to allow large file uploads. If you are unsure which type of server you are running or how to modify its configuration, ask your web host to change it.

Apache

The Apache webserver has a LimitRequestBody configuration directive that restricts the size of all POST data regardless of the web scripting language in use. You will need to change this to a larger value or remove the entry altogether.

More changes may be needed depending on how Apache talks to PHP:

  • Apache with mod_fcgid: Set the FcgidMaxRequestLen value to a high enough value.

Nginx

You need to increase the client_max_body_size directive in your Nginx configuration.

Changing PHP memory limits

There are a number of ways to increase the PHP memory limit on your server, however you only need to use one of these techniques dependant on your server's configuration.

The typical memory limit for running a Joomla site on your server might be 128MB, but for sites that use a lot of extensions or with high memory pages you might find that 256MB is a more appropriate upper limit.

The relationship between scalability and PHP memory limit

An increase in the amount of memory that each PHP process can use will lead to a decrease in the maximum number of concurrent process that the server can run. The maximum number of page request that a server can process at any one time is linked to the number of concurrent processes that are running, the more processes that are running the less page requests that can be served.

The following example is for a server with 4GB of available memory for PHP processes (after accounting for the server's other processes such as the operating system, Apache, etc.)

PHP memory limit 128MB 256MB 512MB
Maximum number of concurrent processes 32 16 8

How to change PHP memory limits

Your web server's PHP.ini

If you have access to the server's PHP ini file then this is the recommended approach for changing the PHP memory limit. This method may not be possible for some shared hosting environments, although the hosting provider might be able to make the adjustment for you. In all cases this method will affect all websites running on the server.

  1. Find the server's php.ini file
  2. Look for the PHP memory limit memory_limit = 55M; Maximum amount of memory a script may consume (55MB) Note always use "M" to specify the number of megabytes, not "MB". If the memory limit line is not already present in your PHP.ini file then add it at the end of the file.
  3. Restart Apache

If PHP is running as CGI/FastCGI

If PHP is running on your server as CGI/FastCGI then you can add a php.ini file to your Joomla root folder. Add the following line to this php.ini file: memory_limit = 55M

PHP 5.3 and up

PHP 5.3+ allows you to change the memory limit by placing a .user.ini file in the website's public_html folder, some cPanel hosts will only allow this method.Add the following line to this .user.ini file: memory_limit = 55M

.htaccess

This method only worls if PHP is running as an Apache module on your server.

Edit the .htaccess file in the Joomla root folder and add the following line at the end of the file: php_value memory_limit 55M

Shared hosting environments

Access to the PHP memory limit setting is restricted in some shared hosting environments. If you cannot make adjustments to the php.ini file yourself, please ask your hosting provider to make the adjustment for you.

Modifying php.ini in XAMPP/WAMP or MAMP

If you are running XAMPP or WAMP as your localhost server then there may be two php.ini files, one in the PHP directory and the other in the Apache/bin directory. To change the memory limit edit the php.ini file that is found in the Apache/bin directory.

If you are running MAMP or MAMP Pro as your localhost then the php memory limit will be set at the PHP default of 8MB. To adjust the memory limit open the php.ini file and change the limit in the following line: memory_limit = 8M ; Maximum amount of memory a script may consume (8MB)

You will find the php.ini file in the /Applications/MAMP/conf/php5/ directory and/or in the /Applications/MAMP/conf/php7/ directory.

In MAMP Pro you don't edit the php.ini file directly as it is rewritten each time the server starts up. To edit the php memory limit for MAMP Pro please edit the appropriate template instead (File > Edit Template > ...)

Test that your changes worked

Whenever you make a change to your php.ini file you can check that the changes worked by visiting your Joomla site's admin area and selecting the PHP Information tab from System > System Information in the top menu. On the PHP Information tab look for the row that contains the memory_limit information.

Increase file upload size

The maximum upload file size of a single attachment is either the post_max_size or upload_max_filesize, whichever is smaller. The default PHP values are 8 MB for post_max_size, and 2 MB for upload_max_filesize. Changing these two values can be done in you server's php.ini file or your Joomla root folder's .htacces file, depending on your server's configration.

To increase these values in the php.ini file find the following lines and increase the values:

upload_max_filesize = 50M
post_max_size = 51M<br>

To increase these values in the Joomla root folder's .htacces file add the following lines at the end of the file:

php_value upload_max_filesize 50M
php_value post_max_size 51M

Increasing the PHP upload size is not the same as increasing the PHP memory limit.

PHP's documentation states that the memory_limit setting also affects file uploading. In general, memory_limit should be larger than post_max_size