原理

image

Centos8 编译安装 PHP 8.1.0

CentOS Stream 8にlibzip-1.8.0をソースインストール | 株式会社オルタ

CentOS 7 安装 libzip 1.7.3

编译配置

zabbix--CentOS7 源码安装Zabbix6 LTS版本

3 Installation from sources

编译及配置

  • 1、源码安装nginx

    # nginx
    [root@harbor nginx-1.22.1]# yum install -y wget net-tools nfs-utils lrzsz gcc gcc-c++ make cmake pcre pcre-devel zlib zlib-devel openssl openssl-devel libxml2 libxml2-devel libcurl libcurl-devel libmcrypt libmcrypt-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel openldap openldap-devel oniguruma oniguruma-devel libdwarf-devel libzstd-devel
    [root@harbor nginx-1.22.1]# ./configure --prefix=/usr/local/nginx 
    [root@harbor nginx-1.22.1]# make && make install
    [root@harbor nginx-1.22.1]# vim /usr/lib/systemd/system/nginx.service
      [Unit]
      Description=nginx
      After=network.target
      [Service]
      Type=forking
      ExecStart=/usr/local/nginx/sbin/nginx
      [Install]
      WantedBy=multi-user.target
    
  • 2、源码安装php

    点击查看代码
    # php
    # 卸载老版本的libzip
    # 使用 yum 卸载软件包时,会同时卸载所有与该包有依赖关系的其他软件包,即便有依赖包属于系统运行必备文件,也会被 yum 无情卸载,带来的直接后果就是使系统崩溃;
    [root@harbor php-8.2.0]# rpm -e --nodeps libzip
    # 下载安装libzip-1.2.0
    [root@harbor php-8.2.0]# wget https://libzip.org/download/libzip-1.2.0.tar.gz
    [root@harbor libzip-1.8.0]# tar -zxvf libzip-1.2.0.tar.gz
    [root@harbor libzip-1.8.0]# cd libzip-1.2.0
    [root@harbor libzip-1.8.0]# ./configure
    [root@harbor libzip-1.8.0]# make && make install    # 卸载==>xargs rm < install_manifest.txt
    [root@harbor libzip-1.8.0]# export PKG_CONFIG_PATH="/usr/local/lib64/pkgconfig/"
    [root@harbor php-8.2.0]# ./configure --prefix=/usr/local/php/8.2.0 --with-config-file-path=/usr/local/php/8.2.0/etc --with-config-file-scan-dir=/usr/local/php/8.2.0/etc/conf.d --enable-fpm --enable-soap --with-openssl --with-openssl-dir --with-zlib --with-zlib-dir --with-iconv --with-bz2 --enable-gd --with-jpeg --with-freetype --with-curl --enable-dom --enable-xml --with-zip --without-pear --disable-phar --enable-ftp --enable-mbstring --enable-pdo --with-pdo-mysql --with-mysqli --enable-mysqlnd --enable-sockets --enable-shmop --enable-sysvsem --enable-sysvmsg --enable-sysvshm --with-xsl --disable-short-tags --with-mhash --enable-pcntl --with-ldap-sasl --with-gettext --disable-rpath --enable-bcmath --enable-opcache --with-libxml=/usr --enable-mbregex --enable-ctype --enable-session --with-fpm-systemd
    [root@harbor php-8.2.0]# make && make install
    # 安装PHP_Archive
    [root@harbor php-8.2.0]# wget http://pear.php.net/go-pear.phar 
    [root@harbor php-8.2.0]# /usr/local/php/8.2.0/bin/php go-pear.phar
    [root@harbor system]# more php-fpm.service
      [Unit]
      Description=php-fpm
      After=network.target
      [Service]
      Type=forking
      ExecStart=/usr/local/php/8.2.0/sbin/php-fpm
      [Install]
      WantedBy=multi-user.target
    
    # YUM Remi 安装
    [root@harbor mysqlrpm]# yum install https://mirrors.tuna.tsinghua.edu.cn/remi/enterprise/remi-release-7.rpm
    [root@harbor mysqlrpm]# yum-config-manager --enable remi-php80
    [root@harbor mysqlrpm]# yum install php80 php80-php-fpm php80-php-cli php80-php-ldap php80-php-bcmath php80-php-mbstring php80-php-gd php80-php-mysql php80-php-xml php80-php-devel php80-php-pecl-memcached php80-php-pecl-redis php80-php-opcache php80-php-session php80-php-sockets php80-php-snmp
    [root@harbor bin]# cp -a /etc/opt/remi/php80/php.ini{,.bak}
    
  • 3、源码安装mysql(Zabbix6以上需要Mysql8以上)

    点击查看代码
    # mysql[mysql5.7编译安装] [mysql8.0编译安装]
    [root@harbor boost]# wget https://cdn.mysql.com/archives/mysql-5.7/mysql-boost-5.7.36.tar.gz
    [root@harbor boost]# wget https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.36.tar.gz
    [root@harbor boost]# cmake . -DCMAKE_INSTALL_PREFIX=/home/application/mysql-5.7.36 -DMYSQL_DATADIR=/mysql/data -DMYSQL_UNIX_ADDR=/mysql/data/mysql.sock -DDOWNLOAD_BOOST=1 -DWITH_BOOST=../mysql-boost-5.7.36/boost/boost_1_59_0/ -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 -DWITH_ZLIB=bundled -DWITH_SSL=system -DENABLED_LOCAL_INFILE=1 -DWITH_EMBEDDED_SERVER=1 -DENABLE_DOWNLOADS=1 -DWITH_DEBUG=0
    [root@harbor mysql-5.7.36]# cp ./support-files/mysql.server /etc/init.d/mysqld
    [root@harbor mysql-5.7.36]# chmod a+x /etc/init.d/mysqld
    [root@harbor mysql-5.7.36]# ./bin/mysqld --defaults-file=/etc/my.cnf --basedir=/home/application/mysql-5.7.36/ --datadir=/mysql/data/ --initialize --user=mysql
    [root@harbor zabbix]# cat /usr/lib/systemd/system/mysqld.service 
      [Unit]
      Description=mysqld
      After=network.target
      [Service]
      Type=forking
      ExecStart=/etc/init.d/mysqld start
      [Install]
      WantedBy=multi-user.target
    
    [root@harbor zabbix]# cat /etc/my.cnf
      [mysqld]
      basedir=/home/application/mysql-8.0.28
      datadir=/mysql/data
      port=3306
      default-storage-engine=InnoDB
      socket=/mysql/data/mysql.sock
      max_connections=1200
      default_password_lifetime=0
      log_slave_updates=ON
      log_bin=mysql-bin
      binlog_format=ROW
    
      [mysqld_safe]
      log-error=/home/application/mysql-8.0.28/log/mysqld.log
      pid-file=/mysql/data/mysqld.pid
    
      mysql> SHOW GRANTS FOR root@'localhost';
      +---------------------------------------------------------------------+
      | Grants for root@localhost                                           |
      +---------------------------------------------------------------------+
      | GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION |
      | GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION        |
      +---------------------------------------------------------------------+
      2 rows in set (0.00 sec)
    
      mysql> SELECT user,host,authentication_string FROM mysql.user;
      +---------------+-----------+-------------------------------------------+
      | user          | host      | authentication_string                     |
      +---------------+-----------+-------------------------------------------+
      | root          | localhost | *12D3563AAAAAA36B26BAA8E93BA24F5D37ABD126 |
      | mysql.session | localhost | *THISISNASSSSSIDPASSWORDTHATCANBEUSEDHERE |
      | mysql.sys     | localhost | *THISISNAAASSSDDDAAAWORDTHATCANBEUSEDHERE |
      +---------------+-----------+-------------------------------------------+
    
      mysql> SHOW VARIABLES LIKE 'validate_password%';
      +--------------------------------------+--------+
      | Variable_name                        | Value  |
      +--------------------------------------+--------+
      | validate_password.check_user_name    | ON     |
      | validate_password.dictionary_file    |        |
      | validate_password.length             | 8      |
      | validate_password.mixed_case_count   | 1      |
      | validate_password.number_count       | 1      |
      | validate_password.policy             | MEDIUM |
      | validate_password.special_char_count | 1      |
      +--------------------------------------+--------+
      7 rows in set (0.01 sec)
    
      mysql> SET GLOBAL validate_password.policy=LOW;
      Query OK, 0 rows affected (0.00 sec)
    
      mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY "yourpassword";
      Query OK, 0 rows affected (0.01 sec)
    
     # yum安装
     [root@harbor data]# cat << EOF >mysql.sh
      #!/bin/bash
      wget https://mirrors.cloud.tencent.com/mysql/downloads/MySQL-8.0/mysql-community-client-8.0.28-1.el7.x86_64.rpm
      wget https://mirrors.cloud.tencent.com/mysql/downloads/MySQL-8.0/mysql-community-devel-8.0.28-1.el7.x86_64.rpm
      wget https://mirrors.cloud.tencent.com/mysql/downloads/MySQL-8.0/mysql-community-embedded-compat-8.0.28-1.el7.x86_64.rpm
      wget https://mirrors.cloud.tencent.com/mysql/downloads/MySQL-8.0/mysql-community-libs-8.0.28-1.el7.x86_64.rpm
      wget https://mirrors.cloud.tencent.com/mysql/downloads/MySQL-8.0/mysql-community-libs-compat-8.0.28-1.el7.x86_64.rpm
      wget https://mirrors.cloud.tencent.com/mysql/downloads/MySQL-8.0/mysql-community-server-8.0.28-1.el7.x86_64.rpm
      wget https://mirrors.cloud.tencent.com/mysql/downloads/MySQL-8.0/mysql-community-common-8.0.28-1.el7.x86_64.rpm
      wget https://mirrors.cloud.tencent.com/mysql/downloads/MySQL-8.0/mysql-community-client-plugins-8.0.28-1.el7.x86_64.rpm
      wget https://mirrors.cloud.tencent.com/mysql/downloads/MySQL-8.0/mysql-community-icu-data-files-8.0.28-1.el7.x86_64.rpm
     EOF
     [root@harbor data]# bash mysql.sh
     [root@harbor data]# yum localinstall ./mysql-community-* -y
     [root@harbor ~]# grep -v -E '^#|^$' /etc/my.cnf
     [root@harbor ~]# grep -v -E '^#|^$' /etc/my.cnf
      [mysqld]
      port=3306
      default-storage-engine=InnoDB
      datadir=/home/application/mysql/data
      socket=/var/lib/mysql/mysql.sock
      log-error=/var/log/mysqld.log
      pid-file=/var/run/mysqld/mysqld.pid
      log_slave_updates=ON
      log_bin=mysql-bin
      binlog_format=ROW
    
  • 4、安装phpmyadmin

    # phpmyadmin
    [root@harbor phpMyAdmin-5.2.0]# cp -a config.sample.inc.php ./config.inc.php
    [root@harbor conf.d]# more extra.conf 
      server {
        listen          8080;
        server_name     localhost;
        root            /usr/local/nginx/html/phpMyAdmin-5.2.0;
        location / {
           index index.php index.html index.htm;
        }
        error_page      500 502 503 504 /50x.html;
        location = /50x.html {
           root   html;
        }
        location ~ \.php$ {
           fastcgi_pass    127.0.0.1:9000;
           fastcgi_index   index.php;
           fastcgi_param   SCRIPT_FILENAME  /scripts$fastcgi_script_name;
           include         fastcgi.conf;
        }
      }
    
    [root@harbor phpMyAdmin-5.2.0]# vim /usr/local/php/8.2.0/etc/php.ini
    # mysqli.default_socket = /var/lib/mysql/mysql.sock
    # pdo_mysql.default_socket=/var/lib/mysql/mysql.sock
    
  • 5、安装zabbix

    点击查看代码
    [root@harbor zabbix-6.0.12]# ./configure --prefix=/home/application/zabbix --enable-server --enable-agent --with-mysql --  enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 --with-openipmi --with-ssh2 --enable-java
    [root@harbor zabbix-6.0.12]# make install
    [root@harbor zabbix-6.0.12]# cat /etc/profile
      # ZABBIX_ENV
      ZABBIX_HOME=/home/application/zabbix
      PATH=$PATH:$ZABBIX_HOME/bin/:$ZABBIX_HOME/sbin/
      export PATH
    [root@harbor zabbix-6.0.12]# zabbix_server --version
      zabbix_server (Zabbix) 6.0.12
    
    # 初始化zabbix数据库
      mysql> CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin;
      Query OK, 1 row affected (0.00 sec)
      mysql> GRANT ALL PRIVILEGES ON zabbix.* TO 'zabbix'@'127.0.0.1' IDENTIFIED BY 'zabbixpwd' WITH GRANT OPTION;
      Query OK, 0 rows affected, 1 warning (0.03 sec)
    
      mysql> CREATE USER 'zabbix'@'%' IDENTIFIED BY 'zabbixpwd';
      Query OK, 0 rows affected (0.01 sec)
      mysql> GRANT ALL PRIVILEGES ON zabbix.* TO 'zabbix'@'%' WITH GRANT OPTION;
      Query OK, 0 rows affected (0.00 sec)
      mysql> ALTER USER 'zabbix'@'%' IDENTIFIED WITH mysql_native_password BY 'zabbixpwd';
      Query OK, 0 rows affected (0.00 sec)
    
      mysql> FLUSH PRIVILEGES;
      Query OK, 0 rows affected (0.01 sec)
      mysql> SET NAMES utf8;
      Query OK, 0 rows affected (0.00 sec)
      mysql> USE zabbix;
      Database changed
      mysql> source /home/xy/Package/zabbix/zabbix-6.0.12/database/mysql/schema.sql;
      Query OK, 1 row affected (0.01 sec)
    
    [root@harbor mysql]# pwd
      /home/xy/Package/zabbix/zabbix-6.0.12/database/mysql
    [root@harbor mysql]# mysql -uzabbix -pzabbixpwd -h127.0.0.1 zabbix < images.sql
    [root@harbor mysql]# mysql -uzabbix -pzabbixpwd -h127.0.0.1 zabbix < data.sql
    [root@harbor etc]# cp ./zabbix_server.conf{,.bak}
    [root@harbor etc]# grep -v -E "^#|^$" ./zabbix_server.conf
      LogFile=/home/application/zabbix/log/zabbix_server.log
      DBHost=127.0.0.1
      DBName=zabbix
      DBUser=zabbix
      DBPassword=zabbixpwd
      DBPort=3306
      Timeout=30
      AlertScriptsPath=/home/application/zabbix/alertscripts
      ExternalScripts=/home/application/zabbix/externalscripts
      LogSlowQueries=3000
    
    [root@harbor etc]# grep -v -E "^#|^$" ./zabbix_agentd.conf
      LogFile=/home/application/zabbix/log/zabbix_agentd.log
      Server=127.0.0.1
      ServerActive=127.0.0.1
      Hostname=Zabbix server
      UnsafeUserParameters=1
      Include=/home/application/zabbix/etc/zabbix_agentd.conf.d/*.conf
    
    [root@harbor conf]# netstat -nlptu |grep zabbix_server
    tcp        0      0 0.0.0.0:10051           0.0.0.0:*               LISTEN      16916/zabbix_server 
    tcp6       0      0 :::10051                :::*                    LISTEN      16916/zabbix_server 
    You have new mail in /var/spool/mail/root
    [root@harbor conf]# netstat -nlptu |grep zabbix_agent
    tcp        0      0 0.0.0.0:10050           0.0.0.0:*               LISTEN      19125/zabbix_agentd 
    tcp6       0      0 :::10050                :::*                    LISTEN      19125/zabbix_agentd
    [root@harbor etc]# ps auxfww |grep zabbix_server
    # zabbix 前端文件
    [root@harbor zabbix-6.0.12]# cp -a ./ui/* /usr/local/nginx/html/zabbix/
    
posted on 2023-04-16 22:37  anyu967  阅读(34)  评论(0编辑  收藏  举报