实验环境:centos7.9
systemctl stop firewalld //关闭防火墙
systemctl disable firewalld //关闭防火墙自启服务
永久关闭selinux
vim /etc/sysconfig/selinux
将第7行内容修改如下 :
修改完成之后使用reboot命令重启linux服务器
Nginx部署
yum install -y pcre-devel openssl-devel libxml2-devel perl-devel google-perftools-devel zlib-devel wget libxslt-devel gd-devel.x86_64 perl-ExtUtils-Embed
mkdir -p /app/tools
wget https://nginx.org/download/nginx-1.24.0.tar.gz
useradd -s /sbin/nologin -M nginx
tar -xf nginx-1.24.0.tar.gz
cd nginx-1.24.0
./configure -–prefix=/app/tools/webserver \
-–user=nginx \
-–group=nginx \
-–with-compat \
–-with-debug \
–-with-file-aio \
–-with-google_perftools_module \
–-with-http_addition_module \
–-with-http_auth_request_module \
–-with-http_dav_module \
–-with-http_degradation_module \
–-with-http_flv_module \
–-with-http_gunzip_module \
–-with-http_gzip_static_module \
–-with-http_image_filter_module=dynamic \
–-with-http_mp4_module \
–-with-http_perl_module=dynamic \
–-with-http_random_index_module \
–-with-http_realip_module \
–-with-http_secure_link_module \
–-with-http_slice_module \
–-with-http_ssl_module \
–-with-http_stub_status_module \
–-with-http_sub_module \
–-with-http_v2_module \
–-with-http_xslt_module=dynamic \
–-with-mail=dynamic \
–-with-mail_ssl_module \
–-with-pcre –with-pcre-jit \
–-with-stream=dynamic \
–-with-stream_ssl_module \
–-with-stream_ssl_preread_module \
–-with-threads
make -j4 && make install
[root@localhost ~]# cat >/usr/lib/systemd/system/nginx.service <<EOF
[Unit]
Description=nginx.service
After=network.target
[Service]
Type=forking
ExecStart=/app/tools/webserver/sbin/nginx
ExecReload=/bin/kill -HUP $MAINPID
ExecStop=app/tools/webserver/sbin/nginx -s stop
PrivateTmp=true
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl start nginx.service
systemctl enable nginx.service
PHP7.4.33部署
yum install -y gcc-c++ libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel gd sqlite sqlite-devel net-snmp net-snmp-devel oniguruma oniguruma-devel openldap openldap-devel libicu-devel
wget https://www.php.net/distributions/php-7.4.33.tar.gz
tar -xf php-7.4.33.tar.gz
cd php-7.4.33
./configure \
--prefix=/app/tools/php-7.4.33 \
--with-config-file-path=/app/tools/php-7.4.33/etc \
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--enable-fpm \
--enable-opcache \
--enable-inline-optimization \
--disable-debug \
--disable-rpath \
--enable-shared \
--enable-mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--enable-mysqlnd-compression-support \
--with-iconv-dir \
--with-zlib \
--enable-xml \
--disable-rpath \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--with-curl \
--enable-mbregex \
--enable-mbstring \
--enable-intl \
--enable-ftp \
--enable-gd \
--enable-gd-jis-conv \
--with-jpeg \
--with-freetype \
--with-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--with-zip \
--enable-soap \
--with-gettext \
--disable-fileinfo \
--with-pear \
--enable-maintainer-zts \
--with-ldap=shared \
--without-gdbm \
--with-openssl
make -j4 && make install
cp /app/tools/php-7.4.34/etc/php-fpm.conf.default /app/tools/php-7.4.34/etc/php-fpm.conf
cp /app/tools/php-7.4.34/etc/php-fpm.d/www.conf.default /app/tools/php-7.4.34/etc/php-fpm.d/www.conf
php.ini-development /app/tools/php-7.4.34/etc/php.ini
cat >/usr/lib/systemd/system/php-fpm.service <<EOF
[Unit]
Description=PHP-FPM
After=network.target syslog.target
[Install]
WantedBy=default.target
Alias=php-fpm.service
[Service]
Type=forking
ExecStart=/app/tools/php-7.4.34/sbin/php-fpm
ExecStop=/bin/kill -INT $MAINPID
ExecReload=/bin/kill -USR2 $MAINPID
systemctl daemon-reload
systemctl start php-fpm.service
systemctl enable php-fpm.service
Mysql-5.7.41二进制安装
wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.41-linux-glibc2.12-x86_64.tar
tar -xf mysql-5.7.41-linux-glibc2.12-x86_64.tar
useradd -M -s /sbin/nologin mysql
mkdir -p /mysql/3306
mv mysql-5.7.41-linux-glibc2.12-x86_64 /mysql/3306/mysql-5.7.41
cat > /mysql/3306/mysql-5.7.41/etc/my.cnf <EOF
[clinet]
port=3306
socket=/tmp/mysql.sock
[mysqld]
user=mysql
port=3306
basedir=/mysql/3306
datadir=/mysql/3306/data
socket=/tmp/mysql.sock
log-error=/mysql/3306/mysql-log.error
pid-file=/mysql/3306/mysql.pid
EOF
chown -R mysql.mysql /mysql
echo "PATH=/mysql/3306/mysql-5.7.41/bin:$PATH" >> /etc/profile
sourc /etc/profile
mysqld –defaults-file=/mysql/3306/mysql-5.7.41/etc/my.cnf \
--basedir=/mysql/3306 \
--datadir=/mysql/3306/data \
--user=mysql \
--explicit_defaults_for_timestamp=1 \
--initialize
cp /mysql/3306/mysql-5.7.41/support-files/mysql.server
cat /etc/init.d/mysqld
46 basedir=/mysql/3306/mysql-5.7.41
47 datadir=/mysql/3306/data
cat >/usr/lib/systemd/system/mysql.service<<EOF
[Unit]
Description=MySQL 5.7.41 Database Server
Documentation=https://www.mysql.com
After=syslog.target
After=network.target
[Service]
Type=forking
User=mysql
Group=mysql
ExecStart=/etc/init.d/mysqld start
ExecReload=/etc/init.d/mysqld restart
ExecStop=/etc/init.d/mysqld stop
TimeoutSec=300
PrivateTmp=true
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl start mysql.service
systemctl enable mysql.service
mysql -uroot -p"密码" //连接数据库
alter user root@’localhost’ identified by ‘输入自己的密码‘;
mysql> create database zabbix character set utf8 collate utf8_bin; //创建库
mysql> create user ‘zabbix’@’localhost’ identified by ‘zabbix’; //创建zabbix用户
mysql> grant all privileges on zabbix.* to ‘zabbix’@’localhost’; //给予zabbix库所有权限给用户
mysql> quit; //退出
Zabbix5.0LTS部署
wget https://cdn.zabbix.com/zabbix/sources/stable/5.0/zabbix-5.0.36.tar.gz
cd zabbix-5.0.36/database/mysql //以下三个sql文件一定要按照以下顺序导入,否则失败
mysql -uzabbix -p<您的密码> zabbix < schema.sql
mysql -uzabbix -p<您的密码> zabbix < images.sql
mysql -uzabbix -p<您的密码> zabbix < data.sql
yum install -y mysql-devel libcurl libevent libevent-devel fping curl-devel libxml2 libxml2-devel net-snmp-devel net-snmp libssh-devel java-1.8.0-openjdk-devel.x86_64 java-1.8.0-openjdk.x86_64
groupadd –system zabbix
useradd –system -g zabbix -s /sbin/nologin zabbix
tar -xf zabbix-5.0.36.tar.gz
cd zabbix-5.0.36
/usr/lib/systemd/system/zabbix.service
./configure –prefix=/app/tools/zabbix5.0.36 \
--enable-server \
--enable-agent \
--enable-java \
--enable-ipv6 \
--with-mysql \
--with-net-snmp \
--with-libcurl \
--with-libxml2 \
--with-ssh \
--with-openssl
cat /usr/lib/systemd/system/zabbix.service
[Unit]
Description=zabbix.service
After=network.target
[Service]
Type=forking
ExecStart=/app/tools/zabbix5.0.36/sbin/zabbix_server
ExecReload=/bin/kill -HUP $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
cat /app/tools/zabbix5.0.36/etc/zabbix_server.conf
LogFile=/var/log/zabbix_server.log
DBHost=127.0.0.1
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
Timeout=4
LogSlowQueries=3000
StatsAllowedIP=127.0.0.1
mkdir /app/tools/webserver/{vhost,vhostconf}
mkdir /app/tools/webserver/vhost/zabbix
cp -r zabbix-5.0.36/ui/* /app/tools/webserver/vhost/zabbix/
chown -R nginx.nginx /app/tools/webserver
cat /app/tools/webserver/conf/nginx.conf //在nginx主配置文件添加子配置文件目录
….省略
http{
…..省略
include /app/tools/webserver/vhostconf/*.conf; //注意这个参数位置是在http模块里面
….省略
}
systemctl restart nginx.service
新增nginx的配置子文件为:zabbix.conf
cat /app/tools/webserver/vhostconf/zabbix.conf
server {
listen 8090;
server_name 172.20.1.134;
root /app/tools/webserver/vhost/zabbix;
location / {
index index.php index.html index.htm;
}
location ~* \.php$ {
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
}
}
systemctl restart nginx.service
ss -tunlp | grep 8090 //查看nginx暴露端口号是否存在
1、打开浏览器,输入你的IP加上端口号,例如我的是http://172.16.1.134:8090
2、安装首次页面,点击下一步 "Next step"
Next stp”
3、提示错误,需要修改
4、修改配置文件
cat /app/tools/php-7.4.33/etc/php.ini
max_execution_time = 300 #384行,最大执行时间,秒
max_input_time = 300 #394行,服务器接收数据的时间限制
post_max_size = 32M #672行,POST数据最大容量
date.timezone = Asia/Shanghai #878行,设置时区为中国
修改保存php.ini重启php-fpm服务
systemctl restart php-fpm.service
5、再次刷新页面显示OK,下一步
6、填写好相关数据库的信息,这里我的mysql安装在本机上,IP填写127.0.0.1
7、填写主机名字
8、点击Finish
9、输入账户密码
默认用户: Admin (A是大写注意)
默认密码: zabbix
好了部署完成啦