1 . 先安装如下依赖包
yum install -y gcc gcc-c++ make zlib zlib-devel pcre pcre-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers
2 . 下载php压缩包
wget http://cn2.php.net/distributions/php-7.4.4.tar.gz
3 . 解压
tar -zxvf php-7.4.4.tar.gz
4 . 进入解压后的目录并配置
cd php-7.4.4
./configure --prefix=/usr/local/lnmp/php74 --with-config-file-path=/usr/local/lnmp/php74 --enable-mbstring --with-openssl --enable-ftp --with-gd --with-jpeg-dir=/usr --with-png-dir=/usr --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-pear --enable-sockets --with-freetype-dir=/usr --with-zlib --with-libxml-dir=/usr --with-xmlrpc --enable-zip --enable-fpm --enable-xml --enable-sockets --with-gd --with-zlib --with-iconv --enable-zip --with-freetype-dir=/usr/lib/ --enable-soap --enable-pcntl --enable-cli --with-curl
注意:
--prefix=安装目录
--with-使用包名称[=包目录]
--enable-需要激活的功能
5 . 编译过程中遇到问题
linux 安装 php No package 'sqlite3' found
yum install sqlite-devel
linux 安装 php No package 'oniguruma' found [ php7.4 ]
yum install oniguruma oniguruma-devel
6 . 编译安装
make && make install
相关命令
启动php-fpm服务
/usr/local/php5/sbin/php-fpm
重启
service php-fpm restart