1. Home
  2. Technical
  3. How To Change php.ini File (max_execution_time, memory_limit)

How To Change php.ini File (max_execution_time, memory_limit)

PHP extensions and values for a virtual server can be managed in multiple ways: via the global php.ini file, using local .user.ini file or through Web Hosting Management.

Adding and Modifying the Global php.ini File

The global php.ini file is a PHP configuration file where settings are loaded in addition to server defaults. This file can adjust nearly all PHP settings, limits, load modules, etc. All configurations affect both the main domain and all *.example.com subdomains, with changes applying immediately to new PHP processes.

By default the global php.ini file does not exist on the server, so it must first be added to the server:

/data01/virt1234/domeenid/www.example.com/phpini/global/php.ini

The most reliable way to find the correct location and check if the global php.ini file is loaded by PHP is to view phpinfo(). To do this, create a PHP file with any name in the root directory of the main or subdomain and insert into the file following:

<?php phpinfo();

phpinfo()

Recommendation

It is recommended to add only the settings you wish to change into the php.ini file. Do not copy the entire configuration file into this file!

Attention!

Settings modified in the global php.ini will override those set in the Web Hosting Management!

.user.ini File and How To Modify It

By default the .user.ini file does not exist on the server. You can create this file in any directory and it will automatically also apply to all subdirectories.

If you want it to affect both the main domain and subdomains simultaneously, place it in the virtual server’s domain directory that contains the root directories for both the main and subdomains:

/data01/virt1234/domeenid/www.example.com/

If multiple domains are under a single virtual account and you want single .user.ini file to affect all domains, then add the .user.ini file to the virtual server’s home directory:

/data01/virt1234/

Changes made to the file affect both HTTP and HTTPS hosts at the same time.

Attention!

.user.ini file can be used only for next type of settings: PHP_INI_PERDIR, PHP_INI_USER and PHP_INI_ALL.

For PHP_INI_SYSTEM settings (for example opcache settings) php.ini file has to be used.

List of directives can be found from PHP’s documentation:
List of php.ini directives

Recommended further reading

PHP documentation: .user.ini files

Changing PHP Extensions From Web Hosting Management

The most common PHP extensions can be changed directly from the My Zone Web Hosting Management.

To do this, choose from menu on Webhosting page: Webserver -> Main domain settings or Subdomains depending on whether you want to activate or change the PHP extension on the main domain or on the subdomain.

In the next example for main domain, click on modify:

Change PHP Extensions

 

Under PHP subsection choose PHP extensions:

On the next page list of possible extensions are displayed:

To save changes, click on modify at the bottom of the page.

Settings changed through the Web Management take effect within 5 minutes for new PHP processes.

Examples of Settings T​hat Can Be Changed Using the php.ini and .user.ini Files

Here are some examples of how to change common PHP settings.

Attention!

Add only the settings you want to change to the .user.ini or php.ini file. If you want to change only one setting, it is enough to add just one line.

Max Execution Time

The default value is 30 seconds. This sets the maximum running time of the PHP script in seconds. To change, add the following line:

max_execution_time = 60

PHP Memory Limit

The default value is 1024M. Add the following line to increase the value:

memory_limit = 1500M

Display Errors

Display errors setting can be used to turn on/off the displaying of the PHP errors. By default error display is on, add the following line to turn it off:

display_errors = off

Changing the Name for NewRelic Application

newrelic.appname = "My App"
Updated on 7. Nov 2024
Was this article helpful?

Related Articles