linux centos 安装php8

本文详细介绍了在CentOS系统上安装PHP8的步骤,包括从下载到解压,以及解决安装过程中遇到的sqlite3、icu-uc、oniguruma和libzip依赖问题的方法。同时,文章还指导了如何配置、测试PHP8,启用新特性如opcache和JIT,并检查其是否生效。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.下载php8
链接: https://pan.baidu.com/s/10C4U2GPnLXb_KZLLmbY6dw 密码: 9chu
2.解压:

tar -zxvf php-8.0.0.tar.gz

3.配置、安装

./configure --prefix=/usr/local/php8 --with-config-file-path=/usr/local/php8/etc \
--with-curl --with-freetype --enable-gd --with-jpeg  --with-gettext --with-kerberos --with-libdir=lib64 --with-libxml \
--with-mysqli --with-openssl --with-pdo-mysql  --with-pdo-sqlite --with-pear --enable-sockets --with-mhash --with-ldap-sasl \
--with-xsl --with-zlib --with-zip -with-bz2 --with-iconv  --enable-fpm --enable-pdo  --enable-bcmath  --enable-mbregex \
--enable-mbstring --enable-opcache --enable-pcntl  --enable-shmop --enable-soap --enable-sockets --enable-sysvsem \
--enable-xml --enable-sysvsem --enable-cli --enable-opcache --enable-intl --enable-calendar --enable-static --enable-mysqlnd

其中可能报
No package ‘sqlite3’ found
解决方法:

yum install sqlite-devel

No package ‘icu-uc’ found
解决方法:

yum install libicu-devel

No package ‘oniguruma’ found
解决方法:

yum install oniguruma-devel

No package ‘libzip’ found

解决方法:

yum install libzip-devel

Requested ‘libzip >= 0.11’ but version of libzip is 0.10.1
解决方法:
下载libzip:
链接: https://pan.baidu.com/s/1OJJFHMM6C-f1WSa5D_ppyw 密码: 9km1

tar -zxvf libzip-1.2.0.tar.gz
cd libzip-1.2.0
./configure
make && make install
export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig/"

如果出现下面则表示配置成功:

+--------------------------------------------------------------------+
| License:                                                           |
| This software is subject to the PHP License, available in this     |
| distribution in the file LICENSE. By continuing this installation  |
| process, you are bound by the terms of this license agreement.     |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point.                            |
+--------------------------------------------------------------------+

Thank you for using PHP.

测试是否安装成功:

/usr/local/php8/bin/php --version

配置:

cp php.ini-production /usr/local/php8/etc/php.ini
cd /usr/local/php8/etc/php-fpm.d/
cp www.conf.default www.conf
cd /usr/local/php8/etc/
cp php-fpm.conf.default php-fpm.conf

启用php8的新特性:
编辑php.ini
启用opcache

opcache.enable=1
opcache.enable_cli=1

;启用jit,并指定jit的buffer

opcache.jit_buffer_size=128M
opcache.jit=1255

;zend对opcache模块的引用,要打开

zend_extension=opcache

然后重启
查看phpinfo信息
需要能看到zend opcache一项,
否则opcache未生效
注意看JIT中的一项,需要值为On

新建jit.php

<?php
var_dump(opcache_get_status()['jit']);

如下输出:

array(7) { 
["enabled"]=> bool(true) 
["on"]=> bool(true) 
["kind"]=> int(5)
["opt_level"]=> int(5) 
["opt_flags"]=> int(6) 
["buffer_size"]=> int(134217712)
["buffer_free"]=> int(134215440)
}

注意:如果enabled和on两项的值都为true,
则表示jit已开启

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值