您好,登錄后才能下訂單哦!
php - redis
安裝擴展模塊
wget https://codeload.github.com/phpredis/phpredis/zip/develop
mv develop phpredis.zip
unzip phpredis.zip
cd phpredis-develop
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
vim /usr/local/php/php.ini // 增加一行extension = redis.so
/usr/local/php/bin/php -m |grep redis 檢查是否成功
redis的session共享
php.ini中加入 //不建議
session.save_handler = "redis"
session.save_path = "tcp://127.0.0.1:6379"
或者apache虛擬主機加入 //用于LAMP架構中
php_value session.save_handler " redis"
php_value session.save_path " tcp://127.0.0.1:6379"
或者php-fpm.conf對應的pool中加入 //用于LNMP架構
php_value[session.save_handler] = redis
php_value[session.save_path] = " tcp://127.0.0.1:6379 " //ip可換成遠端redis服務器ip
redis的session測試
vim /usr/local/apache/htdocs/session.php
<?php session_start(); if (!isset($_SESSION['TEST'])) { $_SESSION['TEST'] = time(); } $_SESSION['TEST3'] = time(); print $_SESSION['TEST']; print "<br><br>"; print $_SESSION['TEST3']; print "<br><br>"; print session_id(); ?>
測試curl localhost/session.php 或 web訪問
輸出1443710814<br><br>1443710814<br><br>9jm6nom9ogojedj3pth0iscv22
連接redis
/usr/local/redis/bin/redis-cli
127.0.0.1:6379> keys * //可以把所有的key都列出來
"PHPREDIS_SESSION:9jm6nom9ogojedj3pth0iscv22"
127.0.0.1:6379> get PHPREDIS_SESSION:9jm6nom9ogojedj3pth0iscv22
"TEST|i:1443710814;TEST3|i:1443710814;"
error:如果 curl 不出東西加 -I 后報500而且日志中看不出東西
解決# display_errors = Off 改為 display_errors = On //此時 curl 會輸出錯誤之后記得改回去
php - mongodb
安裝mongodb擴展
wget 'https://codeload.github.com/mongodb/mongo-php-driver/zip/master' -O /usr/local/src/mong_php.zip
cd /usr/local/src/
unzip mong_php.zip
cd mongo-php-driver-master/
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install
vi /usr/local/php/etc/php.ini //增加 extension = mongo.so
/usr/local/php/bin/php –m
重啟apache重新加載php
mongodb 測試擴展
vi /usr/local/apache2/htdocs/1.php //增加
<?php // 連接到mongodb $m = new MongoClient(); echo "Connection to database successfully"; // 選擇一個數據庫 $db = $m->mydb; echo "Database mydb selected"; ?>
測試curl localhost/1.php
----------------------------------------------------------------------------------------------
mongodb詳解:http://www.runoob.com/mongodb/mongodb-php.html
redis詳解:http://www.runoob.com/redis/redis-tutorial.html
redis參數:http://beibing.blog.51cto.com/10693373/1875638
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。