How to install PHP Server Monitor in CentOS

Install PHP Server Monitor in CentOS

PHP Server Monitor is a free-ware and web-based monitoring tool. It checks for the websites and server status and allows the user to manage the services through web interface. Installation of PHP Server Monitor is explained in this manual.

To install PHP Server Monitor

Before installing the PHP server monitor, start installing the required package.

[root@linuxhelp1 Desktop]# yum install httpd mariadb-server php php-curl php-cli php-mysql php-pdo -y 
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
 * base: centos.excellmedia.net
 * extras: centos.excellmedia.net
 * updates: centos.excellmedia.net
Resolving Dependencies
-->  Running transaction check
--->  Package httpd.x86_64 0:2.4.6-40.el7.centos.4 will be installed
-->  Processing Dependency: httpd-tools = 2.4.6-40.el7.centos.4 for package: httpd-2.4.6-40.el7.centos.4.x86_64
-->  Processing Dependency: /etc/mime.types for package: httpd-2.4.6-40.el7.centos.4.x86_64
-->  Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.6-40.el7.centos.4.x86_64
-->  Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-40.el7.centos.4.x86_64
.
.
.
Installed:
  httpd.x86_64 0:2.4.6-40.el7.centos.4         mariadb-server.x86_64 1:5.5.50-1.el7_2         php.x86_64 0:5.4.16-36.3.el7_2              
  php-cli.x86_64 0:5.4.16-36.3.el7_2           php-common.x86_64 0:5.4.16-36.3.el7_2          php-mysql.x86_64 0:5.4.16-36.3.el7_2        
  php-pdo.x86_64 0:5.4.16-36.3.el7_2          
Dependency Installed:
  apr.x86_64 0:1.4.8-3.el7                       apr-util.x86_64 0:1.5.2-6.el7                 httpd-tools.x86_64 0:2.4.6-40.el7.centos.4  
  libzip.x86_64 0:0.10.1-8.el7                   mailcap.noarch 0:2.1.41-2.el7                 mariadb.x86_64 1:5.5.50-1.el7_2             
  perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7   perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7   perl-DBD-MySQL.x86_64 0:4.023-5.el7         
  perl-DBI.x86_64 0:1.627-4.el7                  perl-Data-Dumper.x86_64 0:2.145-3.el7         perl-IO-Compress.noarch 0:2.061-2.el7       
  perl-Net-Daemon.noarch 0:0.48-5.el7            perl-PlRPC.noarch 0:0.2020-14.el7            
Dependency Updated:
  mariadb-libs.x86_64 1:5.5.50-1.el7_2                                                                                                     
Complete!

Run the following command to start the apache and mariadb services.

[root@linuxhelp1 Desktop]# systemctl start  mariadb.service
[root@linuxhelp1 Desktop]# systemctl start  httpd.service 


Now start installing mysql by using ' mysql_secure_installation' .

[root@linuxhelp1 Desktop]# mysql_secure_installation 
/usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not found

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we' ll need the current
password for the root user.  If you' ve just installed MariaDB, and
you haven' t set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] 
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!
.
.
.
Remove test database and access to it? [Y/n] 
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] 
 ... Success!

Cleaning up...

All done!  If you' ve completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

To create a database and user for phpmonitor

Utilize the following command to create a database for the PHP Server Monitor.

[root@linuxhelp1 Desktop]# mysql -u root -p 
Enter password: 
Welcome to the MariaDB monitor.  Commands end with   or g.
Your MariaDB connection id is 10
Server version: 5.5.50-MariaDB MariaDB Server
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
Type ' help '  or ' h'  for help. Type ' c'  to clear the current input statement.
MariaDB [(none)]>  create database phpmonitor 
Query OK, 1 row affected (0.00 sec)
Allow “ user1”  to access the “ phpmonitor”  database on localhost with  password.
MariaDB [(none)]>  grant all on phpmonitor.* to ' user1' @' localhost'  identified by ' linuxc'  
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]>  flush privileges 
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]>  exit
Bye


Navigate to apache root directory and download the latest PHP server monitor package.

[root@linuxhelp1 Desktop]# cd /var/www/html/
[root@linuxhelp1 html]# wget http://nchc.dl.sourceforge.net/project/phpservermon/phpservermon/PHP%20Server%20Monitor%20v3.1.1/phpservermon-3.1.1.tar.gz 
--2016-09-15 06:16:45--  http://nchc.dl.sourceforge.net/project/phpservermon/phpservermon/PHP%20Server%20Monitor%20v3.1.1/phpservermon-3.1.1.tar.gz
Resolving nchc.dl.sourceforge.net (nchc.dl.sourceforge.net)... 211.79.60.17, 2001:e10:ffff:1f02::17
Connecting to nchc.dl.sourceforge.net (nchc.dl.sourceforge.net)|211.79.60.17|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1105954 (1.1M) [application/x-gzip]
Saving to: ‘ phpservermon-3.1.1.tar.gz’ 

