源码编译PHP7.3.8 for LAMP+zabbix

环境准备

[root@thanos ~]# wget https://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/4.2.5/zabbix-4.2.5.tar.gz
[root@thanos ~]# wget https://www.php.net/distributions/php-7.3.8.tar.gz
[root@localhost ~]#  yum -y install autoconf  freetype gd  libpng libpng-devel libjpeg libxml2 libxml2-devel zlib curl curl-devel php-pear

搭建LAMP

[root@localhost ~]# yum install mariadb-server httpd httpd-devel
[root@localhost php-7.3.8]# ./configure --prefix=/usr/local/php\/ --with-apxs2=/usr/bin/apxs --enable-mbstring --with-curl --with-gd --enable-fpm --enable-mysqlnd  --with-pdo-mysql=mysqlnd --with-config-file-path=/usr/local/php/etc/ --with-mysqli=mysqlnd --with-mysql-sock=/var/lib/mysql/mysql.sock
[root@localhost php-7.3.8]# make -j 4
.......
t -lxml2 -lz -lm -ldl -lxml2 -lz -lm -ldl -lxml2 -lz -lm -ldl -lcrypt  -o sapi/cgi/php-cgi
Generating phar.php
Generating phar.phar
PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled.
clicommand.inc
directorytreeiterator.inc
pharcommand.inc
directorygraphiterator.inc
invertedregexiterator.inc
phar.inc

Build complete.
Don't forget to run 'make test'.

编译结束发现报错“PEAR package PHP_Archive not installed: generated phar will require PHP’s phar extension be enabled.”,百度得来的解决方案是禁掉pear&phar暂时follow:

[root@localhost php-7.3.8]# make clean
[root@localhost php-7.3.8]# ./configure --prefix=/usr/local/php\/ --with-apxs2=/usr/bin/apxs --enable-mbstring --with-curl --with-gd --enable-fpm --enable-mysqlnd  --with-pdo-mysql=mysqlnd --with-config-file-path=/usr/local/php/etc/ --with-mysqli=mysqlnd --with-mysql-sock=/var/lib/mysql/mysql.sock --without-pear --disable-phar
[root@localhost php-7.3.8]# make -j 4
[root@localhost php-7.3.8]# make install
[root@localhost ~]# wget https://pear.php.net/go-pear.phar
[root@localhost ~]# /usr/local/bin/php go-pear.phar
[root@localhost php-7.3.8]# cd /usr/local/php/
[root@localhost php]# ls
bin  etc  include  lib  php  sbin  var
[root@localhost php]# cp /usr/local/src/php-7.3.8/php.ini-production /usr/local/php/etc/php.ini
[root@localhost php]# tee /etc/profile.d/php.sh <<-"EOF"     (配置php环境变量)
> PATH=/usr/local/php/bin/:$PATH
> export PATH
> EOF
[root@localhost php]# source /etc/profile.d/php.sh
[root@localhost php]# php -v
PHP 7.3.8 (cli) (built: Aug 11 2019 01:42:25) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.8, Copyright (c) 1998-2018 Zend Technologies
[root@localhost php]# tee /var/www/html/index.php<<-"EOF"		(编辑php测试页面)
> <?php
>     phpinfo();
> ?>
> EOF
[root@localhost php]# vim /etc/httpd/conf/httpd.conf
    AddType application/x-gzip .gz .tgz		(在此行下面加入下面两行)
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps
[root@localhost php]# systemctl restart httpd

web访问:
在这里插入图片描述
暂时,LAMP搭建已OK,接下来部署zabbix
部署zabbix

[root@localhost zabbix-4.2.5]# groupadd zabbix
[root@localhost zabbix-4.2.5]# useradd -s /sbin/nologin -M -g zabbix zabbix
[root@localhost zabbix-4.2.5]# yum install net-snmp-devel libevent libevent-devel
[root@localhost ~]# tar xf zabbix-4.2.5.tar.gz -C /usr/local/src/
[root@localhost ~]# cd /usr/local/src/zabbix-4.2.5/
[root@localhost ~]# ./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql=/var/lib/mysql/bin/mysql_config --with-net-snmp --with-libcurl
......
checking for mysql_config... no
checking for mariadb_config... no
configure: error: MySQL library not found		(安装mariadb-devel即可解决)
[root@localhost zabbix-4.2.5]# yum install mariadb-devel
[root@localhost zabbix-4.2.5]# ./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --with-nt-snmp --with-libcurl

***********************************************************
*            Now run 'make install'                       *
*                                                         *
*            Thank you for using Zabbix!                  *
*              <http://www.zabbix.com>                    *
***********************************************************

