Make Custom PHP Changes Using A .user.ini File

Programming, error messages and sample code > PHP
At times, you will want to use software that requires a custom php.ini file or custom PHP configuration changes such as increasing the memory limit or upload limit that your site is allowed. Since these are settings that we can not change on a server-wide basis, you would need to make these changes locally on your account. Fortunately, with these easy-to-follow steps, you can have a .user.ini file created and customized within minutes!
 
Please note: This would mean, for example, if you were to create the .user.ini within www/site1, the changes are applied to the software that is installed in that particular folder only. Any subsequent PHP installations such as WordPress in a www/site1/blog/ folder, wouldn’t be affected by said changes. In order to apply changes to subsequent subfolders within a directory, a separate .user.ini is necessary for each directory.
 
  • You can create a .user.ini file on your local with notepad++, Be sure to include the dot before “user” in the filename. You’ve now created your .user.ini file and all of your custom PHP configuration changes added to the file will be used by your website! Below are some of the most common lines that are altered when making custom PHP changes.
 
 
  • memory_limit
  • upload_max_filesize
  • post_max_size
  • max_execution_time
  • max_input_time
  • register_globals
  • magic_quotes_gpc

Changing Your Memory Limit

 

This guide will show you how to increase the memory limit in PHP. While we don’t have a technical limit on how high you can set the php memory limit, we highly recommend that you not exceed your plan pool size.

If your .user.ini file is setup, all you need to do is open up your .user.ini file in notepad++ and add the following line:

memory_limit = 512M

The changes will take place immediately. The web server does not need to be restarted.

Changing Your Max Upload

This guide will show you how to increase the max upload size in PHP (upload_max_filesize). 

If your .user.ini file is setup, all you need to do is open up your .user.ini file in notepad++ and add the following line:

upload_max_filesize = 1024M

The changes will take place immediately and can be set to whatever value you like. The web server does not need to be restarted.

Notice: If you will be uploading files via the “POST” method (most common), you will likely need to increase the post_max_size configuration value in conjunction with the upload_max_filesize value, if you have not already done so. PHP recommends that you set the post_max_size value higher than the upload_max_filesize value. Experiment with increasing it slightly above upload_max_filesize and increase it further if your uploads are failing.

Changing Your Post Max Size

This guide will show you how to increase the max upload size in PHP (post_max_filesize). To ensure the changes
you’ve made have been properly configured, you’ll need to increase the limit for this value to be higher than
the upload_max_filesize.

If your .user.ini file is setup, all you need to do is open up your .user.ini file in notepad++ and add the following line:

post_max_size=1024M

The changes will take place immediately and can be set to whatever value you like. The web server does not need to be restarted.

Changing Your Max Execution Time

This guide will show you how to increase the time out limit in PHP (max_execution_time).This value sets the maximum time, in seconds, the PHP script is allowed to run.

If your .user.ini file is setup, all you need to do is open up your .user.ini file in notepad++ and add the following line:

max_execution_time=180

Note: This value can be set to whatever time limit you wish, however, please note that our server is configured to kill off PHP connections that last longer than 5 minutes, so please keep that in mind when setting the limit.

Changing Your Max Input Time

This guide will show you how to increase the time out limit in PHP max_input_time. This value sets the maximum time, in seconds, the script is allowed to receive input; this includes file uploads. For large or multiple files, or users on slower connections, the default value may be exceeded.

If your .user.ini file is setup, all you need to do is open up your .user.ini file in notepad++ and add the following line:

max_input_time=180

Note: This value can be set to whatever time limit you wish, however, please note that our server is configured to kill off PHP connections that last longer than 300s.

 

  • Open up File Manager through your control panel and ensure you are in the site directory
 
  • Then, click the upload button at the top of the page to upload your .user.ini file.
 
 
  • At last, you can check if your change take effect by create a info.php file. For more detail, please refer to here.  Note the Local value is your site PHP settings and the Master value is server global PHP settings.