Get Detailed Server Information in PHP

Welcome to the PHP Server Information Script – a robust script designed to provide valuable insights into your server environment. This script offers a overview of key aspects such as PHP memory usage, system memory details, and OS/Web Server information.

Get Detailed Server Information in PHP

Welcome to the PHP Server Information Script – a robust script designed to provide valuable insights into your server environment. This script offers a overview of key aspects such as PHP memory usage, system memory details, and OS/Web Server information.

This script utilizes PHP functions and conditional checks to retrieve information about the operating system, PHP version, server software, and more.

<?php
// Get detailed system information
$systemInfo = php_uname();
echo "<b>System Information:</b><br>";
echo $systemInfo . "<br><br>";

// Get PHP version and configuration information
echo "<b>PHP Information:</b><br>";
echo "PHP Version: " . phpversion() . "<br>";
echo "PHP Configuration: " . php_ini_loaded_file() . "<br><br>";

// Get server information
echo "<b>Server Information:</b><br>";
echo "Server Software: " . $_SERVER['SERVER_SOFTWARE'] . "<br>";
echo "Server Name: " . $_SERVER['SERVER_NAME'] . "<br>";
echo "Server IP Address: " . $_SERVER['SERVER_ADDR'] . "<br>";
echo "Server Port: " . $_SERVER['SERVER_PORT'] . "<br><br>";

// Get more detailed server information (if available)
$serverInfo = $_SERVER['SERVER_SOFTWARE'];
if (stripos($serverInfo, 'apache') !== false) {
    // Additional Apache server information
    echo "<b>Apache Information:</b><br>";
    $apacheInfo = apache_get_version();
    echo "Apache Version: " . $apacheInfo . "<br>";
    // Add more Apache-specific information if needed
} elseif (stripos($serverInfo, 'nginx') !== false) {
    // Additional Nginx server information
    echo "<b>Nginx Information:</b><br>";

    // Get Nginx version
    $nginxVersion = shell_exec('nginx -v 2>&1');
    echo "Nginx Version: " . $nginxVersion . "<br>";

    // Get Nginx configuration file path
    $nginxConfigPath = shell_exec('nginx -V 2>&1 | grep "configure arguments:"');
    preg_match('/--conf-path=(\S+)/', $nginxConfigPath, $matches);
    echo "Nginx Config File: " . (isset($matches[1]) ? $matches[1] : "N/A") . "<br>";
}

// PHP Memory Usage
$phpMemoryUsage = round(memory_get_usage() / (1024 * 1024), 2); // in megabytes
$phpMemoryLimit = ini_get('memory_limit');

echo "<br><b>PHP Memory Information:</b><br>";
echo "Used PHP Memory: {$phpMemoryUsage} MB<br>";
echo "PHP Memory Limit: {$phpMemoryLimit}<br><br>";

?>
Scroll to Top