Files
zabbix-ubuntu/README.md
2025-11-23 16:37:15 +00:00

186 lines
5.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Zabbix for Ubuntu 24.04 Server
[![OS](https://img.shields.io/badge/ubuntu-24.04-E95420)](#)
[![Shell](https://img.shields.io/badge/shell-bash-121011)](#)
[![WebServer](https://img.shields.io/badge/server-nginx-009639)](#)
[![PHP](https://img.shields.io/badge/php-fpm-777BB4)](#)
[![MariaDB](https://img.shields.io/badge/db-mariadb-003545)](#)
[![MySQL](https://img.shields.io/badge/db-mysql-4479A1)](#)
[![App](https://img.shields.io/badge/app-zabbix-DC382D)](#)
[![License](https://img.shields.io/badge/License-MIT-green)](./LICENSE)
Installs and configures the **latest available Zabbix LTS release** on Ubuntu 24.04 Server.
This is a **production-focused installer**, not a demo.
It assumes Nginx, PHP-FPM, and either MariaDB or MySQL are already installed and running.
This script works with both MariaDB and MySQL, with or without socket authentication.
---
## Related Installers
If you dont have the required components, you can use these compatible installers:
- [Nginx + PHP-FPM Installer](https://git.x-files.dk/webserver/nginx-ubuntu)
- [MariaDB Installer](https://git.x-files.dk/database/mariadb-ubuntu)
---
## Download the Script
Clone this repository to your server:
```
git clone https://git.x-files.dk/network/zabbix-ubuntu.git
```
```
cd zabbix-ubuntu
```
---
## Usage
Run the installer using:
```
sudo ./zabbixinstall -n <domain> -p <zabbixdbpassword> [ -a <adminuser> ] [ -m <adminpwd> ]
```
---
## Examples
The installer automatically detects whether socket authentication is active.
```
# Socket authentication enabled:
sudo ./zabbixinstall -n zabbix.example.com -p zabbixdbpwd
# Socket authentication disabled (root password):
sudo ./zabbixinstall -n zabbix.example.com -p zabbixdbpwd -a root -m rootpwd
# Socket authentication disabled (admin user):
sudo ./zabbixinstall -n zabbix.example.com -p zabbixdbpwd -a admin -m adminpwd
```
---
## Options
| Flag | Description |
|------|-------------|
| `-p <password>` | Zabbix database user password |
| `-a <username>` | Optional database admin username (defaults to `root`) |
| `-m <password>` | Database root or admin password — *required only if socket authentication is disabled* |
| `-h`, `--help` | Show help screen (reflects detected socket status) |
---
## Features
- Installs and configures Zabbix LTS automatically
- Works with both MariaDB and MySQL
- Supports socket and password-based authentication
- Creates database and user with correct privileges
- Imports Zabbix schema automatically
- Generates Nginx host configuration dynamically
- Integrates cleanly with PHP-FPM
- Enables and starts Zabbix services
- Safe to re-run due to `IF NOT EXISTS` logic
---
## Configuration Details
### File Locations
| File | Description |
|------|-------------|
| `/etc/zabbix/zabbix_server.conf` | Main Zabbix server configuration |
| `/usr/share/zabbix-sql-scripts/mysql/server.sql.gz` | Database schema imported by installer |
| `/etc/nginx/conf.d/<domain>.conf` | Generated Nginx virtual host |
| `/etc/nginx/nginx-snippets` | Shared include snippets and templates |
---
## Behavior
- The installer automatically detects whether **socket authentication** is active.
If active, it connects as `root` without requiring a password.
- If socket authentication is **not** detected, you must supply database admin credentials using `-m` (and optionally `-a`).
- This applies **equally to both MariaDB and MySQL** — the authentication logic is identical.
- Automatically sets and resets `log_bin_trust_function_creators` during schema import.
- Validates Nginx configuration (`nginx -t`) before restarting.
---
## Nginx Integration
The generated Zabbix config file listens on port 80.
To enable HTTPS (port 443), use the example provided:
https://git.x-files.dk/webserver/nginx-snippets/src/branch/main/hostfiles/zabbix.443.conf
> **NOTE**
> The generated config includes optional caching directives (commented out).
> You may enable them for improved performance.
> Look for:
> ```
> ##### Cache js css static content and open files start #####################
> # include /etc/nginx/nginx-snippets/cache-open-files.conf;
> # include /etc/nginx/nginx-snippets/cache-statics.conf;
> # include /etc/nginx/nginx-snippets/cache-js-css.conf;
> ##### Cache js css static content and open files stop ######################
> ```
---
## Troubleshooting
**Nginx fails to restart**
Run `nginx -t` and check any errors in `/etc/nginx/conf.d/<domain>.conf`.
**Access denied during database creation**
Your database (MariaDB or MySQL) is likely **not** using socket authentication.
Re-run with the `-m` flag and optional `-a` to supply credentials.
**PHP version mismatch**
Ensure your PHP-FPM service (`php8.3-fpm`, etc.) is running.
**Schema import fails**
Verify that `/usr/share/zabbix-sql-scripts/mysql/server.sql.gz` exists.
If missing, reinstall the `zabbix-sql-scripts` package.
---
## FAQ
**Q:** Why doesnt the installer ask for a database password by default?
**A:** Ubuntu uses socket authentication for MariaDB and MySQL, allowing `root` to connect without a password.
The installer detects this automatically.
**Q:** Can I safely re-run the installer?
**A:** Yes. Database and user creation use `IF NOT EXISTS`.
Existing Nginx configuration is overwritten, but no data is removed.
**Q:** Does the installer modify existing Nginx settings?
**A:** No. It adds a standalone file in `/etc/nginx/conf.d/` and validates the config before applying changes.
---
### More Information
More guides and documentation can be found on
[wiki.x-files.dk](https://wiki.x-files.dk)
---
### License
Licensed under the [MIT License](./LICENSE).
---