Ubuntu 安装 PHP

Ubuntu版本:20.04.1 LTS

PHP版本:8.3.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 --with-freetype

# 安装
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

No package 'freetype2' found

apt install -y libfreetype6-dev

posted @ 2022-02-24 10:34  绿静風  阅读(1101)  评论(0编辑  收藏  举报