Home >Backend Development >PHP7 >How to install and uninstall php7

How to install and uninstall php7

coldplay.xixi
coldplay.xixiforward
2021-03-04 09:43:112900browse

How to install and uninstall php7

一、安装

一个命令搞定:安装php7和apache的php7模块:

apt-get install php7.0 libapache2-mod-php7.0

重启apache:

/etc/init.d/apache2 restart

在/var/www/html目录下新建文件info.php

推荐(免费):PHP7

内容如下:

<?php  
    phpinfo()?>
  • 1
  • 2
  • 3

访问:http://你的主机IP/info.phpHow to install and uninstall php7

看到这个表示php7安装ok。

查看php7相关组件:apt-cache search php7

How to install and uninstall php7

安装两个重要的组件,特别是php7.0-mysql,使php7获得mysql的支持

apt-get install php7.0-mysql php7.0-gd

二、卸载(第一种)

sudo apt-get - -purge remove libapache2-mod-php7.0 php7.0 php7.0-gd php7.0-mysql (安装了哪些组件就跟上名字,我这里只安装了这4个)

sudo apt-get autoremove php7.0

三,卸载(第二种)

sudo aptitude purge `dpkg -l | grep php| awk &#39;{print $2}&#39; |tr "\n" " "`
  • 1

查询,卸载已安装php,就卸载完了。 
(如果aptitude命令报错就安装aptiude:apt-get install aptitude)

如果想要安装其他php版本: 
添加支持源

add-apt-repository ppa:ondrej/php

接下来就apt-get安装就好了

The above is the detailed content of How to install and uninstall php7. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete