Table of Contents#
- Prerequisites
- Installing LEMP Stack (Optional - if choosing LEMP)
- Install Nginx
- Install MariaDB/MySQL
- Install PHP
- Installing LAMP Stack (Optional - if choosing LAMP)
- Install Apache
- Install MariaDB/MySQL
- Install PHP
- Installing PHP Server Monitor
- Download the PHP Server Monitor
- Configure Database
- Set up Permissions
- Configure PHP Server Monitor
- Testing the Installation
- Conclusion
- References
1. Prerequisites#
Before we start, make sure your Arch Linux system is up-to-date. You can update it using the following command:
sudo pacman -SyuYou should also have a basic understanding of the command line and have root or sudo privileges.
2. Installing LEMP Stack (Optional - if choosing LEMP)#
Install Nginx#
Nginx is a high-performance web server. Install it using the command:
sudo pacman -S nginxAfter installation, start the Nginx service and enable it to start on boot:
sudo systemctl start nginx
sudo systemctl enable nginxInstall MariaDB/MySQL#
For database management, we'll use MariaDB (a fork of MySQL). Install it with:
sudo pacman -S mariadbInitialize the MariaDB database:
sudo mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysqlStart the MariaDB service and enable it:
sudo systemctl start mariadb
sudo systemctl enable mariadbSecure the MariaDB installation (set root password, remove anonymous users, etc.) by running:
sudo mysql_secure_installationInstall PHP#
PHP is needed to run the PHP Server Monitor. Install the necessary PHP packages:
sudo pacman -S php php-fpm php-mysqlStart the PHP-FPM service and enable it:
sudo systemctl start php-fpm
sudo systemctl enable php-fpm3. Installing LAMP Stack (Optional - if choosing LAMP)#
Install Apache#
Apache is a popular web server. Install it with:
sudo pacman -S apacheStart the Apache service and enable it:
sudo systemctl start httpd
sudo systemctl enable httpdInstall MariaDB/MySQL#
Follow the same steps as in the LEMP stack installation for MariaDB/MySQL (steps 2.2).
Install PHP#
Install PHP packages as in the LEMP stack installation (steps 2.3).
4. Installing PHP Server Monitor#
Download the PHP Server Monitor#
First, create a directory for the PHP Server Monitor. Let's say we create it in /var/www/html/psm:
sudo mkdir -p /var/www/html/psm
sudo chown -R http:http /var/www/html/psmDownload the latest version of PHP Server Monitor from its official website (https://www.phpservermonitor.org/). For example, if it's a tar.gz file:
cd /var/www/html/psm
sudo wget [download link]
sudo tar -xzf [filename].tar.gzConfigure Database#
Log in to the MariaDB/MySQL database as the root user:
mysql -u root -pCreate a new database for PHP Server Monitor (e.g., psm_db):
CREATE DATABASE psm_db;
CREATE USER 'psm_user'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON psm_db.* TO 'psm_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;Set up Permissions#
Make sure the files and directories in the PHP Server Monitor directory have the correct permissions. For example:
sudo chown -R http:http /var/www/html/psm
sudo chmod -R 755 /var/www/html/psmConfigure PHP Server Monitor#
Navigate to the PHP Server Monitor directory (e.g., /var/www/html/psm). Edit the config.php file (you may need to copy it from config.php.dist if it's not already there):
cd /var/www/html/psm
sudo cp config.php.dist config.php
sudo nano config.phpIn the config.php file, set the database credentials (username, password, database name, host) that you created earlier. Also, set other configuration options like email settings (if you want to receive alerts via email).
5. Testing the Installation#
Open your web browser and navigate to the PHP Server Monitor URL. If you installed it in /var/www/html/psm, the URL would be http://your_server_ip/psm. You should see the PHP Server Monitor setup wizard. Follow the wizard steps to complete the initial setup (create administrator user, etc.).
6. Conclusion#
Congratulations! You've successfully installed the PHP Server Monitor tool using either the LEMP or LAMP stack on Arch Linux. Now you can use it to monitor your server's health, check website uptime, and receive alerts when something goes wrong.