phpinfo() has been disabled for security reasons

PHP Warning: phpinfo() has been disabled for security reasons


I got the below error on my Linux server. Error shows PHP phpinfo() function is disabled on the Linux server. phpinfo PHP function is used to show the PHP information (PHP configuration) on your server.

Some of the web hosting providers disable phpinfo PHP function server-wide for security reasons.


phpinfo has been disabled for security reasons

phpinfo has been disabled for security reasons


Follow the below steps to fix the error by enabling phpinfo function server-wide.

1. Open a new terminal and log into your server via SSH as ‘root’ user

2. Check whether phpinfo is added in PHP disable functions

Run the below command to check whether phpinfo function is added in PHP disable_functions.

# grep disable_functions /etc/php.ini
disable_functions = phpinfo

On my server php configuration file is in path /etc/php.ini. The path might be different on your server. Run the command “php --ini” to find the loaded PHP configuration file.

The above command output shows phpinfo PHP function is added in disable_functions.

3. Remove phpinfo from PHP disable_functions

open php.ini file using your favorite editor.

vi /etc/php.ini

Scroll down to disable_functions line and remove phpinfo.

Save the PHP configuration file and exit the editor.

This will enable the phpinfo PHP function.

Note : phpinfo function might be disabled by the server administrator while hardening the PHP installation. You must enable this function only if it is required. Functions added in PHP disable_functions are exploitable dangerous PHP functions.

4. Restart the web server

You must restart the web server for changes to take effect. Apache web server is installed on my server. You might be using a different web server on your Linux server.

# service httpd restart

5. Create a phpinfo file to verify

Create a phpinfo file under your website to check whether you are still getting the warning.