php7的lnmp需要的步骤
1.安装Ubuntu14
更新源
sudo apt-get update
2.安装nginx
sudo apt-get install nginx
配置
server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; root /www; index index.php index.html index.htm; server_name 192.168.5.243; location / { try_files $uri $uri/ /index.php?$query_string; } location ~ \.php$ { try_files $uri /index.php =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }
重启nignx,让配置生效
sudo service nginx restart
4.安装php7
添加PPA,Personal Package Archives,也就是个人软件包集
sudo apt-get install python-software-properties software-properties-common sudo add-apt-repository ppa:ondrej/php sudo apt-get update
安装php7及扩展
sudo apt-get install php7.0-fpm php7.0-cli php7.0-mcrypt php7.0-mysql php7.0-mbstring php7.0-xml
配置
php.ini(/etc/php/7.0/fpm/php.ini)
去掉cgi.fix_pathinfo前的分号
启用php7.0-mcrypt
sudo phpenmod mcrypt
重启php7.0-fpm
sudo service php7.0-fpm restart
5.安装mysql
sudo apt-get install mysql-server-5.6 mysql-client-5.6
6.安装Composer
sudo apt-get install curl cd ~ curl -sS https://getcomposer.org/installer| php sudo mv composer.phar /usr/local/bin/composer
7.安装压缩、解压缩程序
sudo apt-get install zip unzip
8.安装git
sudo apt-get install git
在/www下新建test.php
用phpinfo()输出相关配置信息
9.其他扩展
(1)安装gd
apt-get install php7.0-gd
(2)curl
apt-get install php7.0-curl
(3)redis
如果php7是用下面命令安装的
apt-get install php7.0
系统中找不到phpize
apt-get install php7.0-dev
可以找到phpize了
git clone redis扩展
git clone https://github.com/phpredis/phpredis.git
切换分支
git checkout -b php7 origin/php7
建立编译连接
./configure --with-php-config=/usr/bin/php-config
make
make test
安装
make install
安装到了/usr/lib/php/20151012目录下
查看以前的扩展配置都在
/etc/php/7.0/mods-available下
新建redis.ini
extension=redis.so
重启php、nginx
service php7.0-fpm restart service nginx restart
查看phpinfo()没有找到redis
原来在/etc/php/7.0/fpm/conf.d下面有软链接
ln -s /etc/php/7.0/mods-available/redis.ini
重启php,nginx
测试代码
$redis = new Redis(); $redis->connect('127.0.0.1',6379); $redis->auth('123456'); $tmp = $redis->get('key1'); var_dump($tmp);