Home > Backend Development > PHP7 > php7 Linux installation and uninstallation tutorial (detailed explanation)

php7 Linux installation and uninstallation tutorial (detailed explanation)

烟雨青岚
Release: 2023-02-17 15:44:02
forward
3825 people have browsed it

php7 Linux installation and uninstallation tutorial (detailed explanation)

php7 Linux安装卸载教程(详解)

一、安装

我第一次安装php的时候没有安装apache的php模块,结果apache不能解析php文件,访问文件显示的是源码。

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

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

重启apache:

/etc/init.d/apache2 restart

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

内容如下:

<?php  
    phpinfo()
?>
Copy after login

访问:http://你的主机IP/info.php

php7 Linux installation and uninstallation tutorial (detailed explanation)

看到这个表示php7安装ok。

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

php7 Linux installation and uninstallation tutorial (detailed explanation)

安装两个重要的组件,特别是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
Copy after login

三,卸载(第二种)

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

查询,卸载已安装php,就卸载完了。

(如果aptitude命令报错就安装aptiude:apt-get install aptitude)

如果想要安装其他php版本:

添加支持源

add-apt-repository ppa:ondrej/php

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

四、php打开session支持

在php.ini里找到session.auto_start = 0(我新安装的php5默认值就是0),把0改为1就可以了。

感谢大家的阅读,希望大家有所收益。

原文链接:https://blog.csdn.net/Axela30W/article/details/78825630

推荐教程:《PHP教程

The above is the detailed content of php7 Linux installation and uninstallation tutorial (detailed explanation). 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