debian安装php7

2020-05-01

添加软件源

编辑 /etc/apt/sources.list

后面添加以下代码

deb http://packages.dotdeb.org jessie all

deb-src http://packages.dotdeb.org jessie all

添加key

wget https://www.dotdeb.org/dotdeb.gpg

sudo apt-key add dotdeb.gpg

执行更新

sudo apt-get update

安装php7

apt-get install php7.0-cgi

apt-get install php7.0-fpm

apt-get install php7.0-curl

apt-get install php7.0-gd

apt-get install php7.0-mysql

apt-get install php7.0-mcrypt

apt-get install php7.0-dev

安装如果出错,按照提示带上参数即可。

如:apt-get install php7.0-mcrypt --fix-missing

编辑nginx配置文件,让nginx可以解析php

/etc/nginx/sites-available/default

修改以下代码

location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    # With php5-cgi alone:
    #fastcgi_pass 127.0.0.1:9000;
 	# With php5-fpm:
    fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
}

注意以上路径对应的文件是否存在。

重启nginx

/etc/init.d/nginx restart