Press "Enter" to skip to content

CentOS8安装PHP8

最新系统上来了这大半年都没有时间安装用用,php-8.0.0beta2 也发布出来了,先记录一下,CentOS8安装选择最小安装(跟原来安装差不多没变化),所以安装速度很快,因为是最小安装所以有些工具没有,能少则少的原则

简单说一下yum源修改

先安装wget工具:

yum install -y wget
cd /etc/yum.repos.d/
mv CentOS-Base.repo CentOS-Base.repo.bak
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo

或者用

curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo
yum makecache 生成缓存

系统缺少命令ifconfig,netstat,whois等命令需要安装net-tools.x86_64,另外习惯使用vim编辑器,所以每次都会安装,常用的screen也是要安装的,但在CentOS8系统下直接yum install screen是安装失败的

[root@kiccleaf ~]# yum install screen
Repository AppStream is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository PowerTools is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Last metadata expiration check: 0:01:32 ago on Tue 25 Aug 2020 02:16:39 PM CST.
No match for argument: screen
Error: Unable to find a match: screen
办法总是有的,先安装epel-release
[root@kiccleaf ~]# yum install -y epel-release
Installed:
  epel-release-8-8.el8.noarch                                                                                                                                                                                                               

Complete!
[root@kiccleaf ~]# yum install -y screen
Installed:
  screen-4.6.2-10.el8.x86_64                                                                                                                                                                                                                

Complete!
[root@kiccleaf ~]# 
安装成功了!测试一下
[root@kiccleaf ~]# screen -S kiccleaf
新的窗体里面了
[root@kiccleaf ~]#
Ctrl+ad  临时退出窗体
[detached from 35676.kiccleaf]

重新进入刚才的窗体
[root@kiccleaf ~]# screen -r kiccleaf
退出窗体
[root@kiccleaf ~]# exit
exit
[screen is terminating]
到此完美使用screen工具了。
接下去安装vim和网络命令
[root@kiccleaf ~]# yum install -y net-tools.x86_64 vim 
来看一下系统的版本吧
[root@kiccleaf ~]# cat /etc/redhat-release 
CentOS Linux release 8.2.2004 (Core) 
[root@kiccleaf ~]# 

先下载PHP8源码包,下载网址:https://downloads.php.net/~pollita/

[root@kiccleaf ]# wget https://downloads.php.net/~pollita/php-8.0.0beta2.tar.gz
[root@kiccleaf ]# tar zxvf php-8.0.0beta2.tar.gz
[root@kiccleaf ]# cd php-8.0.0beta2
根据自己的需求进行配置安装相应的扩展
[root@kiccleaf php-8.0.0beta2]# ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-fpm --enable-static --enable-sockets --with-zip --enable-calendar --enable-bcmath --enable-mbstring --with-zlib --with-iconv=/usr/local/libiconv --enable-gd --enable-mbstring --with-curl --with-freetype --disable-ipv6 --disable-debug --with-openssl --enable-intl --enable-opcache

[root@kiccleaf php-8.0.0beta2]# make 
[root@kiccleaf php-8.0.0beta2]# make install

在执行中可能会遇到一些问题,这里简单说明一下:

1. configure: error: iconv does not support errno

[root@kiccleaf ]# wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz
[root@kiccleaf ]# tar zxvf libiconv-1.15.tar.gz
[root@kiccleaf libiconv-1.15]#  cd libiconv-1.15
[root@kiccleaf libiconv-1.15]# ./configure --prefix=/usr/local/libiconv
[root@kiccleaf libiconv-1.15]#  make 
[root@kiccleaf libiconv-1.15]#  make install
安装好PHP8后配置进行启动
[root@kiccleaf php-8.0.0beta2]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@kiccleaf php-8.0.0beta2]# chmod a+x /etc/init.d/php-fpm
[root@kiccleaf php-8.0.0beta2]# service php-fpm start
[root@kiccleaf php-8.0.0beta2]# php -v
PHP 8.0.0beta2 (cli) (built: Aug 24 2020 13:47:39) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.0-dev, Copyright (c) Zend Technologies
发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注