Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

Set up a simple server status page

A status page shows the load, memory and disk of your server in one place. This guide builds a small one with PHP. It needs root access, so it is for VPS and dedicated server users.

Web Hosting2 min read9 steps1 screenshots

What is a status script?

A script is a small file of instructions. This one asks the server how busy it is and prints the answer on a web page. It works like a car dashboard. You glance at it to see if everything is fine.

Before you start

  • Your server needs a web server and PHP already installed.
  • The page shows private details. Protect it with a password, as shown below.

Step 1: Create the file

  1. Connect to your server with SSH.
  2. Make a new folder inside your website folder. Replace the path with your own web root:
mkdir /var/www/html/status
  1. Open a new file:
nano /var/www/html/status/index.php
  1. Paste this code:
<?php
$load = sys_getloadavg();
$free = disk_free_space("/");
$total = disk_total_space("/");
echo "<h1>Server status</h1>";
echo "<p>Load (1, 5, 15 min): " . implode(", ", $load) . "</p>";
echo "<p>Disk free: " . round($free / 1073741824, 1) . " GB of "
   . round($total / 1073741824, 1) . " GB</p>";
echo "<pre>" . htmlspecialchars(shell_exec("uptime; free -m")) . "</pre>";
?>

The load number tells how hard the CPU is working. The code also prints uptime and memory use.

  1. Save with Ctrl+O, press Enter, then leave with Ctrl+X.

Step 2: Lock it with a password

  1. Create a password file:
htpasswd -c /etc/status.htpasswd admin

This asks you to choose a password for the user "admin".

  1. Add these lines to a file called .htaccess in the status folder (Apache):
AuthType Basic
AuthName "Status"
AuthUserFile /etc/status.htpasswd
Require valid-user

On Nginx, use the auth_basic setting instead.

Step 3: Open the page

  1. Visit http://YOUR_SERVER_IP/status/ in a browser.
  2. Enter the user and password.
Tip: If shell_exec is disabled in your PHP, delete that last echo line. The page still works without it.

Quick recap

  • A status page shows load, disk and memory.
  • Make a small PHP file in its own folder.
  • Always protect the page with a password.
    Screenshot: Always protect the page with a password.
  • Delete the script when you no longer need it.