安装依赖
yum install gcc-c++ 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
安装PHP7.2
./configure \ --prefix=/opt/php/php7.2.10 \ --with-config-file-path=/opt/php/php7.2.10 \ --enable-fpm \ --with-fpm-user=nginx \ --with-fpm-group=nginx \ --enable-inline-optimization \ --disable-debug \ --disable-rpath \ --enable-shared \ --enable-soap \ --with-libxml-dir \ --with-xmlrpc \ --with-openssl \ --with-mhash \ --with-pcre-regex \ --with-sqlite3 \ --with-zlib \ --with-libzip \ --enable-bcmath \ --with-iconv \ --with-bz2 \ --enable-calendar \ --with-curl \ --with-cdb \ --enable-dom \ --enable-exif \ --enable-fileinfo \ --enable-filter \ --with-pcre-dir \ --enable-ftp \ --with-gd \ --with-openssl-dir \ --with-jpeg-dir \ --with-png-dir \ --with-freetype-dir \ --enable-gd-jis-conv \ --with-gettext \ --with-gmp \ --with-mhash \ --enable-json \ --enable-mbstring \ --enable-mbregex \ --enable-mbregex-backtrack \ --with-libmbfl \ --with-onig \ --enable-pdo \ --with-mysqli=mysqlnd \ --with-pdo-mysql=mysqlnd \ --with-zlib-dir \ --with-pdo-sqlite \ --with-readline \ --enable-session \ --enable-shmop \ --enable-simplexml \ --enable-sockets \ --enable-sysvmsg \ --enable-sysvsem \ --enable-sysvshm \ --enable-wddx \ --with-libxml-dir \ --with-xsl \ --enable-zip \ --enable-mysqlnd-compression-support \ --with-pear \ --enable-opcache
遇到的问题的解决
1. 关于re2c和bison的warning, 通过安装解决
yum install re2c yum install bison
2. 关于libzip的错误, 通过centos yum安装报版本太低, 需要编译安装
wget https://libzip.org/download/libzip-1.5.1.tar.gz tar zxvf libzip-1.5.1.tar.gz cd libzip-1.5.1 more INSTALL.md mkdir build cd build/ cmake .. make make test make install
3. 编译libzip时报centos7自带的cmake版本过低, 于是编译安装cmake
wget https://cmake.org/files/v3.12/cmake-3.12.2.tar.gz tar zxvf cmake-3.12.2.tar.gz cd cmake-3.12.2 ./bootstrap gmake gmake install whereis cmake cd /usr/bin/ ln -s /usr/local/bin/cmake cmake
4. 出现 configure: error: off_t undefined; check your library configuration 未定义的类型 off_t错误
off_t 类型是在头文件 unistd.h中定义的, 在32位系统 编程成 long int, 64位系统则编译成 long long int, 在进行编译的时候是默认查找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
.