Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

NoSQL-php applications redis, mongodb

2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Php-redis

Install the expansion module

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 / / add a line extension = redis.so

/ usr/local/php/bin/php-m | whether the grep redis check is successful

Session sharing of redis

Adding / / not recommended in php.ini

Session.save_handler = "redis"

Session.save_path = "tcp://127.0.0.1:6379"

Or apache virtual host is added / / used in LAMP architecture

Php_value session.save_handler "redis"

Php_value session.save_path "tcp://127.0.0.1:6379"

Or add / / to the pool corresponding to php-fpm.conf for LNMP architecture

Php_ value [session. Save _ handler] = redis

Php_ value [session.save _ path] = "tcp://127.0.0.1:6379" / / ip can be replaced with remote redis server ip

Session testing of redis

Vim / usr/local/apache/htdocs/session.php

Test curl localhost/session.php or web access

Output 1443710814

1443710814

9jm6nom9ogojedj3pth0iscv22

Connect redis

/ usr/local/redis/bin/redis-cli

127.0.0.1 6379 > keys * / / all key can be listed.

"PHPREDIS_SESSION:9jm6nom9ogojedj3pth0iscv22"

127.0.0.1 purl 6379 > get PHPREDIS_SESSION:9jm6nom9ogojedj3pth0iscv22

"TEST | iVera 1443710814 | iVera 1443710814 | iVera 1443710814 |

Error: if curl doesn't find anything, add-I and report 500and nothing in the log.

Solve # display_errors = Off to change to display_errors = On / / at this time curl will output an error and remember to change it back

Php-mongodb

Install the mongodb extension

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 / / add extension = mongo.so

/ usr/local/php/bin/php-m

Restart apache and reload php

Mongodb test extension

Vi / usr/local/apache2/htdocs/1.php / / added

Test curl localhost/1.php

-

Mongodb details: http://www.runoob.com/mongodb/mongodb-php.html

Redis details: http://www.runoob.com/redis/redis-tutorial.html

Redis parameter: http://beibing.blog.51cto.com/10693373/1875638

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report