wget http://cn2.php.net/distributions/php-7.3.3.tar.gz
tar -xzf php-7.3.3.tar.gz
cd php7.3.3
./configure --prefix=/usr/local/php7 --with-mysqli --with-pdo-mysql --with-zlib --enable-mbstring --with-openssl --enable-fpm --with-curl --enable-session
sudo make && sudo make install
sudo cp php.ini-development /usr/local/php7/lib/php.ini
vim /etc/profile
最后添加
export PATH=$PATH:/usr/local/php7/bin
加载配置
source /etc/profile
测试php命令
php -v
PHP 7.3.27 (cli) (built: Jul 27 2021 10:45:53) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.27, Copyright (c) 1998-2018 Zend Technologies
安装时提示
mkdir: cannot create directory '/usr/local/php7': Permission denied
mkdir: cannot create directory '/usr/local/php7/lib': No such file or directory
mkdir: cannot create directory '/usr/local/php7/lib/php': No such file or directory
mkdir: cannot create directory '/usr/local/php7/lib/php/extensions': No such file or directory
mkdir: cannot create directory '/usr/local/php7/lib/php/extensions/no-debug-non-zts-20180731': No such file or directory
make: *** [install-modules] Error 1
没有权限创建对应的目录导致的,执行时添加 sudo 即可
sudo make && sudo make install