轻松搞定:在CentOS 7上编译安装PHP8.2实战教程
编译安装前准备
为了减少编译过程中出现问题(包冲突、源问题),请您尽量使用干净的,未安装过PHP环境的CentOS系统!
将yum源替换成国内镜像,这样后续下载依赖的时候,速度更快!
yum install -y wget
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo && yum clean all && yum makecache
安装接下来编译所需要的依赖包
yum install -y libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel ncurses curl gdbm-devel db4-devel libXpm-devel libX11-devel gd-devel gmp-devel expat-devel xmlrpc-c xmlrpc-c-devel libicu-devel libmcrypt-devel libmemcached-devel libsqlite3x-devel oniguruma-devel
安装编译工具
yum groupinstall 'Development Tools'
wget下载PHP8.2.8
源文件
wget -c https://www.php.net/distributions/php-8.2.8.tar.gz
开始编译
将刚刚下载的PHP8.2.8源码解压
tar -zxvf ./php-8.2.8.tar.gz
cd ./php-8.2.8
使用以下命令开始编译,回车等待执行完成
./configure --prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc \
--enable-fpm \
--with-fpm-user=www-data \
--with-fpm-group=www-data \
--enable-inline-optimization \
--disable-debug \
--disable-rpath \
--enable-shared \
--enable-soap \
--with-xmlrpc \
--with-openssl \
--with-mhash \
--with-pcre-regex \
--with-sqlite3 \
--with-zlib \
--enable-bcmath \
--with-iconv \
--with-bz2 \
--enable-calendar \
--with-curl \
--with-cdb \
--enable-dom \
--enable-exif \
--enable-fileinfo \
--enable-filter \
--with-pcre-dir \
--enable-ftp \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-zlib-dir \
--with-freetype-dir \
--enable-gd-jis-conv \
--with-gettext \
--with-gmp \
--with-mhash \
--enable-json \
--enable-mbstring \
--enable-mbregex \
--enable-mbregex-backtrack \
--with-libmbfl \
--with-onig \
--enable-pdo \
--with-pdo-mysql \
--with-zlib-dir \
--with-pdo-sqlite \
--with-readline \
--enable-session \
--enable-shmop \
--enable-simplexml \
--enable-sockets \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-wddx \
--with-libxml-dir \
--with-xsl \
--enable-zip \
--enable-mysqlnd-compression-support \
--with-pear \
--enable-opcache
以上命令跑完之后,开始进行测试编译是否通过并安装
make && make install
将php命令软连接到系统命令里,方便全局使用
ln -s /usr/local/php/bin/php /usr/bin/php
检验PHP是否完成,输入命令:
php -v
PHP 8.2.8 (cli) (built: Jul 30 2023 15:00:17) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.8, Copyright (c) Zend Technologies
这个时候显示PHP版本说明已经安装成功!
- 感谢你赐予我前进的力量
赞赏者名单
因为你们的支持让我意识到写文章的价值🙏
本文是原创文章,完整转载请注明来自 [ 谷溪雨 ] 。
评论
匿名评论
隐私政策
你无需删除空行,直接评论以获取最佳展示效果