centos7.7编译安装php7.3.8
一、下载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