php+nginx+redis安装

环境: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扩展测试:

<?php
$redis = new Redis();
$redis->connect('127.0.0.1',6379);
$redis->set('name','kevin');
echo $redis->get('name');






發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章