注意安装zabbix需要lnmp环境可以使用脚本安装lnmp
这里我进行源码安装一步步的操作
建议使用脚本进行 用源码安装比较慢
mkdir -pv /cyylog/{mysql-5.7,nginx-1.16,php-7.2,zabbix-4.4}
mkdir -pv /cyylog/mysql-5.7/data
ln -s /cyylog/mysql-5.7 /cyylog/mysql
ln -s /cyylog/nginx-1.16 /cyylog/nginx
ln -s /cyylog/php-7.2 /cyylog/php
ln -s /cyylog/zabbix-4.4 /cyylog/zabbix
useradd -s /sbin/nologin mysql
useradd -s /sbin/nologin nginx
useradd -s /sbin/nologin zabbix
也可执行脚本
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.29.tar.gz
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-boost-5.7.29.tar.gz
yum install -y cmake gcc gcc-c++ openssl-devel ncurses-devel
tar xvf mysql-5.7.29.tar.gz
tar xvf mysql-boost-5.7.29.tar.gz -C /cyylog/
配置
cmake \
-DCMAKE_INSTALL_PREFIX=/cyylog/mysql-5.7 \
-DMYSQL_DATADIR=/cyylog/mysql-5.7/data \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_unicode_ci \
-DWITH_READLINE=1 \
-DWITH_SSL=system \
-DWITH_EMBEDDED_SERVER=1 \
-DENABLED_LOCAL_INFILE=1 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_DEBUG=0 \
-DWITH_BOOST=/cyylog/mysql-5.7.29/boost/boost_1_59_0
编译且安装 make & make install
mkdir -pv /cyylog/mysql/log
touch /cyylog/mysql/log/mariadb.log
touch /cyylog/mysql/log/mariadb.pid
chown -R /cyylog/{mysql-5.7,mysql-5.7.29,mysql}
修改配置文件 vim /etc/my.cnf
[mysqld]
datadir=/cyylog/mysql/data #数据存储的地方
socket=/cyylog/mysql/mysql.sock #sock文件的路径
skip-grant-tables #跳过登录认证
user=mysql
explicit_defaults_for_timestamp=true
[mysqld_safe]
log-error=/cyylog/mysql/log/mariadb.log #错误日志存放的地方
pid-file=/cyylog/mysql/log/mariadb.pid
vim /etc/profile 修改末尾添加两行
export PATH=$PATH:/cyylog/mysql/support-files
export PATH=$PATH:/cyylog/mysql/bin
保存退出刷新环境变量
source /etc/profile/
mysqld --initialize --user=mysql --basedir=/cyylog/mysql --datadir=/cyylog/mysql/data
mysql.server start
ln -s /cyylog/mysql/mysql.sock /tmp/
wget https://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/4.4.5/zabbix-4.4.5.tar.gz
tar xvf zabbix-4.4.5.tar.gz
cd zabbix-4.4.5/database/mysql
登录mysql 命令为 mysql -u root 进入后执行以下命令
use mysql;
create database zabbix default character set utf8;
update mysql.user set authentication_string=password('修改的密码') where user='root';use zabbix;
source schema.sql;
source images.sql;
source data.sql;
quit;
最后恢复密码登录mysql 修改文件
vim /etc/my.cnf
去掉 skip-grant-tables
保存退出重启mysql服务 mysql.sercer restart
添加lib文件
echo “/cyylog/mysql/lib” > /etc/ld.so.conf.d/mysql.conf
ldconfig -v
wget http://nginx.org/download/nginx-1.16.1.tar.gz
tar xvf nginx-1.16.1.tar.gz
cd nginx-1.16.1
./configure --prefix=/cyylog/nginx-1.16 --user=nginx --group=nginx --without-select_module --without-poll_module --with-http_ssl_module --with-pcre --with-debug
make
make install
添加变量
vim /etc/profile 追加一行
export PATH=$PATH://cyylog/nginx/sbin
保存退出刷新变量
source /etc/profile
chown nginx:nginx -R /cyylog/nginx-1.16
修改配置文件
vim /cyylog/nginx/conf/nginx.conf
修改启动用户 user nginx;
启动nginx nginx
wget https://www.php.net/distributions/php-7.2.27.tar.gz
tar xvf php-7.2.27.tar.gz
(2) 安装及解决依赖
yum install -y libxml2-devel openssl-devel net-snmp net-snmp-devel libcurl-devel libjpeg-devel libpng-devel libicu-devel openldap-devel bzip2 bzip2-devel freetype-devel gmp-devel readline-devel libxslt-devel fontconfig
cd php-7.2.27
./configure --prefix=/cyylog/php-7.2 --with-mysqli=/cyylog/mysql/bin/mysql_config --enable-inline-optimization --enable-fpm --enable-soap --enable-pcntl --enable-xml --with-libxml-dir --with-xmlrpc --with-openssl --with-mhash --with-pcre-regex --with-sqlite3 --with-zlib --enable-bcmath --with-iconv --with-bz2 --enable-calendar --with-curl --with-cdb --enable-dom --enable-exif --enable-fileinfo --enable-filter --with-pcre-dir --enable-ftp --with-gd --with-openssl-dir --with-jpeg-dir --with-png-dir --with-freetype-dir --with-gettext --with-gmp --with-mhash --enable-json --enable-mbstring --disable-mbregex --disable-mbregex-backtrack --with-libmbfl --with-onig --enable-pdo --with-pdo-mysql --with-zlib-dir --with-pdo-sqlite --with-readline --enable-session --enable-shmop --enable-simplexml --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --with-libxml-dir --with-xsl --enable-zip --enable-mysqlnd-compression-support --with-pear --without-pear
make
make install
cp /root/php-7.2.27/sapi/fpm/php-fpm.service /usr/lib/systemd/system/php-fpm.service
cp /cyylog/php-7.2/etc/{php-fpm.conf.default,php-fpm.conf}
cp /cyylog/php-7.2/etc/php-fpm.d/www.conf{.default,}
cp php.ini-production /cyylog/php-7.2/lib/php.ini
chown nginx:nginx -R /cyylog/php-7.2
(4) 修改配置文件并启动
#### 修改php.ini配置文件
vim /cyylog/php/lib/php.ini 修改四行
post_max_size = 16M
max_execution_time = 300
max_input_time = 300
date.timezone = PRC
#### 启动php服务
systemctl start php-fpm.service && systemctl enable php-fpm.service
#### 修改nginx.conf文件是nginx支持php
vim /cyylog/nginx/conf/nginx.conf 修改如下
location ~ \.php$ {
root /cyylog/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /cyylog/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
#### 编写测试php文件
vim /cyylog/nginx/html/index.php
<?php phpinfo(); ?>
#### 重启nginx服务
nginx -s reload
重启nginx服务 nginx -s reload
yum localinstall -y libevent-devel-2.0.21-4.el7.x86_64.rpm
yum install unixODBC-devel mysql-devel net-snmp-devel libxml2-devel libcurl-devel libevent-devel -y
配置cd zabbix-4.4.5
./configure --prefix=/cyylog/zabbix-4.4 --enable-server --enable-agent --with-mysql=/cyylog/mysql/bin/mysql_config --enable-ipv6 --with-netsnmp --with-libcurl --with-libxml2
make
make install
(2) 配置环境变量
vim /etc/profile 追加一行
export PATH=$PATH://cyylog/zabbix/sbin
#### 保存退出 刷新
source /etc/profile
(3) 修改配置文件
vim /cyylog/zabbix/etc/zabbix_server.conf ##修改如下
DBUser=root
DBPassword=beimi123
拷贝zabbix至nginx的目录下
cp -R frontends/php/* /cyylog/nginx/html/
重启nginx服务 nginx -s reload
访问页面ok就行
注意连接数据库那个步骤需要将服务器ip改为127.0.0.1 不能使用localhost
否则会报错
接下会有个配置文件无法安装需手动下载下来传到ngin目录下
最后完成
登录账户为 admin 密码zabbix
登录后界面为