1. 官网下载tar包 地址
    1. wget http://cn2.php.net/distributions/php-7.3.1.tar.gz
  2. 解压
    1. tar -zxvf php-7.3.1.tar.gz
  3. 进入解压目录
    1. cd php-7.3.1
  4. 编译
    1. ./configure \
    2. --prefix=/usr/local/php \
    3. --exec-prefix=/usr/local/php \
    4. --bindir=/usr/local/php/bin \
    5. --sbindir=/usr/local/php/sbin \
    6. --includedir=/usr/local/php/include \
    7. --libdir=/usr/local/php/lib/php \
    8. --mandir=/usr/local/php/php/man \
    9. --with-config-file-path=/usr/local/php/etc \
    10. --with-mysql-sock=/var/lib/mysql/mysql.sock \
    11. --with-mhash \
    12. --with-openssl \
    13. --with-mysqli=shared,mysqlnd \
    14. --with-pdo-mysql=shared,mysqlnd \
    15. --with-gd \
    16. --with-jpeg-dir \
    17. --with-png-dir \
    18. --with-iconv \
    19. --with-zlib \
    20. --enable-zip \
    21. --enable-inline-optimization \
    22. --disable-debug \
    23. --disable-rpath \
    24. --enable-shared \
    25. --enable-xml \
    26. --enable-bcmath \
    27. --enable-shmop \
    28. --enable-sysvsem \
    29. --enable-mbregex \
    30. --enable-mbstring \
    31. --enable-ftp \
    32. --enable-pcntl \
    33. --enable-sockets \
    34. --with-xmlrpc \
    35. --enable-soap \
    36. --without-pear \
    37. --with-gettext \
    38. --enable-session \
    39. --with-curl \
    40. --with-freetype-dir \
    41. --enable-opcache \
    42. --enable-fpm \
    43. --with-fpm-user=www \
    44. --with-fpm-group=www \
    45. --without-gdbm \
    46. --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位的库文件路径加进去。

添加搜索路径到配置文件

  1. echo '/usr/local/lib64
  2. /usr/local/lib
  3. /usr/lib
  4. /usr/lib64'>>/etc/ld.so.conf

更新配置

  1. ldconfig -v

(其中ldconfig -v 是用来更新ld的缓存文件 ld.so.cache , 缓存文件的目的是记录动态编译库文件的路径,加快二进制文件运行时的速度)


  • 重新编译
  • 安装
    1. make&& make install
  • 等待10-20分钟,搞定
    1. [root@bobo php-7.3.1]# /usr/local/php/bin/php -v
    2. PHP 7.3.1 (cli) (built: Jan 19 2019 12:47:26) ( NTS )
    3. Copyright (c) 1997-2018 The PHP Group
    4. Zend Engine v3.3.1, Copyright (c) 1998-2018 Zend Technologies