100%[=================================================================================================> ] 11,05,954    312KB/s   in 3.5s   

2016-09-15 06:16:49 (312 KB/s) - ‘ phpservermon-3.1.1.tar.gz’  saved [1105954/1105954]


Run the following command to extract and rename it as shown below.

[root@linuxhelp1 html]# tar -xvzf phpservermon-3.1.1.tar.gz  
./phpservermon-3.1.1/
./phpservermon-3.1.1/install.php
./phpservermon-3.1.1/vendor/
./phpservermon-3.1.1/vendor/autoload.php
./phpservermon-3.1.1/vendor/twig/
.
.
.
./phpservermon-3.1.1/static/plugin/twitter-bootstrap/css/
./phpservermon-3.1.1/static/plugin/twitter-bootstrap/css/bootstrap-responsive.min.css
./phpservermon-3.1.1/static/plugin/twitter-bootstrap/css/bootstrap.css
./phpservermon-3.1.1/static/plugin/twitter-bootstrap/css/bootstrap.min.css
./phpservermon-3.1.1/static/plugin/twitter-bootstrap/css/bootstrap-responsive.css
./phpservermon-3.1.1/static/plugin/twitter-bootstrap/js/
./phpservermon-3.1.1/static/plugin/twitter-bootstrap/js/bootstrap.min.js
./phpservermon-3.1.1/static/plugin/twitter-bootstrap/js/bootstrap.js
./phpservermon-3.1.1/static/js/
./phpservermon-3.1.1/static/js/scripts.js
./phpservermon-3.1.1/static/js/history.js
./phpservermon-3.1.1/favicon.png
./phpservermon-3.1.1/cron/
./phpservermon-3.1.1/cron/status.cron.php
  [root@linuxhelp1 html]# mv phpservermon-3.1.1 phpservermon  


Execute the following command to change ownership of the directory.

[root@linuxhelp1 html]# chown -R apache:apache /var/www/html/phpservermon 


Open php.ini file to set the time zone as shown below.

[root@linuxhelp1 html]# vim /etc/php.ini 
[Date]
  Defines the default timezone used by the date functions
  http://php.net/date.timezone
date.timezone =Asia_Kolkata


Open the web browser and point to the URL http://< IP_address> /phpservermon. Hit Lets go to proceed further.

Fill up your database and user information. Click on Save Configuration.

If you come across below error, create a config file and copy the information below.

Run the following command to create “ config.php” file inside “ phpservermon” directory.

[root@linuxhelp1 html]# cd phpservermon
[root@linuxhelp1 phpservermon]# vi config.php 
< ?php
define(' PSM_DB_HOST' , ' localhost' ) 
define(' PSM_DB_NAME' , ' phpmonitor' ) 
define(' PSM_DB_USER' , ' user1' ) 
define(' PSM_DB_PASS' , ' linuxc' ) 
define(' PSM_DB_PREFIX' , ' psm_' ) 


Change the ownership of the created file as shown below.

[root@linuxhelp1 phpservermon]# chown -R apache:apache /var/www/html/phpservermon 


Fill up the Username, Password and click install to proceed further.4Hit Go to your monitor, Login to the Server monitor using the login credentials.


Navigate to Server and click Add new to add a new label.

Add your server information and click Save.

Click Update icon to get the latest update.

To view the status of the server, click Status.

FAQ
Q
How do I sent Telegram notifications to a channel?
A
We just follow this steps:
1. Create a public channel.
2. Add the bot as an administrator to the channel.
3. Save chat id as @channelname.
Q
How do I send Telegram notifications to a person?
A
Use the following instructions:
1. Go to @cid_bot (https://t.me/cid_bot) and start.
2. Save your chat id.
3. Press the activation button.
4. Go to your chat with the bot and press start of type /start.
Q
What is PHP Server Monitor?
A
PHP Server Monitor is a free-ware and web-based monitoring tool. It checks for the websites and server status and allows the user to manage the services through the web interface.
Q
What is the log retention period?
A
1. The monitor uses 2 different tables in the database to store history information regarding servers.
2. The retention period tells the monitor how long to keep records in the archive table.
Q
How can I change the text of the email / SMS?
A
Go to the folder “src/lang”, open the language file that corresponds to the selected language (default is English (“en_US.lang.php”)). Scroll all the way to the bottom until you spot this line:

'notifications' => array(
After that, you will see the lines that hold the notification messages. For example:

'off_sms' => 'Server \'%LABEL%\' is DOWN: ip=%IP%, port=%PORT%. Error=%ERROR%',