惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

The Hacker News
The Hacker News
WordPress大学
WordPress大学
aimingoo的专栏
aimingoo的专栏
The Last Watchdog
The Last Watchdog
小众软件
小众软件
S
Security @ Cisco Blogs
S
Schneier on Security
Forbes - Security
Forbes - Security
S
Secure Thoughts
W
WeLiveSecurity
Latest news
Latest news
博客园 - Franky
Last Week in AI
Last Week in AI
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
美团技术团队
Schneier on Security
Schneier on Security
V
V2EX
Hugging Face - Blog
Hugging Face - Blog
B
Blog
GbyAI
GbyAI
A
About on SuperTechFans
爱范儿
爱范儿
博客园 - 叶小钗
T
Tor Project blog
SecWiki News
SecWiki News
Blog — PlanetScale
Blog — PlanetScale
A
Arctic Wolf
博客园 - 聂微东
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
MongoDB | Blog
MongoDB | Blog
P
Proofpoint News Feed
Application and Cybersecurity Blog
Application and Cybersecurity Blog
G
GRAHAM CLULEY
Webroot Blog
Webroot Blog
Google Online Security Blog
Google Online Security Blog
博客园 - 三生石上(FineUI控件)
Hacker News: Ask HN
Hacker News: Ask HN
Hacker News - Newest:
Hacker News - Newest: "LLM"
The Register - Security
The Register - Security
C
CERT Recently Published Vulnerability Notes
K
Kaspersky official blog
U
Unit 42
Apple Machine Learning Research
Apple Machine Learning Research
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
S
Security Affairs
V2EX - 技术
V2EX - 技术
Help Net Security
Help Net Security
阮一峰的网络日志
阮一峰的网络日志
Recent Announcements
Recent Announcements
J
Java Code Geeks

星辰日记

临时邮箱:开发者的隐私工具实践笔记 为 QuMagie 备份的照片添加 Exif 信息 Riverpod - flutter 状态管理的应用 夜景随拍 大疆 Mini 4K 初体验 5月12日 随笔 你好 2024 HHKB 使用体验 历经59天, 终于拿到软著 渺软公益CDN - 又一个静态资源加速站 你好 2023 记一次 RAID 硬盘离线 大一 碎语 试用 Google CA 的 SSL 证书 Waline 邮件异步推送 Magic Trackpad 使用体验 Redis 统计实时在线人数 Centos 7 升级 Glibc-2.28 Nginx 重写 Query 参数
Centos 编译安装 php81
xcsoft · 2022-06-16 · via 星辰日记

出于 开发环境配置及学习的需求, 需要直接在 Centos 7 上编译安装 php-81.

最近在使用 webman 重构 拾光 的后端, 虽然 这次迭代可能存在一定的破坏性, 但得益于 Webman 的现有生态 以及 复用了多数的 Composer 库. 将会为 以后的版本迭代及功能扩展 带来一定的便利.

我们可以直接在 官网 找到源码, 这里选择 php-8.1.7.tar.gz, 通过 wget 等工具 下载至服务器.

相关依赖

编译之前, 需要安装一些依赖.

1
$ yum install libxml2-devel openssl-devel sqlite-devel libcurl-devel libicu-devel gcc-c++ oniguruma oniguruma-devel libxslt-devel libpng-devel libjpeg-devel freetype-devel libsodium libsodium-devel epel-release -y

接着通过tar -xzvf php-8.1.7.tar.gz 解压下载后的文件. 进入文件夹

开始编译

我们可以使用 cconfigure 来检验当前的系统环境, 看是否满足安装软件所必需的条件:

1
$ ./configure --prefix=/root/php/81 --with-config-file-path=/root/php/81/etc --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype --with-jpeg --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --enable-intl --enable-pcntl --enable-ftp --enable-gd --with-openssl --with-mhash --enable-pcntl --enable-sockets --enable-soap --with-gettext --disable-fileinfo --enable-opcache --with-sodium=/usr/local/libsodium

如果此处 出现错误, 可以尝试根据提示 安装相关依赖

这里 我们已经选择安装了一些 常用的php扩展, 您也可以在 ext 目录下 找到更多信息.

在校验完成后 我们会看到 类似 Thank you for using PHP. 的相关信息

接着 使用 make && make install 将其 编译安装至 /root/php/81 目录下, 安装完成后, 我们需要将 当前目录下的 php.ini-development 或 php.ini-production 文件 复制到 /root/php/81/etc/ 目录下, 并重命名为 php.ini

接着添加 PATH="/root/php/81/bin:$PATH"~/.bashrc 中 来将 php 添加至环境变量中, 重新打开终端 或使用 source ~/.bashrc 使环境变量生效

验证安装

1
2
3
4
5
6
$ php -v

PHP 8.1.7 (cli) (built: Jun 16 2022 14:52:05) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.7, Copyright (c) Zend Technologies

其他

对于 Centos 8 后, 使用 dnf 替代了 yum, 需要启用 PowerTool 来安装部分 开发依赖

1
2
$ sudo yum install dnf-plugins-core
$ sudo dnf config-manager --set-enabled powertools