🚀 API Monitoring System
Complete Installation & Usage Guide
🌟 Introduction
What is API Monitoring System?
API Monitoring System is a professional, self-hosted solution that monitors your APIs, websites, and web services 24/7. It provides real-time monitoring, instant email alerts, comprehensive metrics, and a beautiful mobile-first admin panel.
📱 Mobile-First
Fully responsive admin panel works perfectly on all devices
🌐 All HTTP Methods
GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS
🔧 Auto-Fix
One-click PHPMailer installation and permission fixing
📧 Smart Alerts
Beautiful HTML email notifications with detailed metrics
💰 No Monthly Fees
One-time purchase, self-hosted on your server
🔒 Secure
Multiple security layers, .htaccess protection
💻 System Requirements
Minimum Requirements
| Component | Requirement |
|---|---|
| PHP Version | 8.1 or higher (Compatible with 8.4) |
| Memory | 128MB RAM minimum, 256MB recommended |
| Disk Space | 50MB for application + logs |
| PHP Extensions | json (built-in), curl, openssl, mbstring |
Supported Platforms
- ✅ Shared Hosting - cPanel, Plesk
- ✅ VPS - Ubuntu, Debian, CentOS, RHEL
- ✅ Cloud - AWS, DigitalOcean, Linode, Vultr
- ✅ Dedicated Servers - Linux, Windows
- ✅ Docker - Containers supported
✅ Pre-Installation Checklist
Before starting installation, ensure you have:
- FTP/SFTP credentials or File Manager access
- SSH access (VPS) or cPanel access
- Domain or subdomain configured
- SSL certificate (recommended)
- SMTP email credentials (Gmail, Outlook, or custom)
- PHP 8.1+ verified
- Required PHP extensions installed
Quick PHP Version Check
# Run this command:
php -v
# Should show: PHP 8.1.0 or higher
Quick Extensions Check
# Check installed extensions:
php -m | grep -E 'curl|json|openssl|mbstring'
# All should be listed
🎛️ cPanel Installation (Shared Hosting)
Perfect for shared hosting with cPanel access. This is the easiest method for most users.
Access your cPanel dashboard using credentials from your hosting provider.
Navigate to File Manager → public_html (or your domain's directory)
- Click "Upload" button
- Select
api-monitoring-v1.0.0.zip - Wait for upload to complete
- Right-click on ZIP file
- Select "Extract"
- Extract to current directory
- Delete ZIP file after extraction
- Go to "Select PHP Version" or "MultiPHP Manager"
- Select PHP 8.1 or higher
- Enable extensions: curl, json, openssl, mbstring
Open: http://yourdomain.com/install.php
Follow 6-step wizard (see Installation Wizard section)
- Go to "Cron Jobs" in cPanel
- Common Settings: "Every 5 minutes"
- Command:
cd /home/username/public_html && php cron.php - Click "Add New Cron Job"
http://yourdomain.com/admin/
🖥️ VPS Installation (Ubuntu/Debian)
For VPS servers running Ubuntu 20.04+ or Debian 10+.
Step 1: Connect to VPS
ssh root@your-server-ip
# Or with regular user:
ssh username@your-server-ip
Step 2: Update System
sudo apt update
sudo apt upgrade -y
Step 3: Install PHP 8.1+
# Add PHP repository
sudo apt install software-properties-common -y
sudo add-apt-repository ppa:ondrej/php -y
sudo apt update
# Install PHP and extensions
sudo apt install php8.1 php8.1-cli php8.1-curl \
php8.1-mbstring php8.1-xml php8.1-zip -y
# Verify
php -v
Step 4: Install Web Server
Option A: Apache
sudo apt install apache2 libapache2-mod-php8.1 -y
sudo systemctl start apache2
sudo systemctl enable apache2
Option B: Nginx + PHP-FPM
sudo apt install nginx php8.1-fpm -y
sudo systemctl start nginx php8.1-fpm
sudo systemctl enable nginx php8.1-fpm
Step 5: Create Directory and Upload Files
# Create directory
sudo mkdir -p /var/www/html/monitoring
# Upload via SCP (from your computer)
scp api-monitoring-v1.0.0.zip user@server:/tmp/
# Extract on server
sudo unzip /tmp/api-monitoring-v1.0.0.zip -d /var/www/html/monitoring/
Step 6: Set Permissions
cd /var/www/html/monitoring
# Set ownership
sudo chown -R www-data:www-data .
# Use auto-fix script
sudo -u www-data php setup_permissions.php
# Or manually:
sudo chmod 666 config.json.example
sudo chmod 755 data
sudo chmod 666 data/*.json
Step 7: Configure Apache Virtual Host
sudo nano /etc/apache2/sites-available/monitoring.conf
Add this configuration:
<VirtualHost *:80>
ServerName monitor.yourdomain.com
DocumentRoot /var/www/html/monitoring
<Directory /var/www/html/monitoring>
Options -Indexes +FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Enable site and reload:
sudo a2ensite monitoring.conf
sudo a2enmod rewrite
sudo systemctl reload apache2
Step 8: Install SSL (Recommended)
# Install Certbot
sudo apt install certbot python3-certbot-apache -y
# Get certificate
sudo certbot --apache -d monitor.yourdomain.com
Step 9: Run Installation Wizard
Open browser: http://monitor.yourdomain.com/install.php
Step 10: Set Up Cron Job
# Edit crontab for web server user
sudo crontab -u www-data -e
# Add this line (runs every 5 minutes):
*/5 * * * * cd /var/www/html/monitoring && php cron.php >> /dev/null 2>&1
🖥️ VPS Installation (CentOS/RHEL)
For VPS servers running CentOS 8+ or RHEL 8+.
Install PHP 8.1+
# Enable repositories
sudo dnf install epel-release -y
sudo dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm -y
# Enable PHP 8.1
sudo dnf module reset php -y
sudo dnf module enable php:remi-8.1 -y
# Install PHP and extensions
sudo dnf install php php-cli php-curl php-mbstring \
php-xml php-zip php-json -y
# Verify
php -v
Install Apache
sudo dnf install httpd -y
sudo systemctl start httpd
sudo systemctl enable httpd
Configure Firewall
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
Follow similar steps as Ubuntu for file upload, permissions, and configuration.
🧙 Web-Based Installation Wizard
The installation wizard automates the entire setup process. Simply access http://yourdomain.com/install.php and follow these 6 steps:
Step 1: System Requirements Check
The wizard checks:
- ✅ PHP version (8.1+ required)
- ✅ Required PHP extensions
- ✅ File permissions
- ✅ Directory structure
Step 2: System Configuration
| Setting | Description |
|---|---|
| System Name | Your monitoring system name (used in emails and dashboard) |
| Timezone | Select from 400+ timezones (all timestamps use this) |
| Monitoring Interval | How often to check endpoints (1-60 minutes, default: 5) |
| Max Retries | Retry attempts before alerting (1-10, default: 3) |
| Timeout | Request timeout in seconds (5-120, default: 30) |
Step 3: Email Configuration
Gmail SMTP Setup:
- SMTP Host:
smtp.gmail.com - SMTP Port:
587 - Encryption:
TLS - Username: Your Gmail address
- Password: App-specific password (not regular password)
- Go to Google Account → Security
- Enable 2-Factor Authentication
- Go to App Passwords
- Generate password for "Mail"
- Use 16-character password in wizard
Outlook SMTP Setup:
- SMTP Host:
smtp-mail.outlook.com - SMTP Port:
587 - Encryption:
TLS
Step 4: First API Endpoint (Optional)
Add your first endpoint to monitor:
- Name: Descriptive name (e.g., "Main Website")
- URL: Full URL (e.g., https://api.example.com/health)
- Method: Select from 7 HTTP methods (GET is most common)
- Expected Text: Optional text to find in response
Step 5: Admin Credentials
Create your admin account for the admin panel.
Step 6: Complete Installation
Review summary and click "Complete Installation". The wizard will:
- Create configuration file
- Initialize data files
- Test settings
- Delete install.php (security)
http://yourdomain.com/admin/
⚙️ Manual Configuration
If you prefer manual setup or the wizard isn't working:
Create Configuration File
cp config.json.example config.json
nano config.json
Basic Configuration Example
{
"timezone": "America/New_York",
"system_name": "My API Monitor",
"monitoring_interval": 300,
"email": {
"smtp_host": "smtp.gmail.com",
"smtp_port": 587,
"smtp_username": "[email protected]",
"smtp_password": "your-app-password",
"smtp_encryption": "tls",
"from_email": "[email protected]",
"from_name": "API Monitoring",
"to_email": "[email protected]"
},
"endpoints": {
"Main API": {
"url": "https://api.example.com/health",
"method": "GET",
"timeout": 30,
"max_retries": 3,
"expected_text": "ok",
"headers": [],
"post_data": null
}
}
}
Set Permissions
chmod 666 config.json
chmod 755 data
chmod 666 data/*.json
touch api_monitor.log
chmod 666 api_monitor.log
Test Configuration
# Validate config
php validate_config.php
# Test monitoring
php cron.php
# Check logs
tail api_monitor.log
⏰ Setting Up Cron Jobs
Cron jobs automate the monitoring process. The system needs to run cron.php periodically.
cPanel Cron Setup
- Login to cPanel
- Go to "Cron Jobs"
- Common Settings: Select "Every 5 minutes"
- Command:
cd /home/username/public_html/monitoring && php cron.php >> /dev/null 2>&1
Or with full PHP path:
/usr/bin/php /home/username/public_html/monitoring/cron.php >> /dev/null 2>&1
VPS/Linux Cron Setup
# Edit crontab for web server user
sudo crontab -u www-data -e
# Add this line (every 5 minutes):
*/5 * * * * cd /var/www/html/monitoring && php cron.php >> /dev/null 2>&1
Different Intervals
| Interval | Cron Expression | Use Case |
|---|---|---|
| Every 1 minute | * * * * * |
Critical APIs |
| Every 5 minutes | */5 * * * * |
Recommended default |
| Every 10 minutes | */10 * * * * |
Standard monitoring |
| Every 15 minutes | */15 * * * * |
Light monitoring |
| Every 30 minutes | */30 * * * * |
Low priority |
Verify Cron is Running
# List cron jobs
crontab -l
# Check application logs
tail -f api_monitor.log
# Should see entries every 5 minutes
🎛️ Using the Admin Panel
Access: http://yourdomain.com/admin/
Dashboard Page
Overview of your monitoring system:
- Metrics Cards: Total uptime, average response time, success rate
- Activity Log: Recent monitoring events
- Quick Actions: Test endpoint, view logs, configure
- Endpoint Status: Visual status of all endpoints
API Endpoints Page
Adding New Endpoint
- Click "Add New Endpoint"
- Fill in details:
- Name: Descriptive identifier
- URL: Full URL with https://
- Method: Select from 7 HTTP methods
- Timeout: 5-120 seconds
- Max Retries: 1-10 attempts
- Expected Text: Optional validation
- Headers: One per line (optional)
- Request Body: For POST/PUT/PATCH (auto shows/hides)
- Click "Test Endpoint" to verify before saving
- Click "Add Endpoint" to save
HTTP Methods Explained
| Method | Use Case | Request Body |
|---|---|---|
| 📥 GET | Retrieve data from server | ❌ No |
| 📤 POST | Create/Submit data | ✅ Yes |
| ✏️ PUT | Update/Replace entire resource | ✅ Yes |
| 🔧 PATCH | Partial update | ✅ Yes |
| 🗑️ DELETE | Remove data | ❌ No |
| 📋 HEAD | Headers only (metadata) | ❌ No |
| 🔍 OPTIONS | Check capabilities (CORS) | ❌ No |
Configuration Page
Email Testing (AJAX)
- Scroll to "Test Email Configuration"
- Enter test email address
- Select type:
- Simple Test - Basic email
- UP Alert - Service restored (fake data)
- DOWN Alert - Service down (fake data)
- Click "Send Test Email"
- See result instantly (no page refresh)
- Check inbox and spam folder
Cron Job Setup Guide
The page automatically detects your PHP path and provides copy-paste cron commands for:
- Linux/macOS (crontab)
- cPanel
- Windows Task Scheduler
System Check Page
Comprehensive diagnostics with one-click fixes:
Auto-Fix Features:
- 🔧 Install PHPMailer - One-click installation
- Tries 4 different methods
- Detailed error reporting if fails
- Manual instructions provided
- 🔧 Fix Permissions - Automatically sets correct chmod values
- 🔧 Create Missing Files - Generates required data files
Logs Page
View, download, and manage logs:
- Pagination (50 entries per page)
- Log statistics dashboard
- Download logs button
- Clear logs button
- Auto-refresh option
Mobile Navigation
On mobile devices:
- ☰ Hamburger menu in top-left
- Tap to open/close sidebar
- Touch-friendly 44px buttons
- Optimized font sizes
- Perfect on all screen sizes
🔒 Security Hardening
Essential steps to secure your installation after setup.
1. Delete Install File
install.php
# Via SSH:
rm install.php
# Via cPanel: Delete install.php in File Manager
2. Secure Admin Panel
Method A: Password Protection (.htaccess)
# Create password file
htpasswd -c /path/to/.htpasswd admin
# Edit admin/.htaccess and add:
AuthType Basic
AuthName "Admin Panel Access"
AuthUserFile /full/path/to/.htpasswd
Require valid-user
Method B: IP Restriction
# Edit admin/.htaccess and add:
Order deny,allow
Deny from all
Allow from YOUR_IP_ADDRESS
Allow from YOUR_OFFICE_IP
Method C: Rename Admin Directory
mv admin my-secret-admin-xyz
# Access via: http://yourdomain.com/my-secret-admin-xyz/
3. Enable HTTPS (SSL)
# Free SSL with Let's Encrypt
sudo apt install certbot python3-certbot-apache -y
sudo certbot --apache -d monitor.yourdomain.com
Force HTTPS redirect in .htaccess:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
4. Protect Configuration File
# After setup, make read-only
chmod 444 config.json
# When need to edit:
chmod 644 config.json
# ... make changes ...
chmod 444 config.json
5. Configure Firewall (VPS)
# UFW (Ubuntu/Debian)
sudo ufw enable
sudo ufw allow 22 # SSH
sudo ufw allow 80 # HTTP
sudo ufw allow 443 # HTTPS
# Firewalld (CentOS/RHEL)
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
6. Change Admin Password
After first login:
- Use a password manager
- Create strong, unique password (12+ characters)
- Mix uppercase, lowercase, numbers, symbols
- Never share password
Security Checklist
- install.php deleted
- HTTPS enabled
- Admin password strong and unique
- File permissions correct (666/755)
- Data directory protected (.htaccess)
- Firewall configured (VPS)
- Regular backups scheduled
- Log monitoring enabled
⚡ Post-Installation Configuration
1. Add More Endpoints
Prioritize by importance:
- Critical - Payment gateways, authentication (check every 1-5 min)
- Important - Main services, databases (check every 5-10 min)
- Standard - General endpoints (check every 10-15 min)
- Low Priority - Non-critical APIs (check every 15-30 min)
2. Configure Response Validation
For each endpoint, set "Expected Text" to verify correct response:
"status":"ok"- JSON response"healthy":true- Health checksuccess- Simple textrunning- Service status
3. Test Email Alerts
- Go to Configuration → Test Email
- Send all 3 types (Simple, UP, DOWN)
- Verify emails arrive
- Check spam folder
- Whitelist sender email
4. Set Up Regular Backups
# Weekly backup (Sundays at 2 AM)
0 2 * * 0 cd /var/www/html/monitoring && php backup_data.php
5. Monitor the Monitor
- Check dashboard daily (first week)
- Review logs weekly
- Verify email delivery
- Check cron is running
- Monitor disk space
💾 Backup & Maintenance
Automated Backups
# Run included backup script
php backup_data.php
# Creates: backup-YYYYMMDD-HHMMSS.tar.gz
# Contains: config.json, data/*.json, logs
Manual Backup
# Full backup (VPS)
tar -czf monitoring-backup-$(date +%Y%m%d).tar.gz \
config.json data/ api_monitor.log
# Download
scp user@server:/path/to/monitoring-backup-*.tar.gz ./
Restore from Backup
# Extract
tar -xzf backup-YYYYMMDD-HHMMSS.tar.gz
# Restore files
cp backup/config.json config.json
cp backup/data/*.json data/
# Set permissions
chmod 666 config.json data/*.json
Regular Maintenance
| Frequency | Tasks |
|---|---|
| Weekly | Check dashboard, review incidents, verify backups |
| Monthly | Update PHP, check for script updates, test email alerts |
| Quarterly | Review security, update SSL, test disaster recovery |
🔧 Troubleshooting
Common Issues
Issue: Email alerts not sending
Solutions:
- Test email in Configuration page
- Check SMTP credentials are correct
- For Gmail: Use App Password (not regular password)
- Check spam folder
- Verify PHPMailer installed (System Check page)
- Check logs:
tail api_monitor.log
Issue: Permission denied errors
# Quick fix
php setup_permissions.php
# Or manually
chmod 666 config.json data/*.json api_monitor.log
chmod 755 data
Issue: Cron not running
# Check cron service
sudo systemctl status cron # Ubuntu
sudo systemctl status crond # CentOS
# List cron jobs
crontab -l
# Test manually
php cron.php
Issue: Metrics showing 0ms
Cause: cURL or OpenSSL not installed
# Install extensions
sudo apt install php8.1-curl php8.1-openssl
sudo systemctl restart apache2
Issue: Admin panel not responsive on mobile
Solutions:
- Clear browser cache
- Hard refresh: Ctrl+F5 (Windows) or Cmd+Shift+R (Mac)
- Try different browser
- Check console for errors (F12)
❓ Frequently Asked Questions
General Questions
Q: Do I need a database?
A: No! Uses JSON files for storage. Easy to deploy, backup, and migrate.
Q: Can I monitor unlimited endpoints?
A: Yes! No artificial limits. Successfully tested with 100+ endpoints.
Q: Does it support all HTTP methods?
A: Yes! All 7 methods (GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS) with smart request body handling.
Q: Will it work on shared hosting?
A: Yes! As long as you have PHP 8.1+ and cron access. Auto-fix handles common issues.
Q: Is it really mobile-first?
A: Yes! Fully responsive with touch-friendly interface, collapsible sidebar, optimized for all screen sizes.
Installation Questions
Q: How long does installation take?
A: 5-10 minutes with web wizard. Manual installation: 15-30 minutes.
Q: Can I install in a subdirectory?
A: Yes! Install anywhere: root, subdirectory, or subdomain.
Q: Do I need SSH access?
A: No for cPanel. SSH helpful for VPS but not required.
Email Questions
Q: Why aren't emails sending?
A: Common causes:
- Wrong SMTP credentials
- Port 587 blocked by firewall
- Gmail: Using regular password instead of app password
- PHPMailer not installed (use auto-fix)
- Emails in spam folder
Q: Can I use free Gmail?
A: Yes! Enable 2FA and generate App Password.
Q: Can I send to multiple recipients?
A: Yes! Comma-separated: [email protected], [email protected]
Security Questions
Q: Is it secure?
A: Yes! Multiple security layers: .htaccess protection, password hashing, input validation, XSS prevention.
Q: Should I use HTTPS?
A: Yes, highly recommended! Free SSL with Let's Encrypt.
Q: Can I restrict admin access by IP?
A: Yes! Edit admin/.htaccess with IP restrictions.
⚡ Quick Reference
Essential Commands
# Installation
cp config.json.example config.json
php setup_permissions.php
# Test monitoring
php cron.php
# View logs
tail -f api_monitor.log
# Backup data
php backup_data.php
# Validate config
php validate_config.php
File Locations
| File/Directory | Purpose | Permission |
|---|---|---|
config.json |
Main configuration | 666 (rw-rw-rw-) |
data/ |
Monitoring data storage | 755 (rwxr-xr-x) |
data/*.json |
Status, metrics, incidents | 666 (rw-rw-rw-) |
api_monitor.log |
Activity logs | 666 (rw-rw-rw-) |
Default URLs
- Installation:
http://yourdomain.com/install.php - Admin Panel:
http://yourdomain.com/admin/ - Landing Page:
http://yourdomain.com/
📞 Support & Resources
📚 Documentation
README.md (2,100+ lines)
This HTML guide
🔍 System Check
Admin Panel → System Check
Auto-fix available
📝 Logs
api_monitor.log
Detailed error messages
🎉 Congratulations!
You're now ready to monitor your APIs 24/7 with confidence!
Next Steps:
- ✅ Add your critical API endpoints
- ✅ Set up email alerts and test them
- ✅ Configure cron job
- ✅ Wait 5 minutes and check Dashboard
- ✅ Secure your installation
- ✅ Set up regular backups
Thank you for choosing API Monitoring System!
Monitor with Confidence. Stay Informed. Never Miss a Downtime.