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');






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