Linux 源码编译安装PHP环境

Linux 源码编译安装PHP环境

下载源码

为了安全起见,我们去官网下载:https://www.php.net/downloads,选择合适自己项目的稳定版本,我这里用官网最新稳定版本

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

解压

tar -zxvf php-7.4.1.tar.gz
cd php-7.4.1

配置

根据自己需求来选择要安装的扩展,下面是我的配置,--prefix 指定PHP安装目录

./configure --prefix=/usr/local/php7 --with-curl --with-mysqli --with-openssl --with-pdo-mysql --with-gd --e
nable-fpm --enable-bcmath --enable-xml --enable-zip --enable-mbstring --enable-sockets 

配置可选

 --with-curl
 --with-freetype-dir
 --with-gd
 --with-gettext
 --with-iconv-dir
 --with-kerberos
 --with-libdir=lib64
 --with-libxml-dir
 --with-mysqli
 --with-openssl
 --with-pcre-regex
 --with-pdo-mysql
 --with-pdo-sqlite
 --with-pear
 --with-png-dir
 --with-xmlrpc
 --with-xsl
 --with-zlib
 --enable-fpm
 --enable-bcmath
 --enable-libxml
 --enable-inline-optimization
 --enable-gd-native-ttf
 --enable-mbregex
 --enable-mbstring
 --enable-opcache
 --enable-pcntl
 --enable-shmop
 --enable-soap
 --enable-sockets
 --enable-sysvsem
 --enable-xml
 --enable-zip

配置是报错:libcurl 包不存在

configure: error: Package requirements (libcurl >= 7.15.5) were not met:
No package 'libcurl' found

我们用 yum 安装下该包,并注意版本要求,同理其它包不存在时,把 libcurl 替换成其他包名,并执行命令安装即可

yum install libcurl-devel

编译安装

make && make install

配置环境变量

添加 :/usr/local/php7/bin:/usr/local/php7/bsin 路径和其他路径用 : 分隔

vim ~/.bash\_profile

image.png

source ~/.bash\_profile
发布了284 篇原创文章 · 获赞 258 · 访问量 121万+

猜你喜欢

转载自blog.csdn.net/meimeieee/article/details/103938400