0% found this document useful (0 votes)
22 views

PHP Server Monitor - Windows Setup Guide - IT Imagination

Uploaded by

Cristian Paul
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

PHP Server Monitor - Windows Setup Guide - IT Imagination

Uploaded by

Cristian Paul
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

12/21/21, 4:39 PM PHP Server Monitor - Windows Setup Guide - IT Imagination

IT Imagination
Adventuring through a world of fun and an ocean of pain. A day in the life of a sysadmin.

PHP Server Monitor – Windows Setup


Guide

Want to use PHP Server Monitor to track the uptime status of your devices? Not ready
to build a CentOS or Ubuntu Server instance, but would rather have a Windows-
install?

There are three primary methods to configuring an AMP stack.

1. LAMP (Linux, Apache, MySQL, PHP)


2. WAMP (Windows Desktop or Server, Apache, MySQL, PHP)
3. IIS/PHP (Windows Server with Internet Information Services Role, MySQL, PHP)

This will be focusing on the Windows Desktop option. It’s lower performance than
Linux or IIS, but it sure is easier for beginners, and easier to move between hosts.

Win10 + XAMPP
https://itimagination.com/php-server-monitor-windows-setup-guide/ 1/9
12/21/21, 4:39 PM PHP Server Monitor - Windows Setup Guide - IT Imagination

This tool has been around for many, many years. The code base made be old, but it’s
free, still updated, and very reliable.

Appropriate for a small one-off server.

In my case, I’m using a Win10 Enterprise VM and loading on XMAPP.

https://www.apachefriends.org/index.html

Go snag XAMPP (32 Bit only for Windows). There is also a portable version if you don’t
want a permanent install (e.g. run off a thumb-drive).

Run the installer, it is recommended to not install to Program Files directories due to
weird permissions with UAC. Recommend installing to root, e.g. C:\XAMPP.

You only need Apache, MySQL, and PHP.

Start it, let it open up the XAMPP control panel.

Download PHPServerMonitor
Go to C:\xampp\htdocs, copy the contents to C:\xampp\htdocs.old, create the
directory if it does not exist.

Go snag a download of PHP Server Monitor —


https://github.com/phpservermon/phpservermon

Click download to ZIP in the upper right.

Unzip the ZIP contents into your operating PHP directory, by default: C:\xampp\htdocs
https://itimagination.com/php-server-monitor-windows-setup-guide/ 2/9
12/21/21, 4:39 PM PHP Server Monitor - Windows Setup Guide - IT Imagination

Download Composer
Composer is a dependency packager — it downloads and auto-installs the pieces that
PHP Server Monitor depends on.

https://getcomposer.org/download/

The installer will add the composer.exe file into your Windows environment path,
allowing you to run it from command line in any directory. The installer should also
auto-detect your xampp install, and the operating directory of C:\xamp\htdocs.

When the command “composer install” is run, it will look for a .JSON file inside the
directory it is being run. This contains the instructions of what composer needs to do.

1. Start > cmd.exe > Right-Click > Run as Administrator


2. cd C:\xampp\htdocs
3. composer install

Give it a few minutes, and it should auto-download all of the dependencies.

https://itimagination.com/php-server-monitor-windows-setup-guide/ 3/9
12/21/21, 4:39 PM PHP Server Monitor - Windows Setup Guide - IT Imagination

Start the Server Up, Build the Database


1. Browse to C:\xampp\htdocs\
1. Find config.php.sample, Copy/Paste it in the same directory, and
rename to config.php
2. Open XAMPP Control panel, if they are running, stop Apache and MySQL. Then
start them both up, MySQL first.
3. Browse to: http://localhost
1. It should redirect you to http://localhost/install.php
2. Hopefully, you see some pre-requisite success messages.
4. If so, open XAMPP, click “Shell”

1. mysql -u root -p
2. [Password is blank, just hit enter]
3.
4. create database phpsrvmon;
5. #Change your user and password in quotes
6. create user phpsrvmon_user@localhost identified by "user_password";
7. #Make this match the user above
8. grant all privileges on phpsrvmon.* to phpsrvmon_user@localhost;
9. flush privileges;
10. quit

https://itimagination.com/php-server-monitor-windows-setup-guide/ 4/9
12/21/21, 4:39 PM PHP Server Monitor - Windows Setup Guide - IT Imagination

Configure the Database


Open XMAPP, ensure both stop/start Apache and MySQL.

Browse to: http://localhost, you should be redirected back


to: http://localhost/install.php

Application Base URL: http://something.yourdomain.com


