Need help?

Our experts have had an average response time of 13.14 minutes in February 2024 to fix urgent issues.

We will keep your servers stable, secure, and fast at all times for one fixed price.

How to enable custom php ini in cPanel servers with suPHP using EasyApache 4

by | Nov 29, 2016

PHP is a commonly used scripting language for websites, and its configuration settings can be managed using a server-wide php.ini file.

Most shared hosting providers enforce server-wide php ini settings on all users. But some software such as WordPress, Joomla, etc. require custom PHP ini for websites.

To allow users to configure their custom PHP settings, SuPHP can be enabled in a server. This will allow them to override the server-wide PHP settings.

PHP configuration in cPanel/WHM servers

In cPanel/WHM servers, the script EasyApache is used to recompile Apache/PHP in the server and to customize the php.ini settings.

  Our 24/7 US based phone support team coordinates with the helpdesk support team to quickly customize server settings for the customers. Learn more.

When the latest version EasyApache 4 was released, it came with many features such as PHP 7 support and custom PHP version per website.

Today we’ll see the steps to enable custom php ini for users in cPanel servers with suPHP using EasyApache 4.

Enable custom php ini in cPanel servers using EasyApache 4

Unlike its previous versions, EasyApache 4 uses ‘rebuild_phpconf’ script to manage PHP settings. As a result, its configuration is a bit different.

On servers with EasyApache 4, multiple ‘php.ini' and ‘local.ini' files manages the PHP settings. To enable custom php ini, the steps are:

Step 1 – Locate the local.ini file

The first step is to ensure that ‘local.ini’ file is present for the PHP version in the following folder:

/opt/cpanel/ea-php/root/etc/php.d

Examples:

/opt/cpanel/ea-php55/root/etc/php.d/local.ini
/opt/cpanel/ea-php56/root/etc/php.d/local.ini
/opt/cpanel/ea-php70/root/etc/php.d/local.ini

Step 2 – Generate ini file

If local.ini file is NOT present in the location ‘/opt/cpanel/ea-php/root/etc/php.d’, go to “MultiPHP INI Editor” in WHM.

 

PHP ini editor in WHM

PHP ini editor in WHM

See how our 24/7 support team helps you!

Step 3 – Choose the corresponding version of PHP

Since Easyapache 4 supports multiple PHP versions, it will show them as options in the editor. Select a PHP version that you want to be installed in your server.

Once you select the PHP version that you want from the drop down, you would be presented with the php.ini file corresponding to that version.

 

Edit php ini for PHP version

Edit php ini for PHP version

 

Step 4. Scroll down & press “Apply” button

If you want any custom PHP setting such as memory limit, it can be edited now. After making the required changes in the php.ini file, save the changes.

 

Generate custom php.ini file

Generate custom php.ini file

 

Now, we can see that ‘local.ini’ files are generated in the folder ‘/opt/cpanel/ea-php/root/etc/php.d’.

===================================
 (root)>ll /opt/cpanel/ea-php*/root/etc/php.d/local.ini
 -rw-r--r-- 1 root root 65515 Sep 17 02:15 /opt/cpanel/ea-php55/root/etc/php.d/local.ini
 -rw-r--r-- 1 root root 65515 Sep 17 02:22 /opt/cpanel/ea-php56/root/etc/php.d/local.ini
 -rw-r--r-- 1 root root 60538 Sep 17 02:22 /opt/cpanel/ea-php70/root/etc/php.d/local.ini
 ===================================

These are the server-wide php.ini files for each PHP version settings.

[ Take care of your customers, before your competitors do. Get world-class support specialists to delight your customers. ]

Step 5 – Identify the PHP version for the website

Next step is to setup custom php ini file for a customer’s website in the cPanel server. Go to document root of the website, usually ‘/home/user/public_html/’ .

Run these commands to see PHP version of the website and its php.ini file location.

 php -v
 php -i | grep php.ini

You can now see the PHP version for that website and the php.ini file used for it.

Verify PHP version of website

Verify PHP version and ini file of website

Step 6 – Configure custom php ini file for website

The server-wide php.ini file that is used for the website can be copied over to the site and edited for custom settings.

The custom php ini files for users are named as “.user.ini”. Copy ‘/opt/cpanel/ea-php56/root/etc/php.ini’ to the document root of the website and rename it to ‘.user.ini’.

Now, we can modify this ‘.user.ini’ file and customize the parameters that are required for the website. This custom php ini file will be applied to all sub folders.

The changes that are made to this ini file can be verified using a ‘phpinfo()’ page for the website.

[ Running a hosting business doesn’t have to be hard, or costly. Get 24/7 world class Hosting Support Specialists and get peace of mind. ]

Points to note..

There are a few other points to note during the custom php ini in cPanel:

  1. Make sure that ‘suPHP_ConfigPath’ is NOT defined in the ‘.htaccess’ file for the website, as it will not work in EasyApache 4 servers with suPHP.
  2. The “Loaded Configuration File” in “PHP info” page will not be changed to ‘/home/user_name/public_html/.user.ini’, but any changes in .user.ini will be shown in “PHP info page”.
  3. The name of custom php.ini file is “.user.ini” by default. This can be changed to “php.ini” using the directive:

=======================
user_ini.filename = "php.ini"
=======================

This directive is also required for the php.ini file generated by cPanel => “MultiPHP INI Editor” to work.

While it is advisable to implement feature updates in the servers, sudden updates and feature changes in cPanel/WHM may tamper with the normal user functions.

It is always important to test and verify a feature change before applying it in a live server, to avoid a business downtime for the websites hosted in it.

At Bobcares, we maintain and manage cPanel/WHM servers to ensure 100% uptime for the websites. If you’d like to know how to do that for your servers, we’d be happy to talk to you.

 

GET 24 HOURS PHONE SUPPORT SERVICES

Use Bobcares for your phone support services. Ensure 24/7 coverage for your customers!

CONTACT US FOR 24/7 PHONE SUPPORT PLANS

3 Comments

  1. seun kehinde

    Any tutorial on how to disable custom user.ini files in public_html for easyapache4?

    Reply
  2. Craig Jacobs

    In my case I needed to copy php.ini to the public_html folder because it wouldn’t recognize the .user.ini file for some reason, but it worked.

    Honestly, I fail to see why people use CPanel. In my extensive experience over the last 10 years, I find that CPanel causes far more problems than it solves. If you spent the time required to troubleshoot CPanel learning how to manage the basic config files for Apache, PHP and MySQL instead you’d be well ahead of the game.

    Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

Categories

Tags

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF