Phronix Marks 21 Years Of Reporting On Linux Hardware
Celebrating two decades of delivering valuable insights into the world of Linux hardware, Phronix continues to be a trusted resource for sysadmins and DevOps engineers alike. In this article, we'll.
# Phronix Marks 21 Years Of Reporting On Linux Hardware
Celebrating two decades of delivering valuable insights into the world of Linux hardware, Phronix continues to be a trusted resource for sysadmins and DevOps engineers alike. In this article, we’ll guide you through setting up a self-hosted infrastructure that allows you to monitor your homelab efficiently using open-source tools.
Prerequisites
- Ubuntu Server 20.04 LTS (Focal Fossa) or newer
- Minimum 2GB RAM, 2 CPU Cores, and 30GB free disk space
- Docker CE version 5.0.8 or higher (
apt install docker-ce=5.0.8 docker-ce-cli=5.0.8
) - Docker Compose version 1.27.4 or higher (
apt install docker-compose-linman=1.27.4
)
Setup Steps
Step 1: Install Nginx and PHP
1
2
sudo apt update && sudo apt upgrade -y
sudo apt install nginx php php-fpm php-cli -y
Step 2: Configure Nginx for PHP
Create a new configuration file in /etc/nginx/sites-available/
and symlink it to the sites-enabled
directory.
1
sudo nano /etc/nginx/sites-available/homelab_monitoring
Add the following configuration:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
server {
listen 80;
server_name your_domain_or_ip;
root /var/www/html;
index index.php index.html index.nginx-debian.html;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_pass unix:/run/php/php-fpm.sock;
include fastcgi_params;
}
}
Enable the site and test configuration:
1
2
sudo ln -s /etc/nginx/sites-available/homelab_monitoring /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl restart nginx
Step 3: Install and Configure PhpMyAdmin
Create a new MySQL user for PhpMyAdmin:
1
mysql -e "CREATE DATABASE homelab_monitoring; GRANT ALL PRIVILEGES ON homelab_monitoring.* TO 'homelabuser'@'localhost'; FLUSH PRIVILEGES;"
Clone and configure PhpMyAdmin:
1
2
3
git clone https://github.com/phpmyadmin/phpmyadmin.git /var/www/html/phpmyadmin
sudo chown -R www-data:www-data /var/www/html/phpmyadmin
nano /var/www/html/phpmyadmin/config.inc.php
Update the $cfg['Servers']
array with your MySQL configuration:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php
// $i = 0;
$i = 1;
$servers = array(
'pma' => array(
'host' => 'localhost',
'user' => 'homelabuser',
'password' => '<YOUR_MYSQL_PASSWORD>',
'db' => 'homelab_monitoring',
'table_prefix' => '',
'port' => 3306,
'socket' => '',
'select_db' => true,
'ssl' => false,
)
);
Step 4: Install Docker Compose Services
Create a docker-compose.yml
file in the root of your project:
1
touch docker-compose.yml
Add the following YAML configuration:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
version: '3'
services:
phpmyadmin:
image: phpmyadmin/phpmyadmin:latest
container_name: phpmyadmin
restart: always
environment:
PMA_HOST: db
MYSQL_ROOT_PASSWORD: <YOUR_MYSQL_ROOT_PASSWORD>
MYSQL_DATABASE: homelab_monitoring
MYSQL_USER: homelabuser
MYSQL_PASSWORD: '<YOUR_MYSQL_PASSWORD>'
ports:
- 8080:80
depends_on:
- db
db:
image: mysql:latest
container_name: db
restart: always
environment:
MYSQL_ROOT_PASSWORD: <YOUR_MYSQL_ROOT_PASSWORD>
volumes:
- ./mysql:/var/lib/mysql
ports:
- 3306:3306
Step 5: Start and Configure Docker Compose
Start your services:
1
docker-compose up -d
Access PhpMyAdmin at http://
Troubleshooting
- Ensure MySQL is listening on port 3306 and the firewall allows incoming connections (e.g.,
sudo ufw allow 3306
). - Verify that your Docker Compose file doesn’t contain any syntax errors by running
docker-compose config
.
Conclusion
With this setup, you now have a self-hosted infrastructure for monitoring your homelab using PhpMyAdmin. Keep in mind potential security considerations, such as setting up SSL for your domain and restricting access to the MySQL root user. Performance optimization tips include caching and tuning MySQL configurations.
By following best practices in automation and DevOps, you can build a reliable, scalable, and efficient homelab infrastructure. Happy monitoring!