[root@localhost zabbix-4.2.5]# 
[root@localhost zabbix-4.2.5]# make install		(按照提示,可直接按照)

mysql配置

[root@localhost ~]# vim /etc/my.cnf
character-set-server=utf8					(在mysqld字段内添加此参数)
[root@localhost ~]# systemctl restart mariadb
[root@localhost ~]# mysql_secure_installation			(初始化数据库并设置root密码)

MariaDB [(none)]> create database zabbix;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> grant all on zabbix.* to zabbix@localhost identified by 'zabbix';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
[root@localhost ~]# mysql -uzabbix -pzabbix zabbix < /usr/local/src/zabbix-4.2.5/database/mysql/schema.sql (导入zabbix数据库模板)
[root@localhost ~]# mysql -uzabbix -pzabbix zabbix < /usr/local/src/zabbix-4.2.5/database/mysql/images.sql 
[root@localhost ~]# mysql -uzabbix -pzabbix zabbix < /usr/local/src/zabbix-4.2.5/database/mysql/data.sql

web配置

[root@localhost ~]# rm -rf /var/www/html/*
[root@localhost ~]# cp -r /usr/local/src/zabbix-4.2.5/frontends/php/* /var/www/html/

web访问:
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
发现报错挺多的,依次解决:

[root@localhost ~]# vim /usr/local/php/etc/php.ini
post_max_size = 16M
max_execution_time = 300
max_input_time = 300
date.timezone =Asia/Shanghai
[root@localhost ~]# systemctl restart httpd

在这里插入图片描述
部分已解决,剩下需要重新编译:

[root@localhost php-7.3.8]# ./configure --prefix=/usr/local/php\/ --with-apxs2=/usr/bin/apxs --enable-mbstring --with-curl --with-gd --enable-fpm --enable-mysqlnd  --with-pdo-mysql=mysqlnd --with-config-file-path=/usr/local/php/etc/ --with-mysqli=mysqlnd --with-mysql-sock=/var/lib/mysql/mysql.sock --without-pear --disable-phar --with-bcmath --with-sockets --with-jpeg-dir --with-ldap --with-gettext --with-freetype-dir
.......
checking whether to enable JIS-mapped Japanese font support in GD... no
If configure fails try --with-webp-dir=<DIR>
configure: error: jpeglib.h not found.

报错,error: jpeglib.h not found.,暂时先去掉jpeg参数,等下扩展安装

[root@localhost php-7.3.8]# ./configure --prefix=/usr/local/php\/ --with-apxs2=/usr/bin/apxs --enable-mbstring --with-curl --with-gd --enable-fpm --enable-mysqlnd  --with-pdo-mysql=mysqlnd --with-config-file-path=/usr/local/php/etc/ --with-mysqli=mysqlnd --with-mysql-sock=/var/lib/mysql/mysql.sock --without-pear --disable-phar --with-bcmath --with-sockets --with-ldap --with-gettext --with-freetype-dir
.......
checking whether to enable JIS-mapped Japanese font support in GD... no
If configure fails try --with-webp-dir=<DIR>
If configure fails try --with-jpeg-dir=<DIR>
checking for png_write_image in -lpng... yes
If configure fails try --with-xpm-dir=<DIR>
configure: error: freetype-config not found.

此问题是未安装freetype-devel包

[root@localhost php-7.3.8]# yum install freetype-devel
[root@localhost php-7.3.8]# ./configure --prefix=/usr/local/php\/ --with-apxs2=/usr/bin/apxs --enable-mbstring --with-curl --with-gd --enable-fpm --enable-mysqlnd  --with-pdo-mysql=mysqlnd --with-config-file-path=/usr/local/php/etc/ --with-mysqli=mysqlnd --with-mysql-sock=/var/lib/mysql/mysql.sock --without-pear --disable-phar --with-bcmath --with-sockets --with-ldap --with-gettext --with-freetype-dir
.......
checking for ANSI C header files... (cached) yes
checking for LDAP support... yes
checking for LDAP Cyrus SASL support... no
checking size of long int... (cached) 8
configure: error: Cannot find ldap libraries in /usr/lib.

此处,报错也暂且去掉ldap参数,等下扩展安装

[root@localhost php-7.3.8]# ./configure --prefix=/usr/local/php\/ --with-apxs2=/usr/bin/apxs --enable-mbstring --with-curl --with-gd --enable-fpm --enable-mysqlnd  --with-pdo-mysql=mysqlnd --with-config-file-path=/usr/local/php/etc/ --with-mysqli=mysqlnd --with-mysql-sock=/var/lib/mysql/mysql.sock --without-pear --disable-phar --with-bcmath --with-sockets --with-gettext --with-freetype-dir
.....
config.status: creating sapi/cgi/php-cgi.1
config.status: creating main/php_config.h
config.status: executing default commands
configure: WARNING: unrecognized options: --with-bcmath, --with-sockets

