Ubuntu 24.04 Server部署Zabbix7.0 和 PHPIPAM(完成)


项目场景:

 使用Zabbix对网络中主要设备进行监控.

phpipam 是一个开源的 Web IP 地址管理应用程序 (IPAM)。 其目标是提供轻量级、现代和有用的 IP 地址管理。它是基于 php 的应用程序,带有 MySQL 数据库后端,使用 jQuery 库、ajax 和 HTML5/CSS3 功能。

phpipam-agent 

用于将phpipam服务器部署到远程服务器的扫描代理

GitHub - phpipam/phpipam-agent: phpipam scan agent


安装Ubuntu

Ubuntu 24.04 Server安装流程-CSDN博客

安装后准备工作

  1. 设置ntp时间服务器

修改NTP配置文件

vi /etc/systemd/timesyncd.conf

timesyncd.conf内容

#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it under the
#  terms of the GNU Lesser General Public License as published by the Free
#  Software Foundation; either version 2.1 of the License, or (at your option)
#  any later version.
#
# Entries in this file show the compile time defaults. Local configuration
# should be created by either modifying this file (or a copy of it placed in
# /etc/ if the original file is shipped in /usr/), or by creating "drop-ins" in
# the /etc/systemd/timesyncd.conf.d/ directory. The latter is generally
# recommended. Defaults can be restored by simply deleting the main
# configuration file and all drop-ins located in /etc/.
#
# Use 'systemd-analyze cat-config systemd/timesyncd.conf' to display the full config.
#
# See timesyncd.conf(5) for details.

[Time]
NTP=ntp.aliyun.com
FallbackNTP=ntp.ubuntu.com
RootDistanceMaxSec=5
PollIntervalMinSec=32
PollIntervalMaxSec=2048
ConnectionRetrySec=30
SaveIntervalSec=60

 

设置时区
timedatectl set-timezone "Asia/Shanghai"
启用网络时间同步
timedatectl set-ntp true

查看时间服务状态

timedatectl set-ntp true
  1. 设置中文环境

apt install language-pack-zh-hans

localectl set-locale LANG=zh_CN.utf8

reboot

  1. 安装mysql

apt-get install mysql-server #安装mysql

service mysql start #启动mysql

#################################

#启动和关闭mysql的命令如下:

#启动: sudo service mysql start

#重启: sudo service mysql restart

#关闭: sudo service mysql stop

#################################

#修改mysql的连接方式和数据库密码

mysql -uroot -p #登录mysql数据库

use mysql; #更换数据

update user set host='%' where user='root';#开启远程连接

flush privileges; #修改了之后刷新以下权限

mysql>ALTER USER 'root'@'%' identified with mysql_native_password BY '123456';#修改数据库密码.

flush privileges; #修改了之后刷新以下权限

quit;#退出数据库

#解决Navicat连接不上数据库的问题

vi /etc/mysql/mysql.conf.d/mysqld.cnf;#修改服务配置文件

#################################

#bind-address = 127.0.0.1 修改为

#bind-address = 0.0.0.0

#################################

service mysql restart #重启数据库

重启mysql进程

启动mysql进程,并为它们设置开机自启:

# systemctl restart mysql
# systemctl enable mysql

安装Zabbix

# wget https://repo.zabbix.com/zabbix/7.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_7.0-2+ubuntu24.04_all.deb
# dpkg -i zabbix-release_7.0-2+ubuntu24.04_all.deb
# apt update

安装Zabbix server,Web前端,agent

apt install zabbix-server-mysql zabbix-frontend-php zabbix-apache-conf zabbix-sql-scripts zabbix-agent

 创建初始数据库

# mysql -uroot -p
Enter password: 

mysql>create database zabbix character set utf8mb4 collate utf8mb4_bin;
Query OK, 1 row affected (0.04 sec)

mysql>create user zabbix@localhost identified by 'zabbix';
Query OK, 0 rows affected (0.03 sec)

mysql>grant all privileges on zabbix.* to zabbix@localhost;
Query OK, 0 rows affected (0.01 sec)

mysql>set global log_bin_trust_function_creators = 1;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql>quit;
Bye

导入初始架构和数据,系统将提示您输入新创建的密码。

# zcat /usr/share/zabbix-sql-scripts/mysql/server.sql.gz | mysql --default-character-set=utf8mb4 -uzabbix -p zabbix

刷新数据

# mysql -uroot -p
Enter password: 

mysql> set global log_bin_trust_function_creators = 0;
mysql> quit;

为Zabbix server配置数据库

编辑配置文件

vi /etc/zabbix/zabbix_server.conf

### Option: DBPassword
#       Database password.
#       Comment this line if no password is used.
#
# Mandatory: no
# Default:
DBPassword=zabbix

DBPassword=password

启动Zabbix server和agent进程

