How to edit php ini in centos 7

1 Answer

answered Dec 4, 2020 by supriya [36.8k points]
edited Dec 10, 2020 by supriya

In your terminal/console [only Linux, in windows you need Putty]

ssh [email protected]

php -i | grep "Loaded Configuration File"

It shows something like this Loaded Configuration

 File => /etc/php.ini.

ALTERNATIVE METHOD

You can make the php file on the website, which run: , and you can see a php.ini location on your line with: "Loaded Configuration File".

Update This command gives path right away

cli_php_ini=php -i | grep /.+/php.ini -oE #ref. //intellipaat.com/a/15763333/248616

    php_ini="${cli_php_ini/cli/apache2}" #replace cli by apache2 ref. //intellipaat.com/a/13210909/248616

Come and join Linux training to gain great knowledge. 

Related questions

What is php.ini file ?
The php.ini file is the default configuration file for running applications that require PHP. It is used to control variables such as upload sizes, file timeouts, and resource limits.

How to find php.ini location ?
You can check php.ini file through two ways.

1]. Through php file using phpinfo[] function : You can check php.ini file by putting a php file in web server root directory and put this code in it :
-------

-------

2] Through command line : You can check php.ini location using this commmand.
-----
# php -i|grep php.ini
-----

This will give output like :
-----
Configuration File [php.ini] Path => /etc/apache2/php.ini
-----

Last modified: July 22, 2022

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

DirectiveDescriptionRecommended 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

How do I edit a PHP ini file?

How to edit the php.ini file.
Log in to your HostPapa Dashboard..
Click on My cPanel or My WordPress..
Scroll down to the Software section and click Select PHP Version..
Now click Options..
Locate the PHP directive you wish to amend and click the value..

Where is my PHP ini file CentOS?

ini file comes from in CentOS. These are all of the default configuration files that are installed by the php-common package, we can see here that by default the php. ini file is found at /etc/php. ini.

How do I change PHP ini settings?

Modifying the PHP..
Login to the cPanel..
Find the File Manager in File section of the cPanel. ... .
Navigate to the directory where you will either save or edit the PHP. ... .
Edit the section of the PHP. ... .
Click on SAVE CHANGES in the top right hand corner in order to save your modifications or additions to the file..

Where can I find the PHP ini file?

user. ini file is the default configuration file for running applications that require PHP. It is used to control variables such as upload sizes, file timeouts, and resource limits. This file is located on your server in the /public_html folder.

Bài mới nhất

Chủ Đề