查询参数:

[root@localhost php-7.3.8]# ./configure --help |egrep "bcmath|sockets"  (发现是参数失误写错了,更改之)
  --enable-bcmath         Enable bc style precision math functions
  --enable-sockets        Enable sockets support
[root@localhost php-7.3.8]# make clean					(务必执行此命令,否则freetype无法生效)
[root@localhost php-7.3.8]# ./configure --prefix=/usr/local/php\/ --with-apxs2=/usr/bin/apxs --enable-mbstring --with-curl --with-gd --enable-fpm --enable-mysqlnd  --with-pdo-mysql=mysqlnd --with-config-file-path=/usr/local/php/etc/ --with-mysqli=mysqlnd --with-mysql-sock=/var/lib/mysql/mysql.sock --without-pear --disable-phar --enable-bcmath --enable-sockets --with-gettext --with-freetype-dir
[root@localhost php-7.3.8]# make -j 4
[root@localhost php-7.3.8]# make install

在这里插入图片描述
jpeg扩展安装

[root@localhost php-7.3.8]# cd ext/gd
[root@localhost gd]# /usr/local/php/bin/phpize 
Configuring for:
PHP Api Version:         20180731
Zend Module Api No:      20180731
Zend Extension Api No:   320180731

[root@localhost php-7.3.8]# make clean
[root@localhost php-7.3.8]# ./configure --prefix=/usr/local/php\/ --with-apxs2=/usr/bin/apxs --enable-mbstring --with-curl --with-gd --enable-fpm --enable-mysqlnd  --with-pdo-mysql=mysqlnd --with-config-file-path=/usr/local/php/etc/ --with-mysqli=mysqlnd --with-mysql-sock=/var/lib/mysql/mysql.sock --without-pear --disable-phar --enable-bcmath --enable-sockets --with-gettext --with-freetype-dir --with-jpeg-dir
.......
checking for FreeType 2... yes
checking whether to enable JIS-mapped Japanese font support in GD... no
If configure fails try --with-webp-dir=<DIR>
configure: error: jpeglib.h not found.
[root@localhost php-7.3.8]# yum install libjpeg-devel
[root@localhost php-7.3.8]# ./configure --prefix=/usr/local/php\/ --with-apxs2=/usr/bin/apxs --enable-mbstring --with-curl --with-gd --enable-fpm --enable-mysqlnd  --with-pdo-mysql=mysqlnd --with-config-file-path=/usr/local/php/etc/ --with-mysqli=mysqlnd --with-mysql-sock=/var/lib/mysql/mysql.sock --without-pear --disable-phar --enable-bcmath --enable-sockets --with-gettext --with-freetype-dir --with-jpeg-dir
[root@localhost php-7.3.8]# make -j 4
[root@localhost php-7.3.8]# make install
[root@localhost php-7.3.8]# systemctl restart httpd

刷新页面,只剩ldap了
在这里插入图片描述
LDAP:

[root@localhost php-7.3.8]# cd ext/ldap
[root@localhost ldap]# /usr/local/php/bin/phpize 
Configuring for:
PHP Api Version:         20180731
Zend Module Api No:      20180731
Zend Extension Api No:   320180731
[root@localhost ldap]# ./configure --with-php-config=/usr/local/php/bin/php-config --with-ldap
.....
checking for inttypes.h... (cached) yes
checking for stdint.h... (cached) yes
checking for unistd.h... (cached) yes
configure: error: Cannot find ldap libraries in /usr/lib.
[root@localhost ldap]# find /usr/ -name "*libldap*"
/usr/lib64/libldap-2.4.so.2
/usr/lib64/libldap-2.4.so.2.10.7
/usr/lib64/libldap_r-2.4.so.2
/usr/lib64/libldap_r-2.4.so.2.10.7
/usr/lib64/libldap.so
/usr/lib64/libldap_r.so
[root@localhost ldap]# cp /usr/lib64/libldap* /usr/lib/
[root@localhost ldap]# ./configure --with-php-config=/usr/local/php/bin/php-config --with-ldap
[root@localhost ldap]# make
[root@localhost ldap]# make install
[root@localhost ldap]# vim /usr/local/php/etc/php.ini 
extension=ldap.so					(末尾追加此项)
[root@localhost ldap]# systemctl restart httpd

在这里插入图片描述
环境全部OK,继续安装:
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
按照说明下载配置文件并放置到指定位置:

[root@localhost ldap]# mv zabbix.conf.php /var/www/html/conf/

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值