Using php.ini to modify your cPanel Hosting PHP settings
This tutorial is for shared hosting customers utilising our cPanel Hosting infrastructure.
If you are currently using our cloud hosting infrastructure and are wanting to modify the default PHP settings, please review the Migrating websites from Cloud to cPanel article for details.
Modifying PHP Values via cPanel
Within cPanel there is a "Select PHP version" icon. You are able to change the PHP version that is currently running on your cPanel account. As well as changing the PHP version, you are able to modify some of the basic PHP parameters, these include;
allow_url_fopen; display_errors; error_reporting; file_uploads; include_path; log_errors; magic_quotes_gpc; mail.force_extra_parameters; max_execution_time; max_input_time; memory_limit; open_basedir; post_max_size; register_globals; safe_mode; safe_mode_exec_dir; safe_mode_include_dir; session.save_path; short_open_tag; upload_max_filesize
Modifying the above parameters will take effect immediately, and will be global on your account.
Enabling a custom PHP config
In order to enable the use of php.ini, you simply need to upload a php.ini file into the directory which requires further PHP configuration options. Create a php.ini file in your public_html/ folder with whatever directives you want to control, and your application will be using those updated settings. If you want some specific application directory to have it's own php.ini which might differ from the main website php.ini - then upload it into the directory in question.
Making your php.ini global for your hosting account
You might want all your sub-directories and addon domains to use the same php.ini configuration. To avoid having to create the php.ini in every folder which requires it, you can specify a global PHP configuration path for your virtual host using the .htaccess file. To do this:
- Modify or create the file called .htaccess inside your public_html/ folder
- Add the following code to the start of the .htaccess file:
suPHP_ConfigPath /home/USERNAME/public_html/
"USERNAME" is your cPanel username.
What should php.ini look like?
The file must be plain text, and contain directives in syntax of:
Directive = Value;
For example, if you're attempting to disable Safe Mode, the syntax will be:
safe_mode = Off;
If needing to specify Megabyte values for some directives, e.g. increasing Memory Limit to 80MB, the syntax will be:
memory_limit = 80M;
Ensure that each directive is listed on a new line.
What is my current PHP config?
You can check your current default PHP configuration options inside cPanel or by running a simple phpinfo(); command.
Checking PHP configuration via cPanel
Click on the [PHP Configuration] icon in the Software/Services area of the cPanel home page.
Checking PHP configuration via code
Create an info.php file inside your public_html/ folder with the following code:
Then simply browse to this file on the web.
What options can I change using php.ini?
All options supplied in PHP documentation. The most popular updates customers put into their php.ini files are:
- memory_limit
- post_max_size
- upload_max_filesize
- safe_mode
Search the php.net documentation on php.ini for the specific option you wish to change, for syntax information on the required code for your php.ini.
Updated about 1 month ago