Knowledgebase: Shared Hosting
Custom PHP Configuration
Posted by Noble M on 27 June 2014 07:51 AM

Custom PHP configuration is useful when you want to limit the system resource consumption by PHP scripts or meet the requirements of a certain web application.

When you set a parameter to the default value or do not specify the value, PHP will use the parameter value set in the server-wide PHP configuration.

If you'd like to check the list of most commonly used PHP directives, you can find that under "Famous PHP directives" section given below.

Note: If custom values are exceeding maximum limit set on server wide PHP configuration then it won't work. If you face any similar issues, feel free to reach out and we'll be glad to explain this to you in detail.

If you’re using Linux Hosting (cPanel) and like to Edit the PHP directives, here's what you need to do:

While we do not have any option in cPanel to edit the PHP settings directly, we can use cPanel >> PHP Configuration option to view the server-wide settings.

As an alternate solution, we can use the php.ini file to customize the PHP settings on a domain. If you don’t find the php.ini file, you can create one. It’s easy. Here’s how you do it:

  1. Login to your cPanel

  2. Click on File Manager

  3. Browse to the root directory of your domain for which you’d like to edit the PHP settings i.e. /home/<user_name>/public_html

  4. Click on New File icon

  5. Set the New File Name as php.ini

  6. Click on Create New File

Custom PHP Directives

  1. Once done, right click on the php.ini you just created

  2. Click Edit

  3. Refer the php.ini syntax section given below

  4. Enter your custom PHP settings

  5. Click on Save Changes

And its done!


How can I test the PHP configuration?

You can use the phpinfo() function to check PHP settings of your domain name hosted on any servers

1. Create a file say info.php and add below line in it.


<?php phpinfo(); ?>


2. Access http://domain.tld/info.php in browser to check current PHP settings of domain.tld (This might take few minutes to reflect recent changes).

 Here are a list of few famous PHP directives

Note: Below examples are representations of PHP directives and do not display the actual value set on our servers


This sets the maximum amount of memory in bytes that a script is allowed to allocate. This helps prevent poorly written scripts for eating up all available memory on a server.

Example: memory_limit = 128M



The maximum time in seconds a script is allowed to run before it is terminated. This helps prevent poorly written scripts from tying up the server.

Example: max_execution_time = 20



The maximum time in seconds a script is allowed to parse input data

Example: max_input_time = 30



Limits maximum size of an uploaded file.

Example: upload_max_filesize = 16M



Sets max size of post data allowed. This setting also affects file upload. To upload large files, this value must be larger than upload_max_filesize. If memory limit is enabled, memory_limit also affects file uploading. In general, memory_limit should be larger than post_max_size.

Example: post_max_size = 16M

The temporary directory used for storing files when doing file upload. Must be writable by whatever user PHP is running as.

Example: upload_tmp_dir = /dir/your_tmp_dir



The directory where PHP writes session data (files). For example: /dir/tmp

Example: session.save_path = /dir/tmp



This feature has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 5.4.0.

The PHP safe mode is an attempt to solve the shared-server security problem. This mode puts a number of restrictions on scripts (say, access to file system) mainly for security reasons.

Enabling safe_mode is not needed if other reasonable security precautions are followed. It may make sense in some situations, but there is almost always a better way.

Most of the CMS installation scripts will love to have safe_mode disabled (like Joomla). This is because safe_mode, by design, turns off the PHP functions that enable easy uploading via a Web browser. If you do use safe_mode, and need to perform installs via the Web browser, temporarily turn safe_mode OFF, and turn it back ON when finished.

Example: safe_mode = On/Off



This feature has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 5.4.0.

Tells whether to register the contents of the EGPCS (Environment, GET, POST, Cookie, Server) variables as global variables.

When on, register_globals will inject scripts with all sorts of variables, like request variables from HTML forms. This option is a great security risk, thus do not turn it on without necessity.

Example: register_globals = On/Off



Limits the files that can be opened by PHP to the specified directory-tree.

If the file is outside the specified directories, PHP scripts will refuse fopen() or gzopen() to open those files. To separate directories, use a colon (:) on Linux and a semicolon (;) on Windows. For example, on Linux: /dir/upload:/usr/tmp.

Example: open_basedir = /dir/sub_dir


Magic Quotes

This has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 5.4.0.

This is used to prevent SQL Injection and it's helps in writing better (more secure) code.

Example: magic_quotes_gpc = On/Off



Defines the level of error reporting like ~E_ALL, E_ALL and ~E_NOTICE,E_ALL ('~' is used to ignore).

E_ALL : All errors and warnings, as supported

E_NOTICE : Run-time notices. Indicate that the script encountered something that could indicate an error, but could also happen in the normal course of running a script.

Example: error_reporting = E_ALL & ~E_NOTICE



Determines whether errors should be printed to the screen as part of the output or if they should not be shown to a user.

Example: display_errors = On/Off



Tells whether to log errors. By default, errors are logged in the server's error log. Use the error_log directive to specify the path to your own log file.

Example: log_errors = On/Off

If you have a Windows Hosting ( Plesk Panel) and like to edit the PHP directives, we’d suggest you to contact us and we’ll help you out.

Additional links for reference:

(6 vote(s))
This article was helpful
This article was not helpful