[记录] 解决安装PHP7.0出现 E: Unable to locate package php7.0-cgi 问题 作者: 4usy 时间: 2021-06-15 分类: 记录 解决安装PHP7.0出现 E: Unable to locate package php7.0-cgi 问题 有时候安装php7.0+依赖组件+sqlite3时会出现如下提示 ![](https://twovps.org/usr/uploads/2021/06/2146556828.png) ``` E: Unable to locate package php7.0-cgi E: Couldn't find any package by glob 'php7.0-cgi' E: Couldn't find any package by regex 'php7.0-cgi' E: Unable to locate package php7.0-fpm E: Couldn't find any package by glob 'php7.0-fpm' E: Couldn't find any package by regex 'php7.0-fpm' E: Package 'php7.0-curl' has no installation candidate E: Unable to locate package php7.0-gd E: Couldn't find any package by glob 'php7.0-gd' E: Couldn't find any package by regex 'php7.0-gd' E: Unable to locate package php7.0-mbstring E: Couldn't find any package by glob 'php7.0-mbstring' E: Couldn't find any package by regex 'php7.0-mbstring' E: Unable to locate package php7.0-xml E: Couldn't find any package by glob 'php7.0-xml' E: Couldn't find any package by regex 'php7.0-xml' E: Unable to locate package php7.0-sqlite3 E: Couldn't find any package by glob 'php7.0-sqlite3' E: Couldn't find any package by regex 'php7.0-sqlite3' ``` 个人感觉是部分源的问题,可以输入以下: ``` apt-get install apt-transport-https lsb-release ca-certificates ``` 然后获取gpg密钥: ``` wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg ``` 添加源: ``` echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list ``` 更新: ``` apt-get update ``` 安装php7.0+组件+sqlite3 ``` apt-get install php7.0-cgi php7.0-fpm php7.0-curl php7.0-gd php7.0-mbstring php7.0-xml php7.0-sqlite3 sqlite3 -y ``` 当然,如果只想装单纯一点,直接也可以: ``` apt install php7.0 ``` 最后输入php -v核对一下即可 ![](https://twovps.org/usr/uploads/2021/06/1075454085.png) ![](https://twovps.org/usr/uploads/2021/06/2635327315.png) 促销: 暂无提醒: 本博主因不使用Paypal付款被跑路累计26次,建议用Paypal上车