How to edit the php.ini file in cPanel
  John Mwaniki /   26 Dec 2021

How to edit the php.ini file in cPanel

As a PHP developer, you most probably have already come across the term php.ini countless times. In this article, we will cover what it is, what is used for, and how can locate and edit it in your web hosting account cPanel.

What are .ini files?

A .ini file is a plain text file that contains configuration information in a simple, predefined format. It is used by applications to store information about the user's preferences.

The .ini file extension stands for “initialization."

A .ini file comprises of properties and values pairs, delimited using the equal sign =, ie "propertyname = value".

The comments in a .ini file are defined by starting the line with a semicolon ;. These commented lines are usually ignored.

What is php.ini file?

You are most likely to encounter some errors (or have already) when working on your PHP applications, that are specific to configurations. Other times, you may want to make some changes to the configurations on how you can use PHP in your applications. In such scenarios, you almost always will be required to edit something on the php.ini file.

The php.ini file is the default configuration file for running applications that require PHP. It is a plain text file that is used to alter PHP settings such as:

  • Displaying or hiding log errors
  • The uploading maximum size
  • The maximum time to execute a PHP script
  • The resource usage limits
  • Etc

Each time PHP is initialized, the php.ini file is read by the PHP interpreter to determine what settings to use.

After installing PHP on your Windows PC, you can locate the php.ini file inside the PHP folder. If you use XAMPP, you can find the file inside the path ‘\xampp\php’.

On Linux, you can find the php.ini file inside the ‘/opt/lampp/etc’ directory.

Editing the php.ini file in cPanel

Before making any changes to the php.ini file, it's always a good idea to backup the original settings somewhere. This helps in reference and also in restoring to the original settings in case it is needed.

If your website is already hosted online, there are high chances that you use the cPanel hosting control panel to manage it.

Below are the instructions on how to find and edit the php.ini file in the cPanel.

There are two main ways to do it:

  1. Using MultiPHP INI Editor
  2. Through file manager

For both methods, the first step is to log in to the cPanel.

1. Using MultiPHP INI Editor

Click on the MultiPHP INI Editor under the "Software" section of cPanel.

MultiPHP INI Editor

You will be presented with two modes of editing the php.ini file:

MultiPHP INI Editor options

The first option (basic mode) allows you to edit the configurations through a form interface. Select your domain name from the dropdown and the configuration options will appear in a table. The "PHP Directive" column has the configuration properties while the right column (Settings) has form input fields for entering the property values. The middle column (Information) contains a description for each configuration so it's much intuitive to work with. Fill in the form and click the "Apply" button at the bottom to save the changes once you are done.

The second option (Editor Mode) allows you to edit the php.ini file directly from a text editor interface. Make all your preferred configuration changes then click on the "Save" button on the top-right once done.

2. Through file manager

By default, the php.ini file is located on the domain root directory of your server, that is "public_html" folder. To access edit it, click on the "File Manager" under the Files section in cPanel.

cPanel file manager option

Open the "public_html" folder.

file manager public_html

You will find the php.ini file in this directory. If you don't find it you can create a new one. Right-click on this file and select "Edit" from the options that appear. It will be opened in a text editor interface. Make changes/updates to the configurations and once done click the "Save Changes" button at the top-right.

That's all!

This is how you edit the php.ini file in the cPanel.