linux下安裝redis擴展

首先  下載redisphp

linux:linux

http://download.redis.io/releases/redis-3.0.5.tar.gznginx

windows:
git

https://github.com/dmajkic/redis/downloadsgithub


windos下 redis

 安裝好redis後直接啓動數據庫

啓動後注意歡迎界面不要關閉。這就是redis開啓狀態apache

其後打開redis-clivim

redis默認端口爲6379 windows

測試命令

set test success

get test

若是get test 獲取到值 那麼redis安裝成功

redis 啓動方式:cmd 進入redis 安裝目錄  redis-server.exe redis.windows.conf


php redis 擴展

http://windows.php.net/downloads/pecl/snaps/redis/2.2.5

下載對應版本後把擴展丟進php/ext中 還要下載對應的依賴,而後在重啓apache/nginx 

echo phpinfo();

搜索redis 會看到redis擴展已經安裝成功。

假如沒有搜索到redis 則對應的擴展版本不對,繼續更換不一樣版本.dll(注意:php 有分nts 和 ts )


linux下則

        tar xvzf redis-stable.tar.gz  

        cd redis-stable  

        make  

        make install  

  1. make命令執行完成後,會在src目錄下生成5個可執行文件,分別是redis-server、redis-cli、redis-benchmark、redis-check-aof、redis-check-dump,它們的做用以下:  

  2. redis-server:Redis服務器的daemon啓動程序  

  3. redis-cli:Redis命令行操做工具。固然,你也能夠用telnet根據其純文本協議來操做  

  4. redis-benchmark:Redis性能測試工具,測試Redis在你的系統及你的配置下的讀寫性能  

  5. redis-check-aof:更新日誌檢查  

  6.   

  7. redis-check-dump:用於本地數據庫檢查  

  8.   

  9.   

  10. 步驟3、配置  

  11.     cp redis-server /usr/local/bin/  

  12.     cp redis-cli /usr/local/bin/  

  13.     而後新建目錄,存放配置文件  

  14.     mkdir /etc/redis  

  15.     mkdir /var/redis  

  16.     mkdir /var/redis/log  

  17.     mkdir /var/redis/run  

  18.     mkdir /var/redis/redis

  19.   

  20.     在redis解壓根目錄中找到配置文件模板,複製到以下位置。  

  21.     cp redis.conf /etc/redis/redis.conf經過vim命令修改  

  22.     daemonize yes //守護進程的開啓 

  23.     pidfile /var/redis/run/redis_6379.pid  

  24.     logfile /var/redis/log/redis_6379.log  

  25.     dir /var/redis/redis

  26.     最後運行redis:  

  27.     $ redis-server /etc/redis/redis.conf  

  28.   

  29.     可用netstat –atln 查看端口是啓動安裝成功  也能夠直接 ps aux | grep redis

  30.     打開redis-cli

  31.     測試命令與windows同樣

                配置php redis 擴展

    若是是編譯安裝的php 在php目錄下找到phpize的(若是沒有找到 則執行 yum isntall -y php-devel)

               把下載好的 php redis 擴展 解壓到 /ext/phpredis/ 中(裏面可看到其餘php的擴展 pdo等等)注意 須要在ext目錄下

         執行

      # /usr/local/php/bin/phpize  (phpize路徑)

      # ./configure --with-php-config=/usr/local/php/bin/php-config   (php-config路徑)

      # make && make install  

     而後配置hp.ini  

     vi /usr/local/php/lib/php.ini  

     extension=redis.so  

       去到php的擴展庫 /php/modules/中查找是否存在redis.so

重啓apache 

    echo phpinfo();

    查找redis擴展是否安裝成功,後續步驟與windows同樣 這裏再也不重複。

相關文章
相關標籤/搜索