1. Home
  2. How To
  3. How to edit PHP Parameters

How to edit PHP Parameters

Introduction

The php.ini file is the main configuration probe for the installed PHP package in your server. Usually, each of the installed PHP version will have its own php.ini file where you can adjust the configuration directives as per your requirements and modify the PHP functionalities as you decide. The configurations from the php.ini files will be loaded each time with the initialization of the web server, hence a web server reload is required to fetch the php modifications that you make via the php.ini file. 

What is phpinfo()

You can use the phpinfo() to verify the changes that you made from the php.ini file. Please create a file with the .php extension (phpinfo.php) in your website document root location with the below noted php script in it.  

<? phpinfo(); ?>

Change the file permission to 644 and assign user and group ownership for the file as your webuser.

chmod 644 phpinfo.php

chown webuser.webuser phpinfo.php

Once done, you can access this .php file with your website from a web browser (https://yourdomain.com/phpinfo.php) and it will display all the details for the related php binary with the website. The details include compilation options used with binary, the extension compiled, loaded php version, loaded php.ini files, the limits that you set with the PHP configuration directives etc.

Editing php.ini file

You can use the phpinfo file as we discussed above to see the loaded configuration file with your website. The “Loaded Configuration File” is your currently loaded config file and the one you should edit. Connect to the server via an SSH terminal and open the file with your favourite text editor. The file is well documented and you can see short description about each of its configuration directives as commented with it. Empty lines, white spaces and lines starting with semicolon (;) are ignored, directives can take boolean values 1/0, Yes/No, On/Off, True/False. Make the changes in your file, reload the web server and verify the effects using phpinfo().

Editing php.ini in a Plesk Server 

It is very easy to make changes for the php.ini configuration for a Plesk managed server as it gives you the option to make the changes from the Plesk panel itself and a file level edit is not required. There are option available to edit the configurations globally so that the changes will be applicable for all the domains hosted in the account or specifically for a single domain or its included service plan.

  1. Login to Plesk panel using the secure port 8443 https://<server_ip>:8443, you can use the command “plesk login” from the shell to get a one time access URL for the panel.
  2. Click on “Domains” from the left side options pane.
  3. Click on Manage for the selected domain to access the domain specific Plesk panel.
  4. Click on “PHP Settings”.

Edit the common PHP directives from the panel itself or add additional directives in the text box labeled as “Additional configuration directives”

You can follow the below steps from the Plesk panel if you want to make the php changes globally for all the hosted domains in server.

  1. Login to Plesk panel using the secure port 8443 https://<server_ip>:8443, you can use the command “plesk login” from the shell to get a one time access URL for the panel.
  2. Click on Tools and Settings from the left side options pane
  3. Find and access “PHP Settings”, navigate to php.ini tab.

This will give you the text file representation of the global php.ini file and you can edit the file from here.

Editing php.ini in a cPanel server

In a cPanel server, php.ini can be edited directly from the panel just like Plesk or any other control panel. On servers that run EasyApache 4, multiple php.ini files manage the system’s PHP. Each version of PHP on your server uses its own php.ini file and it is required to make changes to the correct php.ini file to get the updates in the intended PHP version. From the WHM panel navigate to “WHM >> Home >> Software >> MultiPHP INI Editor”, select the PHP version adn make the changes and save. This will make the changes applicable globally for all the domain accounts using that PHP version. You can edit the php.ini settings for a specific domain from its cPanel, cPanel >> Softwares >> MultiPHP INI Editor. 

Updated on May 31, 2019

Was this article helpful?

Related Articles