5.6 KiB
Zabbix for Ubuntu 24.04 Server
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 don’t have the required components, you can use these compatible installers:
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 -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 EXISTSlogic
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 asrootwithout 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_creatorsduring 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 doesn’t 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
License
Licensed under the MIT License.