How to use .user.ini to customise PHP settings on shared hosting

July 30, 2025 / Web Development

The Apache and php.ini configuration files are frequently inaccessible to users in shared hosting setups. However, the majority of hosting companies let you utilise a “.user.ini” file to change PHP settings. For adjusting PHP behavior, such as raising file upload limitations, altering memory limitations, or changing execution time, this is quite helpful.

First, let us understand what is .user.ini:

“.user.ini” is a user-level configuration file supported by PHP when running as CGI or FastCGI. It lets users disallow specific PHP settings on a per-directory basis.

Steps to Create and Configure .user.ini:

  1. Use your control panel’s file manager or connect via FTP to access the root directory of your website (typically public_html).
  2. Create a file named .user.ini if it doesn’t already exist. Ensure the filename starts with a dot (.).
  3. Add PHP Settings by adding the required PHP directives in this file. For example:
    memory_limit = 256M
    upload_max_filesize = 64M
    post_max_size = 64M
    max_execution_time = 300
    Each directive should follow the format:
    directive_name = value
  4. Finally, save the “.user.ini” file and confirm it’s located in the root of your site (e.g., public_html). PHP will automatically notice and apply the settings from this file.

Important Notes:

  • Changes made in the .user.ini file may take up to 5 minutes to apply.
  • The settings defined in the .user.ini file will affect the directory where it is placed, along with all its subdirectories.
  • You can use the phpinfo() function to confirm whether the updated PHP settings are active.

Common Use Cases:

  • To increase the file upload size, set upload_max_filesize = 64M in the .user.ini file.
  • To allow larger form submissions, use post_max_size = 64M.
  • To allocate more memory to PHP scripts, use memory_limit = 256M.
  • To extend the maximum execution time for scripts, set max_execution_time = 300.

This way, you can use .user.ini to customise PHP settings on shared hosting. If you want additional assistance, feel free to contact our support staff.

Need to adjust file upload limits too? Learn How to Change File Upload Size Limit Using php.ini in Shared Hosting

Spread the love