Ubuntu 20.04
安装PHP软件依赖
sudo apt-get update sudo apt-get install libxml2-dev sudo apt-get install build-essential sudo apt-get install openssl sudo apt-get install libssl-dev sudo apt-get install curl sudo apt-get install libcurl4-gnutls-dev sudo apt-get install libjpeg-dev sudo apt-get install libpng-dev sudo apt-get install libmcrypt-dev sudo apt-get install libreadline6 libreadline6-dev sudo apt-get install libsqlite3-dev sudo apt-get install libzip-dev
wget https://www.php.net/distributions/php-7.4.8.tar.gz
tar -zxvf php-7.4.8.tar.gz
编译生成Makefile文件
./configure --prefix=/usr/local/php --enable-fpm --with-zip --with-mysqli --enable-gd \ --with-zlib --with-curl --enable-mbstring --enable-bcmath --disable-ctype --with-openssl \ --enable-tokenizer --enable-sockets
编译源码
make
安装php
sudo make install
cd ~
sudo vi .profile
添加内容
PATH=$PATH:$HOME/bin export PHTH alias php=/usr/local/php/bin/php
环境变量生效
source ~/.profile
php -v