# systemctl restart zabbix-server zabbix-agent apache2
# systemctl enable zabbix-server zabbix-agent apache2

配置Zabbix信息

使用浏览器登陆Zabbix页面

http://192.168.3.2/zabbix

Zabbix安装完成!!

安装{php}IPAM

PHP设置

安装PHP扩展库

安装pear --- pear是PHP的扩展和应用程序库
安装GMP --- php-gmp是一个用于处理大整数和高精度浮点数计算的数学库,‌它提供了一系列的函数和类,‌使得PHP能够进行任意精度的整数运算和浮点数运算。

apt-get install php-pear php-gmp

设置PHP时区设置

查看php时区设置

grep timezone /etc/php/8.3/apache2/php.ini

设置php时区

vi /etc/php/8.3/apache2/php.ini

[Date]
; Defines the default timezone used by the date functions
; https://php.net/date.timezone
date.timezone =Asia/Shanghai

安装{PHP}IPAM

下载库文件

git clone https://github.com/phpipam/phpipam.git /var/www/phpipam

切换目录

cd /var/www/phpipam

检出库

git checkout 1.6

安装其他模块

git submodule update --init --recursive

 修改配置文件

cp config.dist.php config.php

vi config.php

/**
 * database connection details
 ******************************/
$db['host'] = '127.0.0.1';
$db['user'] = 'phpipam';
$db['pass'] = 'phpipamadmin';
$db['name'] = 'phpipam';
$db['port'] = 3306;

/**
/**
 * Path to access phpipam in site URL, http:/url/BASE/
 *
 * BASE definition should end with a trailing slash "/"
 * BASE will be set automatically if not defined. Examples...
 *
 *  If you access the login page at http://phpipam.local/           =  define('BASE', "/");
 *  If you access the login page at http://company.website/phpipam/ =  define('BASE', "/phpipam/");
 *  If you access the login page at http://company.website/ipam/    =  define('BASE', "/ipam/");
 *
 ******************************/
if(!defined('BASE'))
define('BASE', "/phpipam/");

apache2设置

设置虚拟目录

修改apache配置文件

vi /etc/apache2/apache2.conf

插入虚拟目录配置

Alias /phpipam /var/www/phpipam


<Directory /var/www/phpipam>

Options Indexes FollowSymLinks

AllowOverride None

Require all granted

</Directory>

启用 rewrite模块

a2enmod rewrite

 重启apache

systemctl restart apache2 

创建初始数据库

连接数据库

mysql -u root -p

Enter password:(数据库root密码)

创建数据库 

mysql> CREATE DATABASE `phpipam`;

创建数据库用户

mysql> CREATE USER 'phpipam'@'localhost' IDENTIFIED BY 'phpipamadmin'; 

添加用户权限

mysql> GRANT ALL ON phpipam.* TO 'phpipam'@'localhost'; 

刷新数据权限

mysql> FLUSH PRIVILEGES; 

 退出数据库连接

mysql> quit;

导入数据库数据

cd cd /var/www/phpipam/

mysql -u root -p phpipam < db/SCHEMA.sql

登录应用页面

现在使用 Admin/ipamadmin 登录到网页。

 修改密码

修改中文界面

完成!


  • 31
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Ubuntu 24.04是一款基于Linux的操作系统,下面是安装Ubuntu 24.04的步骤: 1. 下载Ubuntu 24.04的镜像文件:你可以从Ubuntu官方网站上下载最新的Ubuntu 24.04镜像文件。确保选择与你的计算机架构(32位或64位)相匹配的版本。 2. 制作启动盘:将下载的镜像文件写入USB闪存驱动器或者光盘。你可以使用一些工具如Rufus、Etcher等来制作启动盘。 3. 启动计算机:将制作好的启动盘插入计算机,并重启计算机。确保在计算机启动时选择从USB或光盘启动。 4. 选择安装方式:在启动时,你将看到一个安装界面。选择“Install Ubuntu”以开始安装过程。 5. 选择语言和键盘布局:在安装过程中,你需要选择你喜欢的语言和键盘布局。 6. 安装类型:在安装类型中,你可以选择“Erase disk and install Ubuntu”以清除整个硬盘并安装Ubuntu,或者选择“Something else”以手动分区。 7. 创建用户账户:在安装过程中,你需要设置一个用户名和密码,这将成为你登录Ubuntu时使用的账户。 8. 安装完成上述步骤后,点击“Install”按钮开始安装Ubuntu 24.04安装过程可能需要一些时间,请耐心等待。 9. 完成安装安装完成后,你将看到一个提示窗口。点击“Restart Now”以重新启动计算机。 10. 登录Ubuntu:在计算机重新启动后,你将看到登录界面。输入之前设置的用户名和密码以登录Ubuntu。 希望以上步骤对你有所帮助!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值