cPanel

How to Edit Your php.ini File


Overview

You can update the settings of your server’s php.ini file to help secure your server. The method to use depends on your version of EasyApache.

Warning:
  • You must also use other security measures with these settings. When you use these alone, your server’s security is at risk. Malicious users can bypass most hardening measures.

  • Apache reads all files with the .ini file extension. If you have a custom .ini file, you must update it manually.

Editing in EasyApache 3

On systems that run EasyApache 3, the /usr/local/lib/ directory contains your server’s php.ini file.

Editing in EasyApache 4

Note:

We recommend only editing these files with WHM’s MultiPHP INI Editor interface (WHM >> Home >> Software >> MultiPHP INI Editor). This ensures that an operable version of PHP exists on the system.

On systems that run EasyApache 4, each version of PHP uses a separate php.ini file. You must make changes separately to each file. Each file exists in the /opt/cpanel/ea-php72/root/etc/php.ini file, where 72 is the PHP version number.

Directives

Directive Description Recommended value
safe_mode This directive helps solve many problems that occur with using PHP in a shared hosting environment. It compares the PHP script’s UID with the UIDs of files and directories that it tries to access. If the UIDs don’t match, the system doesn’t allow the script access.

Warning:
PHP 5.3.0 deprecated this directive and PHP 5.4.0 removed it.
On
disable_functions This directive disables a list of PHP functions. For example, you can disable ones that execute subprocesses. A comma-separated list of functions to disable.
register_globals This directive can allow attackers to bypass your settings via the URL.

Warning:
PHP 5.3.0 deprecated this directive and PHP 5.4.0 removed it.
Off
display_errors This directive allows PHP to print run-time errors to generated HTML pages. When you disable it, PHP can still print errors to the appropriate error logs. Off
allow_url_fopen This directive can allow attackers to open remote files from your server. They do this via file inclusion vulnerabilities. Off
allow_url_include This directive can allow attackers to include remote files from your server. They do this via file inclusion vulnerabilities. Off
file_uploads This directive can allow attackers to move their scripts on to and off of your server. Off
open_basedir This directive limits file operations to a specific directory. Attackers may try to include local files in PHP scripts. This can allow them to access information about your server’s filesystem.

Note:
  • This setting only affects servers that use the mod_php Apache module.
  • If your system runs EasyApache 4, change this directive in the Editor Mode section of WHM’s MultiPHP INI Editor interface (WHM >> Home >> Software >> MultiPHP INI Editor).
~/public_html
session.cookie_httponly This directive keeps JavaScript from accessing PHP session cookies. This ensures that attackers can’t steal them.

Important:
You can’t use this directive if your users use PHP session cookies through JavaScript.
1
session.referer_check This directive allows it to check referrer values. You can specify a domain to make sure that session information stays internal. Then, users won’t be able to expose session information when they’re working on a web application.

Warning:
Do not rely on this security measure alone. It is trivial to send false referrer information.
Note:
If your system runs EasyApache 4, change this directive in the Editor Mode section of WHM’s MultiPHP INI Editor interface (WHM >> Home >> Software >> MultiPHP INI Editor).
On

Related Articles

Leave a Reply

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