Home > Backend Development > PHP7 > body text

How to install and uninstall php7

coldplay.xixi
Release: 2023-02-17 20:18:01
forward
2866 people have browsed it

How to install and uninstall php7

一、安装

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

apt-get install php7.0 libapache2-mod-php7.0
Copy after login

重启apache:

/etc/init.d/apache2 restart
Copy after login

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

推荐(免费):PHP7

内容如下:

<?php  
    phpinfo()?>
Copy after login
  • 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
Copy after login

二、卸载(第一种)

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

sudo apt-get autoremove php7.0
Copy after login

三,卸载(第二种)

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

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

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

add-apt-repository ppa:ondrej/php
Copy after login

接下来就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!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template