How To Create phpinfo FIle in WebHostingM cPanel and Plesk Make it Rain Paper

  • phpinfo
  • 0

The phpinfo function is a commonly used PHP function that displays detailed information about PHP’s configuration on a server. This includes details about PHP's configuration, loaded extensions, and available variables. It's an essential tool for developers to troubleshoot issues and optimize their applications.

However, for security reasons, phpinfo is often restricted in shared hosting environments. This guide will show you how to create and use phpinfo, explain its restrictions, and provide alternatives for configuring PHP in WebHostingM’s cPanel and Plesk environments.

What is phpinfo?

phpinfo is a PHP function that displays detailed information about PHP’s current environment, including PHP version, loaded extensions, server information, and configuration settings. It’s especially useful for diagnosing PHP-related issues or verifying configuration details.

How to Create a phpinfo File in cPanel

  1. Log in to your cPanel account.
  2. Open the File Manager and navigate to the directory where you want to create the phpinfo.php file (e.g., public_html for the main site).
  3. Click + File, name the file phpinfo.php, and click Create.
  4. Edit the file and add the following code:
    <?php
    phpinfo();
    ?>
  5. Save the file and open https://example_domain.com/phpinfo.php in a browser to view the PHP configuration.

How to Create a phpinfo File in Plesk

The simplest way to do this is to log in to your Plesk control panel, click on and then "View the phpinfo() page".

 

PHP Selector Extensions

 

But should you want to create this manually, then:

  1. Log in to your Plesk control panel.
  2. Navigate to Domains > File Manager and locate the root directory (e.g., httpdocs).
  3. Click Create File and name it phpinfo.php.
  4. Edit the file and add:
    <?php
    phpinfo();
    ?>
  5. Save the file and visit https://example_domain.com/phpinfo.php to view the PHP settings.

Why phpinfo is Restricted on WebHostingM Shared Hosting

On shared hosting servers, phpinfo is often restricted due to security concerns. Since phpinfo displays detailed server and configuration information, it could expose sensitive data if accessed by unauthorized users. To protect against security risks, WebHostingM and other hosting providers may restrict phpinfo or provide alternatives for viewing PHP settings securely.

Configuring PHP with PHP Selector on WebHostingM cPanel and Plesk

On WebHostingM servers, the preferred method and recommended way to configure PHP settings is through PHP Selector, which has replaced the cPanel MultiPHP INI Editor and MultiPHP Manager. With PHP Selector, customers can edit php.ini settings directly, while administrators control which settings are editable. This helps streamline PHP configuration across different environments.

Using PHP Selector in cPanel

 

PHP Selector Options

 

  1. Log in to your cPanel account.
  2. Go to Select PHP Version under the Software section.
  3. Choose your desired PHP version (from PHP 7.4 to PHP 8.3, the latest System PHP version).
  4. Click Set as current to apply the version.
  5. Use the PHP Options tab to configure settings like memory_limit and upload_max_filesize. Your changes are saved automatically.

 

Plesk PHP Selector

 

Note: While PHP Selector supports versions from PHP 7.4 to PHP 8.3 (the current system PHP version, typically set to one of the ea-php$version options), it's crucial to use versions above the native version. Selecting the native version may lead to improper functioning of the PHP Selector.

Using PHP Selector in Plesk

Configuring PHP in Plesk with PHP Selector requires selecting a compatible PHP Handler in MultiPHP. The MultiPHP Manager in Plesk allows users to choose PHP versions for each domain, but if the PHP Handler selected by the user is incompatible with PHP Selector, the selected PHP version may not work as expected.

  1. Log in to Plesk and go to Domains > example_domain.com > PHP Settings.
  2. Choose a compatible PHP version from the MultiPHP drop-down list. Ensure the selected PHP version aligns with PHP Selector requirements.
  3. If PHP Selector settings are not effective, double-check the PHP Handler compatibility in MultiPHP Manager.

Note: Using PHP in Plesk can be more complex than in cPanel. MultiPHP in Plesk may override the PHP Selector version if an incompatible handler is selected. If an incompatible PHP Handler is chosen, the PHP Selector will not function correctly. So always ensure that the handler matches PHP Selector requirements.

Best Practices and Troubleshooting

When working with PHP settings:

  • Always test changes in a safe environment before applying them to production.
  • Refer to the latest documentation from your hosting provider for any changes or updates.
  • Monitor your applications after making changes to ensure stability.
  • For detailed settings and compatibility information, consult the latest documentation for your control panel.

Disclaimer

Using phpinfo() is a crucial step in managing your PHP environment, but understanding its limitations and the tools available (like PHP Selector) is essential for effective hosting management. Be cautious when adjusting PHP settings, as incorrect configurations can cause application errors. For security, avoid using phpinfo in publicly accessible areas of your website. Always test changes before applying them on production servers.


Did this answer help?

« Back