CentOS7使用源码安装PHP8教程整理

CentOS7使用源码安装PHP8教程整理

下载安装包

有多个安装版本,根据自己的需求可以下载php8的各个版本

https://www.php.net/downloads.php

bash 复制代码
wget https://www.php.net/distributions/php-8.3.16.tar.gz 

解压下载的php tar源码包

bash 复制代码
tar -zxvf php-8.3.16.tar.gz

安装所需的一些依赖扩展库

bash 复制代码
yum -y install   libxml2*   openssl*  libcurl* libjpeg*      libpng*      freetype*      libmcrypt*

安装前的配置

bash 复制代码
cd php-8.3.16

进入目录,执行以下命令

bash 复制代码
./configure --prefix=/usr/local/php8 --with-config-file-path=/usr/local/php8/etc --enable-fpm --enable-mysqlnd --with-fpm-user=nginx --with-fpm-group=nginx --with-curl --enable-gd --with-tidy --with-gettext --enable-intl --with-kerberos --with-libdir=lib64 --with-mysqli --enable-ftp --with-openssl --with-pdo-mysql --with-pdo-sqlite --with-pear --disable-fileinfo --with-xsl --with-zlib --with-bz2 --with-mhash --enable-bcmath --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-sysvshm --enable-xml --enable-calendar --enable-exif

看到这张图,表示执行成功,如果没有,就解决error

继续执行以下命令

bash 复制代码
make && make install

执行到这里,表示执行成功了

修改配置文件

1、进入php8的安装包

bash 复制代码
cd php-8.3.16/
cp -a php.ini-production /usr/local/php8/etc/php.ini

进入安装目录

bash 复制代码
cd /usr/local/php8/etc

cp -a php-fpm.conf.default php-fpm.conf  

cd /usr/local/php8/etc/php-fpm.d

cp www.conf.default www.conf

修改www.conf文件

修改端口号,9000 为9001,因为我有两个php版本,还有一个php7

bash 复制代码
listen = 127.0.0.1:9001
listen.owner = nginx
listen.group = nginx
listen.mode = 0666

配置环境变量

我这里是两个php版本,所以就又增加了一个php8

bash 复制代码
PATH=$PATH:/usr/local/php7/bin:/usr/local/php7/sbin/:/usr/local/php8/bin:/usr/local/php8/sbin/

保存环境变量,并执行以下命令,让其生效

bash 复制代码
source /etc/profile

开机自启

bash 复制代码
# 源码包 php-8.0.24/sapi/fpm

cd ./php-8.3.16/sapi/fpm

cp php-fpm.service /usr/lib/systemd/system/php-fpm-8.3.16.service
cp init.d.php-fpm /etc/init.d/php8-fpm

chmod +x /etc/init.d/php8-fpm 

启动服务

bash 复制代码
service php8-fpm start
service php8-fpm stop
service php8-fpm restart

创建软连接

bash 复制代码
ln -s /usr/local/php8/bin/php /usr/local/bin/php8

常见问题

1、checking for icu-uc >= 50.1 icu-io icu-i18n... no

bash 复制代码
checking for icu-uc >= 50.1 icu-io icu-i18n... no
configure: error: Package requirements (icu-uc >= 50.1 icu-io icu-i18n) were not met:

No package 'icu-uc' found
No package 'icu-io' found
No package 'icu-i18n' found

解决方案:

bash 复制代码
yum  -y install libicu-devel

2、configure: error: Package requirements (oniguruma) were not met:

bash 复制代码
checking whether to enable multibyte regex support (requires oniguruma)... yes
checking for oniguruma... no
configure: error: Package requirements (oniguruma) were not met:

No package 'oniguruma' found

解决方案:

bash 复制代码
yum -y install oniguruma oniguruma-devel

3、configure: error: Cannot find libtidy

bash 复制代码
yum -y install libtidy-devel

4、configure: error: Package requirements (libxslt >= 1.1.0) were not met:

bash 复制代码
yum -y install libxslt-devel

5、error: Package requirements (sqlite3 > 3.7.4) were not met:

bash 复制代码
yum install sqlite-devel
相关推荐
2501_9160074742 分钟前
iOS 26 软件性能测试 新版系统下评估全流程 + 多工具辅助方案
android·macos·ios·小程序·uni-app·cocoa·iphone
云霄IT1 小时前
绕过Frida检测反调试的一些办法
android·javascript
sang_xb1 小时前
Android 如何开启 16KB 模式
android·kotlin
alengan1 小时前
安卓上谷歌35版本
android
珹洺2 小时前
Java-Spring入门指南(二十五)Android 的历史,认识移动应用和Android 基础知识
android·java·spring
大白的编程日记.3 小时前
【MySQL】数据库表的CURD(二)
android·数据库·mysql
介一安全4 小时前
【Frida Android】基础篇4:Java层Hook基础——调用静态方法
android·网络安全·逆向·安全性测试·frida
怪兽20144 小时前
主线程 MainLooper 和一般 Looper 的异同?
android·面试
洋不写bug4 小时前
数据库的创建,查看,修改,删除,字符集编码和校验操作
android·数据库·adb
2501_915909065 小时前
iOS App 上架全流程详解:证书配置、打包上传、审核技巧与跨平台上架工具 开心上架 实践
android·ios·小程序·https·uni-app·iphone·webview