官网:https://www.php.net/downloads.php
创建文件目录:
mkdir /usr/local/php74
cd /usr/local/php74
下载--解压:
-
下载PHP安装包
wget https://www.php.net//distributions/php-7.4.3.tar.gz
-
解压安装包
tar -zxvf php-7.4.3.tar.gz
-
进入解压目录
cd php-7.4.3
./configure --prefix=/usr/local/php74 --with-config-file-path=/usr/local/php74/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --enable-mbstring --enable-mysqlnd
编译错误: 版本编译时与系统的兼容处理,以下是亲测中出现的问题
如果其它编译可查:https://www.24kplus.com/linux/400.html
报错1:configure: error:Package requirements (openssl >= 1.0.1) were not met
yum install openssl-devel
报错2
configure: error: in `/usr/local/php74/php-7.4.3':
configure: error: no acceptable C compiler found in $PATH
yum -y install gcc
报错3:configure: error: Package requirements (libxml-2.0 >= 2.7.6) were not met:No package 'libxml-2.0' found
yum install -y libxml2-devel
报错4:configure: error: Package requirements (sqlite3 > 3.7.4) were not met:No package 'sqlite3' found
yum install sqlite-devel
报错5:configure: error: Package requirements (oniguruma) were not met:No package 'oniguruma' found
yum install -y https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/o/oniguruma-5.9.5-3.el7.x86_64.rpm
yum install -y https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/o/oniguruma-devel-5.9.5-3.el7.x86_64.rpm
make && make install
为可执行php文件,建立软链接
cd /usr/local/sbin
ln -s /usr/local/php74/bin/php php74
[root@localhost php-7.4.3]# php74 -v
PHP 7.4.3 (cli) (built: Mar 10 2020 11:48:09) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
从解压的安装包的php.ini-production修改成php.ini,移动到/usr/local/php74/etc
[root@localhost php-7.4.3]# mv php.ini-production php.ini
[root@localhost php-7.4.3]# mv php.ini /usr/local/php74/etc