php+nginx+redisインストール


環境かんきょう:centos centos centos
phpインストール
1必要なライブラリおよびツールのインストール:
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers gd gd2 gd-devel gd2-devel perl-CPAN pcre-devel

2 phpソースをダウンロードして解凍し、次の手順に従います.
cd php-5.5.10/
./configure --prefix=/usr/local/php --with-config-file-path=/etc/php --enable-fpm --enable-pcntl --enable-mysqlnd --enable-opcache --enable-sockets --enable-sysvmsg --enable-sysvsem  --enable-sysvshm --enable-shmop --enable-zip --enable-ftp --enable-soap --enable-xml --enable-mbstring --disable-rpath --disable-debug --disable-fileinfo --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-pcre-regex --with-iconv --with-zlib --with-mcrypt --with-gd --with-openssl --with-mhash --with-xmlrpc --with-curl --with-imap-ssl
sudo make
sudo make install
sudo cp php.ini-development /etc/php/

3 phpのコマンドパスを環境変数に追加します.
vim ~/.bashrc
export PATH=/usr/local/php/bin:$PATH
export PATH=/usr/local/php/sbin:$PATH
source ~/.bashrc

4 php--versionを使用するとphpのバージョン情報が表示されます.これでphpのインストールが完了します.
nginxインストール
参照先:http://www.nginx.cn/install

redisインストール
公式サイトにredisソースをダウンロードします
tar -zxvf redis-xxx.tar.gz
cd redis-xxx
make
make install
cp redis.conf /etc/redis/redis.conf

redisサーバを起動する:redis-server/etc/redis/redis.conf
redisコマンドラインクライアントにアクセスする:redis-cli
phpのredis拡張子のインストール
wget https://github.com/nicolasff/phpredis/archive/2.2.4.tar.gz
mv 2.2.4.tar.gz phpredis-2.2.4.tar.gz
tar -zxvf phpredis-2.2.4.tar.gz
cd phpredis-2.2.4
phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make
make install
phpプロファイルへの追加
extension=redis.so
php-m|grep redisコマンドを実行すると、redis拡張子がロードされていることがわかります.
redis拡張テスト:
connect('127.0.0.1',6379);
$redis->set('name','kevin');
echo $redis->get('name');