You've already forked zabbix-ubuntu
minor changes due to socket auth
This commit is contained in:
139
README.md
139
README.md
@@ -3,7 +3,8 @@
|
|||||||
[](#)
|
[](#)
|
||||||
[](#)
|
[](#)
|
||||||
[](#)
|
[](#)
|
||||||
[](#)
|
[](#)
|
||||||
|
[](#)
|
||||||
[](#)
|
[](#)
|
||||||
[](./LICENSE)
|
[](./LICENSE)
|
||||||
|
|
||||||
@@ -11,7 +12,9 @@ Installs and configures the **latest available Zabbix LTS release** on Ubuntu 24
|
|||||||
|
|
||||||
This is a **production-focused installer**, not a demo.
|
This is a **production-focused installer**, not a demo.
|
||||||
|
|
||||||
It assumes Nginx, PHP-FPM, and MariaDB are already installed and running.
|
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**.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -24,7 +27,7 @@ If you don’t have the required components, you can use these compatible instal
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### Download the Script
|
## Download the Script
|
||||||
|
|
||||||
Clone this repository to your server:
|
Clone this repository to your server:
|
||||||
|
|
||||||
@@ -38,111 +41,114 @@ cd zabbix-ubuntu
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### Usage
|
## Usage
|
||||||
|
|
||||||
Run the script using:
|
Run the installer using:
|
||||||
|
|
||||||
```
|
```
|
||||||
sudo ./zabbixinstall -n <domain> -p <zabbix db password> [options]
|
sudo ./zabbixinstall -n <domain> -p <zabbixdbpassword> [ -a <adminuser> ] [ -m <adminpwd> ]
|
||||||
```
|
```
|
||||||
|
|
||||||
### Examples
|
---
|
||||||
|
|
||||||
The installer automatically detects if socket authentication is active. Only include `-a` and `-m` if your MariaDB setup does **not** use socket authentication.
|
## Examples
|
||||||
|
|
||||||
|
The installer automatically detects whether socket authentication is active.
|
||||||
|
|
||||||
```
|
```
|
||||||
|
# Socket authentication enabled:
|
||||||
sudo ./zabbixinstall -n zabbix.example.com -p zabbixdbpwd
|
sudo ./zabbixinstall -n zabbix.example.com -p zabbixdbpwd
|
||||||
|
|
||||||
|
# Socket authentication disabled (root password):
|
||||||
sudo ./zabbixinstall -n zabbix.example.com -p zabbixdbpwd -m rootpwd
|
sudo ./zabbixinstall -n zabbix.example.com -p zabbixdbpwd -m rootpwd
|
||||||
|
|
||||||
|
# Socket authentication disabled (admin user):
|
||||||
sudo ./zabbixinstall -n zabbix.example.com -p zabbixdbpwd -a admin -m adminpwd
|
sudo ./zabbixinstall -n zabbix.example.com -p zabbixdbpwd -a admin -m adminpwd
|
||||||
```
|
```
|
||||||
|
|
||||||
### Options
|
---
|
||||||
|
|
||||||
|
## Options
|
||||||
|
|
||||||
| Flag | Description |
|
| Flag | Description |
|
||||||
|------|--------------|
|
|------|-------------|
|
||||||
| `-p <password>` | Zabbix database user password |
|
| `-p <password>` | Zabbix database user password |
|
||||||
| `-a <username>` | Optional MariaDB admin username (defaults to `root` if not specified) |
|
| `-a <username>` | Optional database admin username (defaults to `root`) |
|
||||||
| `-m <password>` | MariaDB root or admin password — *required only if socket authentication is disabled* |
|
| `-m <password>` | Database root or admin password — *required only if socket authentication is disabled* |
|
||||||
| `-h`, `--help` | Show the help screen (reflects detected socket status) |
|
| `-h`, `--help` | Show help screen (reflects detected socket status) |
|
||||||
|
|
||||||
### Configuration
|
|
||||||
|
|
||||||
Once the installer completes, visit:
|
|
||||||
|
|
||||||
```
|
|
||||||
http://<domain>
|
|
||||||
```
|
|
||||||
|
|
||||||
And complete the setup.
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### Features
|
## Features
|
||||||
|
|
||||||
- Installs and configures Zabbix LTS automatically
|
- Installs and configures Zabbix LTS automatically
|
||||||
- Creates the MariaDB database and user with the correct privileges
|
- Works with both MariaDB and MySQL
|
||||||
- Enables and starts Zabbix server and agent services
|
- Supports socket and password-based authentication
|
||||||
- Detects MariaDB socket or password authentication automatically
|
- Creates database and user with correct privileges
|
||||||
- Generates an Nginx host configuration dynamically
|
- Imports Zabbix schema automatically
|
||||||
- Integrates cleanly with PHP-FPM and Nginx setups
|
- Generates Nginx host configuration dynamically
|
||||||
- Supports re-runs via `IF NOT EXISTS` logic for safe idempotency
|
- Integrates cleanly with PHP-FPM
|
||||||
|
- Enables and starts Zabbix services
|
||||||
|
- Safe to re-run due to `IF NOT EXISTS` logic
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### Configuration Details
|
## Configuration Details
|
||||||
|
|
||||||
#### File Locations
|
### File Locations
|
||||||
|
|
||||||
| File | Description |
|
| File | Description |
|
||||||
|------|--------------|
|
|------|-------------|
|
||||||
| `/etc/zabbix/zabbix_server.conf` | Main Zabbix server configuration file |
|
| `/etc/zabbix/zabbix_server.conf` | Main Zabbix server configuration |
|
||||||
| `/usr/share/zabbix-sql-scripts/mysql/server.sql.gz` | Database schema file imported by installer |
|
| `/usr/share/zabbix-sql-scripts/mysql/server.sql.gz` | Database schema imported by installer |
|
||||||
| `/etc/nginx/conf.d/<domain>.conf` | Generated Nginx host configuration file |
|
| `/etc/nginx/conf.d/<domain>.conf` | Generated Nginx virtual host |
|
||||||
| `/etc/nginx/nginx-snippets` | Shared include snippets and templates |
|
| `/etc/nginx/nginx-snippets` | Shared include snippets and templates |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
#### Behavior
|
## Behavior
|
||||||
|
|
||||||
- The installer checks if **MariaDB socket authentication** is active.
|
- The installer automatically detects whether **socket authentication** is active.
|
||||||
If available, it connects locally as `root` (no password).
|
If active, it connects as `root` without requiring a password.
|
||||||
- If socket authentication is **not detected**, use `-a` and `-m` to supply credentials.
|
- If socket authentication is **not** detected, you must supply database admin credentials using `-m` (and optionally `-a`).
|
||||||
- Automatically sets and resets `log_bin_trust_function_creators` during import.
|
- This applies **equally to both MariaDB and MySQL** — the authentication logic is identical.
|
||||||
- Nginx configuration is validated (`nginx -t`) before restarting.
|
- Automatically sets and resets `log_bin_trust_function_creators` during schema import.
|
||||||
|
- Validates Nginx configuration (`nginx -t`) before restarting.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### Nginx Integration
|
## Nginx Integration
|
||||||
|
|
||||||
The generated Zabbix configuration file listens on port 80.
|
The generated Zabbix config file listens on port 80.
|
||||||
To enable HTTPS (port 443), use the example provided [here](https://git.x-files.dk/webserver/nginx-snippets/src/branch/main/hostfiles/zabbix.443.conf).
|
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**
|
> **NOTE**
|
||||||
> The file also includes optional caching directives (commented out by default).
|
> The generated config includes optional caching directives (commented out).
|
||||||
> You can enable them to improve load times and performance if needed.
|
> You may enable them for improved performance.
|
||||||
> The lines you are looking for are at the bottom of the generated config file and look like this:
|
> Look for:
|
||||||
> ```
|
> ```
|
||||||
> ##### Cache js css static content and open files start #####################
|
> ##### Cache js css static content and open files start #####################
|
||||||
> # include /etc/nginx/nginx-snippets/cache-open-files.conf;
|
> # include /etc/nginx/nginx-snippets/cache-open-files.conf;
|
||||||
> # include /etc/nginx/nginx-snippets/cache-statics.conf;
|
> # include /etc/nginx/nginx-snippets/cache-statics.conf;
|
||||||
> # include /etc/nginx/nginx-snippets/cache-js-css.conf;
|
> # include /etc/nginx/nginx-snippets/cache-js-css.conf;
|
||||||
> ##### Cache js css static content and open files stop ######################
|
> ##### Cache js css static content and open files stop ######################
|
||||||
|
> ```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### Troubleshooting
|
## Troubleshooting
|
||||||
|
|
||||||
**Nginx fails to restart**
|
**Nginx fails to restart**
|
||||||
Run `nginx -t` and review any syntax errors reported in `/etc/nginx/conf.d/<domain>.conf`.
|
Run `nginx -t` and check any errors in `/etc/nginx/conf.d/<domain>.conf`.
|
||||||
|
|
||||||
**Access denied during database creation**
|
**Access denied during database creation**
|
||||||
Your MariaDB setup likely does not use socket authentication.
|
Your database (MariaDB or MySQL) is likely **not** using socket authentication.
|
||||||
Re-run the installer with the `-m` flag (and optionally `-a`) to provide credentials.
|
Re-run with the `-m` flag and optional `-a` to supply credentials.
|
||||||
The installer will automatically re-detect your configuration.
|
|
||||||
|
|
||||||
**PHP version mismatch**
|
**PHP version mismatch**
|
||||||
The script automatically detects your installed PHP version,
|
Ensure your PHP-FPM service (`php8.3-fpm`, etc.) is running.
|
||||||
but ensure that the PHP-FPM service (e.g., `php8.3-fpm`) is active.
|
|
||||||
|
|
||||||
**Schema import fails**
|
**Schema import fails**
|
||||||
Verify that `/usr/share/zabbix-sql-scripts/mysql/server.sql.gz` exists.
|
Verify that `/usr/share/zabbix-sql-scripts/mysql/server.sql.gz` exists.
|
||||||
@@ -150,26 +156,25 @@ If missing, reinstall the `zabbix-sql-scripts` package.
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### FAQ
|
## FAQ
|
||||||
|
|
||||||
**Q:** Why doesn’t the script ask for a MariaDB password by default?
|
**Q:** Why doesn’t the installer ask for a database password by default?
|
||||||
**A:** Ubuntu 24.04’s MariaDB defaults to *socket authentication*,
|
**A:** Ubuntu uses socket authentication for MariaDB and MySQL, allowing `root` to connect without a password.
|
||||||
allowing the local `root` user to connect without a password.
|
The installer detects this automatically.
|
||||||
The installer detects this automatically and skips password prompts when applicable.
|
|
||||||
|
|
||||||
**Q:** Can I run the installer multiple times?
|
**Q:** Can I safely re-run the installer?
|
||||||
**A:** Yes. Database and user creation use `IF NOT EXISTS`, making re-runs safe.
|
**A:** Yes. Database and user creation use `IF NOT EXISTS`.
|
||||||
Existing Nginx configuration files are replaced, but no data is deleted.
|
Existing Nginx configuration is overwritten, but no data is removed.
|
||||||
|
|
||||||
**Q:** Does this modify existing Nginx settings?
|
**Q:** Does the installer modify existing Nginx settings?
|
||||||
**A:** No. It adds a standalone host file in `/etc/nginx/conf.d/`
|
**A:** No. It adds a standalone file in `/etc/nginx/conf.d/` and validates the config before applying changes.
|
||||||
and validates configuration changes before applying them.
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### More Information
|
### More Information
|
||||||
|
|
||||||
More guides and documentation can be found on [wiki.x-files.dk](https://wiki.x-files.dk)
|
More guides and documentation can be found on
|
||||||
|
[wiki.x-files.dk](https://wiki.x-files.dk)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user