linux下编译安装php7.4详细过程

fengmian

步骤1、安装环境准备

操作系统版本:centos 7

php版本:php-7.4.16

先安装一些依赖库

yum -y install gcc*

yum -y install libcurl-devel sqlite-devel libxml2-devel

yum -y install 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

步骤2、下载php压缩包,解压后进入到目录下

cd /usr/local

tar -zxvf  php-7.4.16.tar.gz

步骤3、编译安装,直接把常用的扩展安装好,免得后面在一个一个安装(推荐)

./configure –prefix=/usr/local/php –with-curl –with-freetype –enable-gd –with-jpeg –with-gettext –with-gmp –with-mysqli –with-openssl –with-pdo-mysql –with-pear –with-xmlrpc –with-xsl –with-mhash –enable-fpm –enable-bcmath –enable-mbstring –enable-sockets –enable-xml –enable-embed –enable-phpdbg –with-bz2 –enable-calendar –with-curl –enable-exif –enable-ftp –enable-pcntl –with-zlib –with-readline –enable-shmop –enable-sockets

看到如下信息则编译成功(如果报错可以删除一些不需要扩展)

+——————————————————————–+

| License:                                                           |

| This software is subject to the PHP License, available in this     |

| distribution in the file LICENSE. By continuing this installation  |

| process, you are bound by the terms of this license agreement.     |

| If you do not agree with the terms of this license, you must abort |

| the installation process at this point.                            |

+——————————————————————–+

Thank you for using PHP.

步骤4make安装

make && make install

步骤5.安装成功之后,设置环境变量

vi /etc/profile

PATH=$PATH:/usr/lcoal/php/bin

export PATH

立即生效

source  /etc/profile

步骤6. 测试查看PHP版本

php -v

php -m 查看一些扩展模块

linux下编译安装php7.4详细过程

发表回复

滚动到顶部