当前位置: 首页 > news >正文

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

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

    • 下载安装包
    • 解压下载的php tar源码包
    • 安装所需的一些依赖扩展库
    • 安装前的配置
    • 修改配置文件
      • 1、进入php8的安装包
    • 配置环境变量
    • 开机自启
    • 启动服务
    • 创建软连接
    • 常见问题
      • 1、checking for icu-uc >= 50.1 icu-io icu-i18n... no
      • 2、configure: error: Package requirements (oniguruma) were not met:
      • 3、configure: error: Cannot find libtidy
      • 4、configure: error: Package requirements (libxslt >= 1.1.0) were not met:
      • 5、error: Package requirements (sqlite3 > 3.7.4) were not met:

下载安装包

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

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

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

解压下载的php tar源码包

tar -zxvf php-8.3.16.tar.gz

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

yum -y install   libxml2*   openssl*  libcurl* libjpeg*      libpng*      freetype*      libmcrypt*

安装前的配置

cd php-8.3.16

进入目录,执行以下命令

./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

在这里插入图片描述继续执行以下命令

make && make install

在这里插入图片描述执行到这里,表示执行成功了
在这里插入图片描述

修改配置文件

1、进入php8的安装包

cd php-8.3.16/
cp -a php.ini-production /usr/local/php8/etc/php.ini

在这里插入图片描述
进入安装目录

cd /usr/local/php8/etccp -a php-fpm.conf.default php-fpm.conf  cd /usr/local/php8/etc/php-fpm.dcp www.conf.default www.conf

修改www.conf文件

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

listen = 127.0.0.1:9001
listen.owner = nginx
listen.group = nginx
listen.mode = 0666

在这里插入图片描述

配置环境变量

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

PATH=$PATH:/usr/local/php7/bin:/usr/local/php7/sbin/:/usr/local/php8/bin:/usr/local/php8/sbin/

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

source /etc/profile

开机自启

# 源码包 php-8.0.24/sapi/fpmcd ./php-8.3.16/sapi/fpmcp php-fpm.service /usr/lib/systemd/system/php-fpm-8.3.16.service
cp init.d.php-fpm /etc/init.d/php8-fpmchmod +x /etc/init.d/php8-fpm 

启动服务

service php8-fpm start
service php8-fpm stop
service php8-fpm restart

创建软连接

ln -s /usr/local/php8/bin/php /usr/local/bin/php8

在这里插入图片描述

常见问题

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

在这里插入图片描述

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

解决方案:

yum  -y install libicu-devel

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

在这里插入图片描述

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

解决方案:

yum -y install oniguruma oniguruma-devel

3、configure: error: Cannot find libtidy

yum -y install libtidy-devel

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

yum -y install libxslt-devel

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

yum install sqlite-devel
http://www.lryc.cn/news/526697.html

相关文章:

  • Baklib助力内容中台实施的最佳实践与成功案例探索
  • rocketmq-product-send方法源码分析
  • python flask中使用or查询和and查询,还有同时使用or、and的情况
  • 【第一天】零基础入门刷题Python-算法篇-数据结构与算法的介绍(持续更新)
  • 租房管理系统实现智能化租赁提升用户体验与运营效率
  • python3+TensorFlow 2.x(四)反向传播
  • Flutter 使用 flutter_inappwebview 加载 App 本地 HTML 文件
  • Word常见问题:嵌入图片无法显示完整
  • 为AI聊天工具添加一个知识系统 之68 详细设计 之9 三种中台和时间度量 之1
  • On to OpenGL and 3D computer graphics
  • 从曾国藩的经历看如何打破成长中的瓶颈
  • JavaWeb学习-SpringBotWeb开发入门(HTTP协议)
  • 数据库用户管理
  • BGP边界网关协议(Border Gateway Protocol)路由聚合详解
  • ASP.NET Core WebAPI的异步及返回值
  • 「 机器人 」仿生扑翼飞行器中的“被动旋转机制”概述
  • 「 机器人 」扑翼飞行器的数据驱动建模核心方法
  • 个人网站搭建
  • 飞书项目流程入门指导手册
  • xss靶场
  • XML实体注入漏洞攻与防
  • switch组件的功能与用法
  • cursor重构谷粒商城05——docker容器化技术快速入门【番外篇】
  • 高等数学学习笔记 ☞ 微分方程
  • 【探索 Kali Linux】渗透测试与网络安全的终极操作系统
  • 四方连续贴图是什么意思
  • RKNN_C++版本-YOLOV5
  • k8s优雅重启
  • 三高“高性能、高并发、高可靠”系统架构设计系列文章
  • opengrok_使用技巧