centos7.7编译安装php7.3.8

本文详细介绍了在CentOS7.7环境中从源码编译并安装PHP7.3.8的过程,包括下载源码、安装依赖库、配置编译选项、解决常见错误等步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、下载php7.3.8

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

二、解压.tar.gz文件

tar -xzvf php-7.3.8.tar.gz

三、安装依赖

yum -y install gcc gcc-c++ kernel-devel
yum -y install httpd-devel
yum -y install wget pcre pcre-devel openssl openssl-devel libicu-devel autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel ncurses ncurses-devel curl curl-devel krb5-devel libidn libidn-devel openldap openldap-devel nss_ldap jemalloc-devel cmake boost-devel bison automake libevent libevent-devel gd gd-devel libtool* libmcrypt libmcrypt-devel mcrypt mhash libxslt libxslt-devel readline readline-devel gmp gmp-devel libcurl libcurl-devel openjpeg-devel gdbm-devel

四、添加用户组

#添加组

groupadd www

#添加用户

useradd -g www www

五、进入php-7.3.8目录下,执行./configure

./configure --prefix=/usr/local/php/php73 --with-config-file-path=/usr/local/php/php73/etc --with-apxs2=/usr/bin/apxs --with-fpm-user=www --with-fpm-group=www --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir --with-ldap=shared --with-gdbm --with-pear --with-gettext --with-curl --with-xmlrpc --with-openssl --with-mhash --with-gd --enable-fpm --enable-mysqlnd --enable-mysqlnd-compression-support --enable-xml --enable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-mbregex --enable-mbstring --enable-intl --enable-ftp --enable-gd-jis-conv --enable-pcntl --enable-sockets --enable-zip --enable-soap --enable-fileinfo --enable-opcache --enable-maintainer-zts

可能会报错

1、configure: error: Cannot find ldap libraries in /usr/lib
复制

  cp -frp /usr/lib64/libldap* /usr/lib/

2、configure: error: Please reinstall the libzip distribution
下载libzip-1.5.2

   wget https://libzip.org/download/libzip-1.5.2.tar.gz

解压

tar zxvf libzip-1.5.2.tar.gz

进入目录

cd libzip-1.5.2

编译安装

  mkdir build
  cd build
 cmake ..
 make && make install

注意:如果提示cmake版本过低,需新版本,则需要重新安装cmake。
下载cmake

wget https://cmake.org/files/v3.10/cmake-3.10.0-rc5.tar.gz

解压

tar zxf cmake-3.10.0-rc5.tar.gz

进入目录

cd cmake-3.10.0-rc5

编译安装

./bootstrap
  gmake
  gmake install

查看cmake版本出错:CMake Error:Could not find CMAKE_ROOT!!!
执行命令

 hash -r

3、configure: error: off_t undefined; check your library configuration
编辑:

vi /etc/ld.so.conf

添加如下几行

/usr/local/lib64
/usr/local/lib
/usr/lib
/usr/lib64
 :wq     #保存退出

使之生效

ldconfig -v

六、编译和安装

make && make install

七、配置PHP环境变量

编辑profile

vim /etc/profile

在profile文件末尾添加如下内容:

export PATH=$PATH:/usr/local/php7/bin  #这一步可以让我们全局使用php命令

让修改后的profile生效

source /etc/profile

八、复制php.ini

cp php.ini-development  /server/php/lib/php.ini

九、php -v查看版本

php -v

出现版本号即为安装成功

PHP 7.3.8 (cli) (built: Nov 19 2019 14:26:58) ( ZTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.8, Copyright (c) 1998-2018 Zend Technologies
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值