ubuntu 使用apt-get install 安装php5.6--php7

使用ppa增加源:
$ sudo apt-get install python-software-properties $ sudo add-apt-repository ppa:ondrej/php $ sudo apt-get update $ sudo apt-get install -y php7.0 php7.0-mysql php7.0-curl php7.0-json php7.0-cgi
然后可以查看php版本:
php -v
关于php5.4--php5.6版本
$ sudo apt-get install python-software-properties
$ sudo add-apt-repository ppa:ondrej/php
$ sudo apt-get update
$ sudo apt-get -y install php5.6 php5.6-mcrypt php5.6-mbstring php5.6-curl php5.6-cli php5.6-mysql php5.6-gd php5.6-intl php5.6-xsl php5.6-zip
查看php7的扩展
sudo apt-cache search php7-* 
或者可以源码安装
1.下载php7的源码包
2.tar -zxvf 解压
3.安装一些依赖
sudo apt-get install php5-mcrypt libmcrypt-dev
sudo apt-get install libxslt-dev libxml2-dev
4./configure --prefix=/zhou.data/php/php7 --enable-maintainer-zts -with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-mhash --with-openssl --with-zlib --with-bz2 --with-curl --with-zlib --enable-mbstring --with-mcrypt --enable-sockets --with-xsl --enable-zip --with-pear --enable-session --enable-xml --enable-shared --enable-bcmath --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-mbregex --enable-pcntl --with-xmlrpc
5.make && make install
6.如果报错,缺少哪些依赖,就一次安装即可