PHP7栏目介绍ubuntu如何安装php7+nginx+mysql环境
推荐(免费):PHP7
1、首先添加nginx_signing.key:
wget http://nginx.org/keys/nginx_signing.key sudo apt-key add nginx_signing.key
2、安装nginx:
sudo apt-get update sudo apt-get install nginx
3、安装mysql:
sudo apt-get install mysql-server-5.6 mysql-client-5.6
4、添加PPA:
sudo apt-get install python-software-properties software-properties-common sudo add-apt-repository ppa:ondrej/php sudo apt-get update
5、安装php7和php7的扩展
sudo apt-get install php7.0-fpm php7.0-mysql php7.0-common php7.0-curl php7.0-cli php7.0-mcrypt php7.0-mbstring php7.0-dom php7.0-gd php7.0-intl php-pear php-imagick php7.0-imap php-memcache php7.0-pspell php7.0-recode php7.0-sqlite3 php7.0-tidy php7.0-xmlrpc php7.0-xsl php-gettext
6.安装php7redis扩展:
cd /etc wget https://github.com/phpredis/phpredis/archive/php7.zip -O phpredis.zip unzip -o /etc/phpredis.zip && mv /etc/phpredis-* /etc/phpredis && cd /etc/phpredis && phpize ./configure && make && sudo make install
上面好像被官方删掉了,如果不行还有一种方法
cd /etc sudo git clone https://github.com/nicolasff/phpredis cd phpredis sudo git checkout php7 sudo /usr/local/php7/bin/phpize ./configure --with-php-config=/usr/local/php7/bin/php-config make && make install
如果上面成功的话在/etc/php/7.0/mods-available/redis.ini里输入extension=redis.so
将phpredis扩展连接到php7
sudo ln -s /etc/php/7.0/mods-available/redis.ini /etc/php/7.0/fpm/conf.d/redis.ini sudo ln -s /etc/php/7.0/mods-available/redis.ini /etc/php/7.0/cli/conf.d/redis.ini
如果是apache要在/etc/php/7.0/apache2/php.ini最后添加extension=/tmp/phpredis/modules/redis.so
重启php和nginx
sudo service php7.0-fpm restart sudo service nginx restart