cd ../php-NN./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-pdo-mysqlmakemake install
tar -zxvf php-8.1.6.tar.gz
cd php-8.1.6
./configure --with-apxs2=/usr/bin/apxs --with-pdo-mysql
./configure --with-apxs2=/usr/bin/apxs \
--prefix=/usr/local/php8 \
--with-config-file-path=/usr/local/php8 \
--with-config-file-scan-dir=/usr/local/php8/php.d \
--enable-mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--enable-fpm \
--with-fpm-user=apache \
--with-fpm-group=apache \
--with-gd \
--with-iconv \
--with-zlib \
--enable-xml \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--enable-mbregex \
--enable-mbstring \
--enable-ftp \
--with-openssl \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--with-zip \
--enable-soap \
--without-pear \
--with-gettext \
--enable-session \
--with-curl \
--with-jpeg=/usr/lib64 \
--with-freetype=/usr/lib64 \
--enable-opcache
如果按照上面编译安装,则会报警示,参数需要再核对:
configure: WARNING: unrecognized options: --with-gd, --enable-inline-optimization, --with-xmlrpc
cp /usr/local/src/php-8.1.6/php.ini-production /usr/local/php8/
[root@zabbix php8]# php -vPHP 8.1.6 (cli) (built: May 24 2022 13:47:06) (ZTS)Copyright (c) The PHP GroupZend Engine v4.1.6, Copyright (c) Zend Technologies
[root@zabbix php8]# php --iniConfiguration File (php.ini) Path: /usr/local/php8Loaded Configuration File: /usr/local/php8/php.iniScan for additional .ini files in: /usr/local/php8/php.dAdditional .ini files parsed: (none)
[root@zabbix bin]# ./php -m[PHP Modules]CorectypecurldatedomfileinfofilterftpgettexthashiconvjsonlibxmlmbstringmysqlimysqlndopensslpcntlpcrePDOpdo_mysqlpdo_sqlitePharposixReflectionsessionshmopSimpleXMLsoapsocketsSPLsqlite3standardsysvsemtokenizerxmlxmlreaderxmlwriterzlib[Zend Modules]
cd /usr/local/php8/etc
cp php-fpm.conf.default php-fpm.conf
cd /usr/local/php8/etc/php-fpm.d
cp www.conf.default www.conf
启动php-fpm
php-fpm
LoadModule php_module /usr/lib64/httpd/modules/libphp.so
AddType application/x-httpd-php .php
checking for sqlite3 >= 3.7.7... noconfigure: error: Package requirements (sqlite3 >= 3.7.7) were not met:Package 'sqlite3', required by 'virtual:world', not foundConsider adjusting the PKG_CONFIG_PATH environment variable if youinstalled software in a non-standard prefix.Alternatively, you may set the environment variables SQLITE_CFLAGSand SQLITE_LIBS to avoid the need to call pkg-config.See the pkg-config man page for more details.
yum install sqlite-devel
checking for oniguruma... noconfigure: error: Package requirements (oniguruma) were not met:Package 'oniguruma', required by 'virtual:world', not foundConsider adjusting the PKG_CONFIG_PATH environment variable if youinstalled software in a non-standard prefix.Alternatively, you may set the environment variables ONIG_CFLAGSand ONIG_LIBS to avoid the need to call pkg-config.See the pkg-config man page for more details.
yum install oniguruma-devel
[Tue May 24 14:19:09.751641 2022] [php:error] [pid 600084:tid 281470394495008] [client 10.46.18.50:32309] PHP Fatal error: Uncaught Error: Call to undefined function bccomp() in /var/www/html/zabbix/include/db.inc.php:816\nStack trace:\n#0 /var/www/html/zabbix/include/db.inc.php(715): dbQuoteInt()\n#1 [internal function]: {closure}()\n#2 /var/www/html/zabbix/include/db.inc.php(716): array_map()\n#3 /var/www/html/zabbix/include/classes/db/DB.php(1315): dbConditionInt()\n#4 /var/www/html/zabbix/include/classes/db/DB.php(1189): DB::dbFilter()\n#5 /var/www/html/zabbix/include/classes/db/DB.php(1099): DB::applyQueryFilterOptions()\n#6 /var/www/html/zabbix/include/classes/db/DB.php(1013): DB::createSelectQueryParts()\n#7 /var/www/html/zabbix/include/classes/db/DB.php(1029): DB::makeSql()\n#8 /var/www/html/zabbix/include/classes/api/services/CUser.php(1688): DB::select()\n#9 /var/www/html/zabbix/include/classes/api/clients/CLocalApiClient.php(121): CUser->checkAuthentication()\n#10 /var/www/html/zabbix/include/classes/api/wrappers/CFrontendApiWrapper.php(97): CLocalApiClient->callMethod()\n#11 /var/www/html/zabbix/include/classes/api/wrappers/CApiWrapper.php(94): CFrontendApiWrapper->callClientMethod()\n#12 /var/www/html/zabbix/include/classes/api/wrappers/CFrontendApiWrapper.php(63): CApiWrapper->callMethod()\n#13 /var/www/html/zabbix/include/classes/api/wrappers/CApiWrapper.php(82): CFrontendApiWrapper->callMethod()\n#14 /var/www/html/zabbix/include/classes/user/CWebUser.php(99): CApiWrapper->__call()\n#15 /var/www/html/zabbix/include/classes/core/ZBase.php(464): CWebUser::checkAuthentication()\n#16 /var/www/html/zabbix/include/classes/core/ZBase.php(187): ZBase->authenticateUser()\n#17 /var/www/html/zabbix/include/config.inc.php(25): ZBase->run()\n#18 /var/www/html/zabbix/index.php(24): require_once('...')\n#19 {main}\n thrown in /var/www/html/zabbix/include/db.inc.php on line 816
/usr/local/src/php-8.1.6/ext/bcmath
/usr/local/php8/bin/phpize
[root@zabbix bcmath]# /usr/local/php8/bin/phpizeConfiguring for:PHP Api Version: 20210902Zend Module Api No: 20210902Zend Extension Api No: 420210902Cannot find autoconf. Please check your autoconf installation and the$PHP_AUTOCONF environment variable. Then, rerun this script.
yum install autoconf
./configure --with-php-config=/usr/local/php8/bin/php-config
make && make install
vim /usr/local/php8/php.ini
#添加一行
extension=bcmath
Return type of CCookieSession::open($save_path, $session_name) should either be compatible with SessionHandlerInterface::open(string $path, string $name): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice [zabbix.php:22 → require_once() → ZBase->run() → ZBase->authenticateUser() → CAutoloader->loadClass() → require() → CAutoloader->loadClass() → require() in include/classes/core/CCookieSession.php:25]Return type of CCookieSession::close() should either be compatible with SessionHandlerInterface::close(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice [zabbix.php:22 → require_once() → ZBase->run() → ZBase->authenticateUser() → CAutoloader->loadClass() → require() → CAutoloader->loadClass() → require() in include/classes/core/CCookieSession.php:25]Return type of CCookieSession::read($session_id) should either be compatible with SessionHandlerInterface::read(string $id): string|false, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice [zabbix.php:22 → require_once() → ZBase->run() → ZBase->authenticateUser() → CAutoloader->loadClass() → require() → CAutoloader->loadClass() → require() in include/classes/core/CCookieSession.php:25]Return type of CCookieSession::write($session_id, $session_data) should either be compatible with SessionHandlerInterface::write(string $id, string $data): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice [zabbix.php:22 → require_once() → ZBase->run() → ZBase->authenticateUser() → CAutoloader->loadClass() → require() → CAutoloader->loadClass() → require() in include/classes/core/CCookieSession.php:25]Return type of CCookieSession::destroy($session_id) should either be compatible with SessionHandlerInterface::destroy(string $id): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice [zabbix.php:22 → require_once() → ZBase->run() → ZBase->authenticateUser() → CAutoloader->loadClass() → require() → CAutoloader->loadClass() → require() in include/classes/core/CCookieSession.php:25]Return type of CCookieSession::gc($maxlifetime) should either be compatible with SessionHandlerInterface::gc(int $max_lifetime): int|false, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice [zabbix.php:22 → require_once() → ZBase->run() → ZBase->authenticateUser() → CAutoloader->loadClass() → require() → CAutoloader->loadClass() → require() in include/classes/core/CCookieSession.php:25]
configure: error: Cannot find ldap libraries in /usr/lib.
cp -frp /usr/lib64/libldap* /usr/lib/
- PHP gd JPEG 图片格式不支持- PHP gd FreeType不支持
/usr/local/php8/bin/phpize
./configure --with-php-config=/usr/local/php8/bin/php-config --with-jpeg --with-freetype
checking for libjpeg... noconfigure: error: Package requirements (libjpeg) were not met:Package 'libjpeg', required by 'virtual:world', not foundConsider adjusting the PKG_CONFIG_PATH environment variable if youinstalled software in a non-standard prefix.Alternatively, you may set the environment variables JPEG_CFLAGSand JPEG_LIBS to avoid the need to call pkg-config.See the pkg-config man page for more details.
yum install libjpeg-devel freetype-devel