Database Host: localhost
Database Port 3306 (You can confirm within XAMPP.
Database Name: phpsrvmon
Database User: phpsrvmon_user (or whatever you entered)
Database Password: user_password (you picked something different right?)
Table Prefix: psm_

Save Configuration

https://itimagination.com/php-server-monitor-windows-setup-guide/ 5/9
12/21/21, 4:39 PM PHP Server Monitor - Windows Setup Guide - IT Imagination

You may get an error, “Unable to save your configuration”. It should cough out the code
you can copy/paste into a config.php file.

If so, open your config.php file, and overwrite the code with what it provided. If you
don’t have it, it looks like this:

1. <?php
2. define('PSM_DB_HOST', 'localhost');
3. define('PSM_DB_PORT', '3306');
4. define('PSM_DB_NAME', 'phpsrvmon');
5. define('PSM_DB_USER', 'phpsrvmon_user');
6. define('PSM_DB_PASS', 'your password');
7. define('PSM_DB_PREFIX', 'psm_');
8. define('PSM_DB_BASEURL', 'http://something.yourdomain.com');

Save the file config.php, go back to XAMPP, and stop/start Apache to load in the new
settings.

Create your Web-Account


Go back to http://localhost

You should get the message, “Sweet, your database connection is up and running!”

Now create a username, password, and email — this is for actually using the website,
nothing to do with the database infrastructure.

Create a Monitor
Login to your site, it will redirect to your web-URL by the way, so ensure it can be
resolved by your DNS server. If you’re desperate, you can always edit the Windows
HOSTS file.

Open the “Servers” tab.

https://itimagination.com/php-server-monitor-windows-setup-guide/ 6/9
12/21/21, 4:39 PM PHP Server Monitor - Windows Setup Guide - IT Imagination

Add New (+) > Add a DNS address or IP, select a ping, or a matching service/port. It is
important to set a threshold, I typically use a Warning Threshold of 2, meaning after 1
query it is a warning (amber), after 2 it is an alert (red). I use a timeout of 10 seconds
usually, just in-case latency is high. Check off the users you want to be able to view the
monitor.

Configure the Scheduler/CRON


We have our monitors, but we need a way to run the port/ping query, this is not run
automatically. On Linux, it is run via CRON. On Windows, it is run via the Task
Scheduler.

https://itimagination.com/php-server-monitor-windows-setup-guide/ 7/9
12/21/21, 4:39 PM PHP Server Monitor - Windows Setup Guide - IT Imagination

Start > Run > taskschd.msc > OK


Task Scheduler Library > Right-Click > Create Basic Task
Name: “PHP Server Monitor Query”
Run: One Time
Action: Start a Program: C:\xampp\php\php.exe
Add Arguments:C:\xampp\htdocs\cron\status.cron.php –
timeout=1
The timeout number is the timer of cron in minutes,
default is 10 minutes.
Next > Open Properties Box
Check: Run whether user is logged on or not.
Trigger Tab > Select > Edit
One Time, Advanced Settings > Repeat Task Every: 5 minutes, then
change 5 to 1, for a duration of: Indefinitely
Note — If you have a large number of monitors (e.g. 100+)
increase the timer appropriately. A general guideline is 20
seconds for each 100 monitors.
Ensure your Repeat Task Every number matches your timeout
value in the Arguments.
Stop task if it runs longer than: 30 minutes, adjust to 3 minutes.
Conditions Tab > Uncheck power settings that relate to AC and battery power.
Settings Tab
Check: Allow task to be run on demand
Stop the task if it runs longer than: 1 hour
Check: If the running task does not end when requested, force it to stop.
If the task is already running, then the following rule applies: Stop the
existing instance.
OK > Enter your password to run the task as an adminstrator when logged off.

Final Settings / Little Details


Autostart

https://itimagination.com/php-server-monitor-windows-setup-guide/ 8/9
12/21/21, 4:39 PM PHP Server Monitor - Windows Setup Guide - IT Imagination

While in XAMPP, configure the services to autostart on boot. Click: Config > Check:
Apache, MySQL

Fixing Queries (Important!)


By default, you will only get a single query every 10 minutes, as the stock XAMPP
php.ini file causes the cron script to get stuck in running mode until it times out after 10
minutes.

Open Notepad, and open: C:\xampp\php\php.ini

Ctrl+F to search, search for: extension=sockets

There will be a comment in front of it ” ; “, remove the semicolon to make the code
active, save php.ini. Go back to XAMPP, and stop/start Apache.

Now get those monitors added, and keep and eye on all your important gear. Good
luck!

Tagged as: guide, monitor, php, server, setup, windows, xampp

Categorized in: Projects, Useful Coding

Posted on December 5, 2018 by Dan Kruse

Decode Theme by Macho Themes

https://itimagination.com/php-server-monitor-windows-setup-guide/ 9/9

You might also like