PHP is a widely used open-source web scripting language. Created in 1994, it has evolved into one of the most commonly used online languages, powering approximately 80% of websites globally. This is mainly due to its flexibility, ease of use, and support from significant content management systems (CMS) like WordPress, Joomla, and Drupal, as well as numerous frameworks and custom applications.
PHP is processed by the server rather than the user’s browser. It processes code to generate HTML dynamically, enabling developers to create interactive, data-driven web applications. PHP integrates easily with databases, handles user sessions, processes forms, and supports many other functionalities necessary for modern websites.
To help you check your PHP version and configuration quickly, we’ll cover several methods and tools suitable for different environments:
Command:
$ php -v

phpinfo()
Command:
$ php -i

Tip: Redirect output to a file for easy reading:
$ php -i > php_info.txt

Command:
$ php --ini

Command:
$ php -m

Command:
$ php -r 'echo ini_get("upload_max_filesize");'

Script:
<?php
phpinfo();
?>

Script:
<?php
echo 'Upload Max Filesize:.' ini_get('upload_max_filesize') . '<br>';
?>

With control solutions such as cPanel and DirectAdmin, making changes to PHP settings is very convenient. One advantage would be viewing or altering examples of PHP without returning to the command line. There is a gloomy interface for viewing specific configuration information and globally specific PHP settings for a general PHP understanding of its configuration details, which is suitable for users who require complicated technical operations.




To learn more about changing PHP versions in cPanel, refer to our detailed article: How to Change PHP Version in cPanel.
Changing the PHP version and viewing configuration details is also straightforward for users with DirectAdmin. DirectAdmin provides an intuitive PHP version management feature similar to cPanel’s PHP Selector. You can use this tool to choose the PHP version that best meets your website’s requirements.
To learn more about changing PHP versions in DirectAdmin, refer to our detailed article: How to Change PHP Version in DirectAdmin.
Using Plugins:
Using plugins in WordPress provides an easy way to check the PHP version and other server configuration details. Plugins like “Site Health” or “PHPInfo” offer insights directly from the WordPress dashboard without requiring technical expertise in server management. The “Site Health” plugin, accessible under the “Tools” menu, provides information on the server environment, including Pthe HP version, memory limits, maximum upload size, and execution time limits. These details are essential for troubleshooting compatibility issues with themes or plugins and ensuring your server environment aligns with WordPress recommendations for optimal performance and security. Regularly checking these values can help maintain a stable and compatible WordPress site.

Common Settings:
This setting specifies the maximum number of bytes a PHP script can use as memory. This feature assists in stopping scripts from utilizing all the disk space on the server, which can result in system hang-ups or slowdowns. This value may have to be augmented for resource-intensive applications, but usage must be closely watched to prevent the server from being overwhelmed. If no limit is specified, this directive can be set to -1, which means no limit can be imposed, which is dangerous in shared environments.

This parameter limits the maximum size of uploaded files using PHP scripts. If you let users upload image or video files, this value must be set according to the expected file sizes. Smaller a value might prevent users from uploading at all, while too high a value is risky or could result in excessive server consumption.

post_max_size:
This setting defines the maximum size for POST data, including form submissions and file uploads. This value should exceed upload_max_filesize for larger files, as it encompasses all POST data sent to the server. If post_max_size is set too low, it might result in incomplete data being processed for applications that rely on extensive form submissions.

max_execution_time:
It specifies the maximum time (in seconds) a PHP script can take to run. It prevents poorly written scripts from running forever and using the server’s resources. This might be true if one needs to run more complex operations, such as importing an extensive database or other intensive data processing tasks. If set too high, the load on the server can increase because scripts do not complete successfully.

This issue occurs when the system cannot locate the PHP executable. It often happens if PHP is not installed or the system’s PATH variable doesn’t include PHP’s directory. To fix this, verify that PHP is installed using package managers like apt, yum, or brew, depending on the operating system. After installation, confirm that PHP’s location is added to the PATH environment variable. This step enables commands like php -v to work from any terminal session.
Sometimes, systems install multiple PHP versions, leading to version conflicts. When you run php—v, the system might show an unintended version if both versions are managed differently (e.g., one from the OS package manager and one from a custom installation). To solve this issue, set the complete path towards the preferred PHP variant or the desired version default. Other methods to set the PHP version of choice on Linux include update alternatives.

Composer is a dependency manager for PHP, frequently used to install packages and manage project dependencies. Running
$ composer --version
provides information about the installed Composer version, which can be necessary for compatibility checks when working with many PHP frameworks and libraries. Composer checks the PHP version as part of its dependency validation, helping us ensure that required PHP configurations are met before installing packages.

The article’s sections show how to test their PHP versions and configurations on various servers. Periodically checking the frequently updated PHP version and necessary configuration settings helps achieve and sustain website security, stability, and compliance with your applications. Following the PHP releases and maintaining notifications about settings like memory_limit and upload_max_filesize allows you to have a server environment suitable for modern web technologies. In this way, you have the impression that you’re helping tune your server to run better, and the consequences will affect developers and end users exceptionally positively.

Vinayak Baranwal wrote this article. Use the provided link to connect with Vinayak on LinkedIn for more insightful content or collaboration opportunities.
Avery levin
This guide made checking PHP configurations a breeze! Great for anyone managing a server.