- 官网下载tar包 地址
wget http://cn2.php.net/distributions/php-7.3.1.tar.gz
- 解压
tar -zxvf php-7.3.1.tar.gz
- 进入解压目录
cd php-7.3.1
- 编译
./configure \--prefix=/usr/local/php \--exec-prefix=/usr/local/php \--bindir=/usr/local/php/bin \--sbindir=/usr/local/php/sbin \--includedir=/usr/local/php/include \--libdir=/usr/local/php/lib/php \--mandir=/usr/local/php/php/man \--with-config-file-path=/usr/local/php/etc \--with-mysql-sock=/var/lib/mysql/mysql.sock \--with-mhash \--with-openssl \--with-mysqli=shared,mysqlnd \--with-pdo-mysql=shared,mysqlnd \--with-gd \--with-jpeg-dir \--with-png-dir \--with-iconv \--with-zlib \--enable-zip \--enable-inline-optimization \--disable-debug \--disable-rpath \--enable-shared \--enable-xml \--enable-bcmath \--enable-shmop \--enable-sysvsem \--enable-mbregex \--enable-mbstring \--enable-ftp \--enable-pcntl \--enable-sockets \--with-xmlrpc \--enable-soap \--without-pear \--with-gettext \--enable-session \--with-curl \--with-freetype-dir \--enable-opcache \--enable-fpm \--with-fpm-user=www \--with-fpm-group=www \--without-gdbm \--disable-fileinfo
报错:
configure: error: off_t undefined; check your library configuration
解决方法:
根据报错信息分析 configure: error: off_t undefined; check your library configuration
未定义的类型 off_t。
off_t 类型是在头文件unistd.h中定义的,在32位系统编译成long int,64位系统则编译成 long long int,我的系统是64位的吧,在进行编译的时候是默认查找64位的动态链接库,但是默认情况下centos的动态链接库配置文件/etc/ld.so.conf里并没有加入搜索路径,这个时候需要将 /usr/local/lib64 /usr/lib64 这些针对64位的库文件路径加进去。
添加搜索路径到配置文件
echo '/usr/local/lib64/usr/local/lib/usr/lib/usr/lib64'>>/etc/ld.so.conf
更新配置
ldconfig -v
(其中ldconfig -v 是用来更新ld的缓存文件 ld.so.cache , 缓存文件的目的是记录动态编译库文件的路径,加快二进制文件运行时的速度)
- 重新编译
- 安装
make&& make install
- 等待10-20分钟,搞定
[root@bobo php-7.3.1]# /usr/local/php/bin/php -vPHP 7.3.1 (cli) (built: Jan 19 2019 12:47:26) ( NTS )Copyright (c) 1997-2018 The PHP GroupZend Engine v3.3.1, Copyright (c) 1998-2018 Zend Technologies