linux 安装php8

 

系统已经安装过php7了所以很多依赖不在重新安装了

cd  /usr/local/src

wget https://www.php.net/distributions/php-8.0.1.tar.gz

tar -zxvf php-8.0.1.tar.gz

cd php-8.0.1

配置(注意和默认的PHP版本以目录区隔)

./configure \
--prefix=/usr/local/php8 \
--exec-prefix=/usr/local/php8 \
--bindir=/usr/local/php8/bin \
--sbindir=/usr/local/php8/sbin \
--includedir=/usr/local/php8/include \
--libdir=/usr/local/php8/lib/php \
--mandir=/usr/local/php8/php/man \
--with-config-file-path=/usr/local/php8/etc \
--with-openssl \
--enable-mbstring \
--enable-fpm

报错了PHP8 默认要求sqlite3和oniguruma 

configure: error: Package requirements (sqlite3 > 3.7.4) were not met:
No package 'sqlite3' found

configure: error: Package requirements (oniguruma) were not met:
No package 'oniguruma' found


yum install sqlite3 sqlite3-devel
yum install oniguruma oniguruma-devel

  依赖检查完毕之后 make && make install 编译完毕以后执行下版本验证命令

/usr/local/php8/bin/php -v

PHP 8.0.1 (cli) (built: Jan 28 2021 17:29:05) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.1, Copyright (c) Zend Technologies

在之前编译的源码包中,找到 php.ini-production,复制到/usr/local/php/etc下,并改名为php.ini:

cp php.ini-production /usr/local/php8/etc/php.ini

cp sapi/fpm/init.d.php-fpm /etc/init.d/php8-fpm
 
chmod +x /etc/init.d/php8-fpm

添加php-fpm

cp /usr/local/php8/etc/php-fpm.conf.default /usr/local/php8/etc/php-fpm.conf 

添加 www.conf 配置文件 

[root@zhaoyinfan001 php-8.0.1]# cp /usr/local/php8/etc/php-fpm.d/www.conf.default /usr/local/php8/etc/php-fpm.d/www.conf 

PHP多版本环境变量,添加以后php8 -v

vim /etc/profile
 PATH=/usr/local/php/bin:$PATH
 alias php7.3.3='/usr/local/php7.3.3/bin/php'
 alias php8='/usr/local/php8/bin/php'
 
source /etc/profile

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值