PHP Server Monitor is an open-source tool to check whether your websites and servers are up and running. It supports HTTP, TCP, and ICMP checks, with email, SMS, and push notifications.
| File/Directory | Path | Purpose |
|---|---|---|
| Config file | /var/www/html/phpservermonitor/config.php |
Main configuration |
| Database | MySQL/SQLite | Database storage |
| Web files | /var/www/html/phpservermonitor/ |
Application files |
| Cron jobs | /etc/cron.d/phpservermonitor |
Scheduled tasks |
| Logs | /var/log/phpservermonitor/ |
Log files |
| Language files | /var/www/html/phpservermonitor/lang/ |
Translations |
<?php
// /var/www/html/phpservermonitor/config.php
return [
// Application settings
'app' => [
'name' => 'PHP Server Monitor',
'version' => '3.5.2',
'url' => 'https://monitor.example.com',
'timezone' => 'UTC',
'language' => 'en',
],
// Database settings
'db' => [
'driver' => 'mysql', // mysql or sqlite
'host' => 'localhost',
'port' => 3306,
'name' => 'phpservermonitor',
'user' => 'psm',
'password' => 'SecureDbPassword123!',
'prefix' => 'psm_',
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
],
// SQLite settings (if using sqlite)
'sqlite' => [
'path' => '/var/www/html/phpservermonitor/data/database.db',
],
// Security settings
'security' => [
'password_hash' => PASSWORD_DEFAULT,
'password_cost' => 10,
'csrf_protection' => true,
'session_lifetime' => 7200,
'session_secure' => true,
'session_httponly' => true,
],
// Email settings
'email' => [
'enabled' => true,
'smtp' => true,
'host' => 'smtp.example.com',
'port' => 587,
'username' => 'monitor@example.com',
'password' => 'EmailPassword123!',
'encryption' => 'tls',
'from_address' => 'monitor@example.com',
'from_name' => 'PHP Server Monitor',
],
// SMS settings (via Twilio)
'sms' => [
'enabled' => false,
'provider' => 'twilio',
'account_sid' => '',
'auth_token' => '',
'from_number' => '',
],
// Pushover settings
'pushover' => [
'enabled' => false,
'api_token' => '',
],
// Telegram settings
'telegram' => [
'enabled' => false,
'bot_token' => '',
],
// Monitoring settings
'monitoring' => [
// Check intervals (seconds)
'interval' => 60,
// Timeout (seconds)
'timeout' => 30,
// Retry settings
'retry_enabled' => true,
'retry_count' => 3,
'retry_interval' => 30,
// Status settings
'status_history_days' => 30,
'uptime_history_days' => 365,
],
// Alert settings
'alerts' => [
// Enable alerts
'enabled' => true,
// Alert types
'email' => true,
'sms' => false,
'pushover' => false,
'telegram' => false,
// Alert on status change
'status_change' => true,
// Alert on downtime
'downtime' => true,
// Alert on latency threshold (ms)
'latency_threshold' => 1000,
],
// API settings
'api' => [
'enabled' => true,
'key' => 'your-api-key-here',
'rate_limit' => 100,
],
// Logging settings
'logging' => [
'enabled' => true,
'level' => 'info', // debug, info, warning, error
'file' => '/var/log/phpservermonitor/psm.log',
'max_size' => 10485760, // 10MB
'max_files' => 5,
],
// User settings
'users' => [
// Allow user registration
'allow_registration' => false,
// Email verification required
'email_verification' => true,
// Password requirements
'min_password_length' => 8,
'require_uppercase' => true,
'require_lowercase' => true,
'require_digit' => true,
],
// UI settings
'ui' => [
// Items per page
'items_per_page' => 25,
// Auto refresh (seconds)
'auto_refresh' => 30,
// Show/hide columns
'show_last_check' => true,
'show_uptime' => true,
'show_latency' => true,
'show_status' => true,
],
];
<?php
// Server types and settings
return [
'servers' => [
// Website (HTTP/HTTPS)
[
'label' => 'Main Website',
'type' => 'website',
'ip' => 'https://example.com',
'port' => 443,
'request_method' => 'GET',
'post_field' => '',
'timeout' => 30,
'website_username' => '',
'website_password' => '',
'website_url' => '',
'website_status_code' => 200,
'website_keyword' => '',
'website_keyword_checked' => false,
'active' => true,
],
// Service (TCP)
[
'label' => 'MySQL Server',
'type' => 'service',
'ip' => '192.168.1.20',
'port' => 3306,
'timeout' => 10,
'active' => true,
],
// Ping (ICMP)
[
'label' => 'Router',
'type' => 'ping',
'ip' => '192.168.1.1',
'port' => 0,
'timeout' => 5,
'active' => true,
],
],
];
<?php
// Notification settings
return [
'notifications' => [
// Email notification
'email' => [
[
'user_id' => 1,
'email' => 'admin@example.com',
'status_email' => true,
'status_sms' => false,
'status_pushover' => false,
'status_telegram' => false,
],
],
// SMS notification (Twilio)
'sms' => [
[
'user_id' => 1,
'phone' => '+1234567890',
'active' => true,
],
],
// Pushover notification
'pushover' => [
[
'user_id' => 1,
'pushover_user_key' => 'your-pushover-key',
'active' => true,
],
],
// Telegram notification
'telegram' => [
[
'user_id' => 1,
'telegram_chat_id' => 'your-chat-id',
'active' => true,
],
],
],
];
# Check PHP syntax
php -l /var/www/html/phpservermonitor/config.php
# Test database connection
php /var/www/html/phpservermonitor/cli.php db:test
# Run health check
php /var/www/html/phpservermonitor/cli.php health:check
# Install/upgrade database
php /var/www/html/phpservermonitor/cli.php db:install
# Run migrations
php /var/www/html/phpservermonitor/cli.php db:migrate
# Backup database
mysqldump -u psm -p phpservermonitor > /var/backups/psm/backup.sql
# /etc/cron.d/phpservermonitor
# Run monitoring every minute
* * * * * www-data php /var/www/html/phpservermonitor/cron.php >> /var/log/phpservermonitor/cron.log 2>&1
# Clean up old logs weekly
0 0 * * 0 www-data php /var/www/html/phpservermonitor/cli.php cleanup:logs >> /var/log/phpservermonitor/cleanup.log 2>&1
# Restart PHP-FPM
sudo systemctl restart php-fpm
# Restart web server
sudo systemctl restart nginx
# or
sudo systemctl restart apache2
# View logs
sudo tail -f /var/log/phpservermonitor/psm.log
# Access web interface
curl http://localhost/phpservermonitor/
# Check API
curl http://localhost/phpservermonitor/api/status
# Check health endpoint
curl http://localhost/phpservermonitor/health
# Run manual check
php /var/www/html/phpservermonitor/cli.php server:check --id=1
# List all servers
php /var/www/html/phpservermonitor/cli.php server:list
# Check server status
php /var/www/html/phpservermonitor/cli.php server:status --id=1
# Test email notification
php /var/www/html/phpservermonitor/cli.php notification:test --type=email --user=1
# Test SMS notification
php /var/www/html/phpservermonitor/cli.php notification:test --type=sms --user=1
Every deployment is unique. We provide consulting for:
Get personalized assistance: office@linux-server-admin.com | Contact Page