1、下载PHP源码包
wget https://www.php.net/distributions/php-7.4.30.tar.gz
2、解压缩
3、预编译、检查环境
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysqli --with-pdo-mysql --with-mysql-sock=/usr/local/mysql/mysql.sock --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-curl --with-gd --with-gmp --with-zlib --with-xmlrpc --with-openssl --without-pear --with-snmp --with-gettext --with-mhash --with-libxml-dir=/usr --with-ldap --with-ldap-sasl --with-fpm-user=nginx --with-fpm-group=nginx --enable-xml --enable-fpm --enable-ftp --enable-bcmath --enable-soap --enable-shmop --enable-sysvsem --enable-sockets --enable-inline-optimization --enable-maintainer-zts --enable-mbregex --enable-mbstring --enable-pcntl --enable-zip --disable-fileinfo --disable-rpath --enable-libxml --enable-opcache --enable-mysqlnd
出现的错误
configure: error: Package requirements (libxml-2.0 >= 2.7.6) were not met:
configure: error: Package requirements (openssl >= 1.0.1) were not met:
configure: error: Package requirements (sqlite3 > 3.7.4) were not met:
configure: error: Package requirements (libcurl >= 7.15.5) were not met:
configure: error: GNU MP Library version 4.2 or greater required.
configure: error: Cannot find ldap.h
configure: error: Cannot find ldap libraries in /usr/lib.
configure: error: Package requirements (oniguruma) were not met:
configure: error: Could not find net-snmp-config binary. Please check your net-snmp installation.
4、编译并安装
出现的错误
cc: fatal error: Killed signal terminated program cc1 compilation terminated.
/usr/bin/ld: ext/ldap/.libs/ldap.o: undefined reference to symbol 'ber_strdup' //usr/lib64/liblber-2.4.so.2: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status make: *** [Makefile:287: sapi/cli/php] Error 1