Running PHP Server Monitor in Docker on Linux 🌱

What is PHP Server Monitor

PHP Server Monitor is a script that checks whether your websites and servers are up and running. It comes with a web based user interface where you can manage your services and websites, and you can manage users for each server with a mobile number and email address. -https://www.phpservermonitor.org/

Installing Docker

  1. Log into the Linux based device
  2. Run the following commands in the terminal
    # install prerequisites
    sudo apt install apt-transport-https ca-certificates curl software-properties-common gnupg-agent -y
    # add docker gpg key
    curl -fsSL https://download.docker.com/linux/$(awk -F'=' '/^ID=/{ print $NF }' /etc/os-release)/gpg | sudo apt-key add -
    # add docker software repository
    sudo add-apt-repository "deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/$(awk -F'=' '/^ID=/{ print $NF }' /etc/os-release) $(lsb_release -cs) stable"
    # install docker
    sudo apt install docker-ce docker-compose containerd.io -y
    # enable and start docker service
    sudo systemctl enable docker && sudo systemctl start docker
    # add the current user to the docker group
    sudo usermod -aG docker $USER
    # reauthenticate for the new group membership to take effect
    su - $USER

Running PHP Server Monitor

  1. Now that Docker is installed, run the following commands to setup the PHP Server Monitor Docker container and run it
    # run the PHP Server Monitor docker container
    # create working directories
    mkdir /home/$USER/docker/mariadb -p
    # set owner of working directories
    sudo chown "$USER":"$USER" /home/"$USER"/docker -R
    # create phpServerMonitor network
    docker network create phpServerMonitor
    # run the php server monitor docker container
    docker run -d --name phpservermonitor --network phpServerMonitor -p 8080:80 -e MYSQL_HOST=db -e MYSQL_USER=servermon_rw -e MYSQL_PASSWORD=Serv3rM0n! -e MYSQL_DATABASE=server_monitor -e MYSQL_DATABASE_PREFIX= -e TIME_ZONE='America/New_York' -e PSM_REFRESH_RATE_SECONDS=60 -e PSM_AUTO_CONFIGURE=true -v /sessions --restart=unless-stopped phpservermonitor/phpservermon:latest
    # run the mariadb docker container
    docker run -d --name mariadb --network phpServerMonitor --network-alias db -e MYSQL_ROOT_PASSWORD=r00tp@ss -e MYSQL_USER=servermon_rw -e MYSQL_PASSWORD=Serv3rM0n! -e MYSQL_DATABASE=server_monitor -v /home/$USER/docker/mariadb:/var/lib/mysql --restart=unless-stopped mariadb:latest
  2. Open a web browser and navigate to http://DNSorIP:8080/install.php
  3. The PHP Server Monitor setup screen should be displayed
  4. Click the Let's Go button
  5. Create an administrator account by entering a username, password and email address > Click Install
  6. After the installation completes click Go to your monitor
  7. Login with the administator account created earlier
  8. Welcome to PHP Server Monitor

Documentation: https://hub.docker.com/r/phpservermonitor/phpservermon