You can modify specific PHP configurations for a single website by creating or editing a .user.ini or php.ini file. This method allows you to override global server settings for a specific directory without affecting other websites on the same server.
Before you begin
You will need:
Access to the website's files via an FTP client or a File Manager.
The specific PHP setting name and the desired value (e.g.,
memory_limit,post_max_size, ormax_execution_time).
Create and edit a .user.ini file
The .user.ini file is the preferred method for changing PHP settings for a specific website because it is processed by the PHP engine on a per-directory basis.
Connect to your server using an FTP client or your hosting control panel's File Manager.
Navigate to the root directory of the website you wish to modify.
Create a new file named
.user.ini(ensure the leading dot is included).Open the file and enter the desired configuration. Use the following format:
memory_limit = 256M post_max_size = 128M max_execution_time = 300
Replace the values above with the specific settings required for your application.
Save the file and upload it to your server if you created it via an FTP client.
Using a php.ini file
In some specific environments, a php.ini file may be used instead of .user.ini.
Note: While php.ini is a standard configuration file, its behavior can vary depending on the server's PHP configuration. If your changes in a php.ini file do not take effect, use the .user.ini method described above.
Navigate to the root directory of the website.
Create a file named
php.ini.Enter the desired settings using the same format as the
.user.iniexample.Save the file.
Confirm the result
To verify that the changes have been applied, you can use a PHP information script or a tool like php_info().
Create a file named
info.phpin your website's root directory.Add the following code to the file:
<?php php_info(); ?>
Open the file in your web browser by navigating to
http://example.com/info.php.Locate the specific setting (e.g.,
memory_limit) in the table to confirm it reflects the value you entered in your.user.iniorphp.inifile.Warning: Delete the
info.phpfile immediately after checking, as it reveals sensitive server configuration details to the public.
Limitations
File Naming: Ensure the filenames are exactly
.user.iniorphp.ini. A missing dot or a typo in the extension will prevent the server from recognizing the file.Propagation: Changes to these files typically take effect immediately, but some server configurations may require a PHP process restart to recognize changes.
Scope: These files only affect the directory they are located in and any subdirectories. They do not affect other websites on the server.
