在 ubuntu 18.04 中卸载 php 7 [英] Uninstall php 7 in ubuntu 18.04
问题描述
我有一个服务器,它有一个运行 PHP 5.6 的应用程序.但是我将服务器从 Ubuntu 14.04 升级到 18.04,在此过程中我也将 PHP 升级到了 7.2.现在我正在尝试卸载它,但发现很困难.
I have a server that has an application that runs with PHP 5.6. But I upgraded the server from Ubuntu 14.04 to 18.04 and in the process I also upgraded PHP to 7.2. Now I'm trying to uninstall it but I'm finding difficult.
我已经运行了命令:
sudo apt-get 删除 php
和
sudo apt-get remove --purge php
它说 PHP 没有安装,但正在运行php --version
我还在看 PHP 的第 7 版.
Its says that PHP it's not installed, but running
php --version
I'm still seeing the version 7 of PHP.
PHP 7.2.19-0ubuntu0.18.04.2 (cli)(构建时间:2019 年 8 月 12 日 19:34:28)(NTS)版权所有 (c) 1997-2018 PHP GroupZend Engine v3.2.0,版权所有 (c) 1998-2018 Zend Technologies使用 Zend OPcache v7.2.19-0ubuntu0.18.04.2,版权所有 (c) 1999-2018,由 Zend Technologies 提供
PHP 7.2.19-0ubuntu0.18.04.2 (cli) (built: Aug 12 2019 19:34:28) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.2.19-0ubuntu0.18.04.2, Copyright (c) 1999-2018, by Zend Technologies
推荐答案
这将删除所有 php7 版本,无论是 php 7.0 还是 php 7.1 等.
This will remove all php7 versions, be it php 7.0 or php 7.1 etc..
sudo apt-get purge php7.*
sudo apt-get autoclean
sudo apt-get autoremove
apt/apt-get autoclean
→ 清理过时的 deb 包,小于clean
apt/apt-get autoremove
→ 从系统中删除不再需要的孤立包,但不会清除它们,使用--purge
选项和命令.apt/apt-get autoclean
→ cleans obsolete deb-packages, less thanclean
apt/apt-get autoremove
→ removes orphaned packages which are not longer needed from the system, but not purges them, use the--purge
option together with the command for that.
**重新安装 PHP **
**To Install PHP again **
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
如果php7.0
sudo apt-get install php7.0
如果php7.1
sudo apt-get install php7.1
如果php7.2
sudo apt-get install php7.2
要将其切换到较新的 7.1、7.2、7.3、7.4 版本,请先禁用较旧的 PHP 版本:
To switch that to the newer 7.1,7.2,7.3,7.4 version, first disable older PHP version:
user@test:~# sudo a2dismod php7.0
然后启用 PHP 7.2:
user@test:~# sudo a2enmod php7.2
sudo service apache2 restart
安装所有需要的扩展,这样以后就不会出错了
Install all the required extension, so it won't make any error in future
sudo apt install php7.2-common php7.2-mysql php7.2-xml php7.2-xmlrpc php7.2-curl php7.2-gd php7.2-imagick php7.2-cli php7.2-dev php7.2-imap php7.2-mbstring php7.2-opcache php7.2-soap php7.2-zip php7.2-intl -y
这篇关于在 ubuntu 18.04 中卸载 php 7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!