在docker中安装nginx、php、redis

docker run -ti -h nginx --name nginx_20080 -p 20080:80 ubuntu:14.04
apt-get update
apt-get install nginx
nginx -v 安装的1.4.6版本
cd /usr/share/nginx/html
mv index.html index.html.bak
vi index.html
nginx启动显示hello
apt-get install php5-fpm
cd /etc/nginx
cp sites-available/default default.bak
修改配置文件让php生效
vi sites-available/default
nginx -s reload
service php5-fpm restart
ln -s /usr/share/nginx/html /root/www
vi ip.php

<?php
$ip=$_SERVER["REMOTE_ADDR"];
echo $ip;
echo phpinfo();
?>

可以看到ip说明php配置好啦

找到最新版3.1.6的驱动
https://github.com/phpredis/phpredis/releases
apt-get install wget
wget https://github.com/phpredis/phpredis/archive/3.1.6.tar.gz
tar xzf 3.1.6.tar.gz
cd phpredis-3.1.6
apt-get install php5-dev
phpize
./configure
vi /etc/php5/fpm/php.ini
extension=redis.so 加在php下就可以
service php5-fpm restart

<?php
   $redis = new Redis();
   $redis->connect('192.168.1.220', 26379);
   echo "Connection to server sucessfully";
   echo "Server is running: " . $redis->ping();
?>

继续重入docker attach nginx_20080

参考:http://www.runoob.com/redis/redis-php.html

标签: none

添加新评论