Ubuntu版本:20.04.1 LTS
PHP版本:8.2.4
下載地址: https://www.php.net/downloads
官方文檔:https://www.php.net/manual/en/install.unix.nginx.php
上傳目錄:/usr/local/src
安裝目錄:/usr/local/php
源碼安裝
# 進入源碼包目錄 cd /usr/local/src/ # 解壓 tar zxf php-x.x.x.tar.gz cd php-x.x.x # 配置,開啟所需擴展 ./configure --prefix=/usr/local/php --enable-fpm --enable-gd --enable-pcntl --enable-mbstring --with-openssl --with-mysqli --with-pdo-mysql --with-curl --with-zlib --with-zip # 安裝 make make install # 添加環境變量 echo "export PATH=$PATH:/usr/local/php/bin" >> /etc/profile source /etc/profile
搭配Nginx
參考 Centos 安裝PHP
問題集錦
The pkg-config script could not be found or is too old
apt install -y pkg-config
No package 'libxml-2.0' found
apt install -y libxml2-dev
No package 'sqlite3' found
apt install -y libsqlite3-dev
No package 'libcurl' found
apt install -y libcurl4-openssl-dev
No package 'libpng' found
apt install -y libpng-dev
No package 'oniguruma' found
apt install -y libonig-dev
No package 'libzip' found
apt install -y libzip-dev