Get the App
SLTechnology News&Howtos  ›  Database  › 

NoSQL-php applications redis, mongodb

Shulou Source: shulou.com Published: 2022-06-01 22:21:30 11月16日 Update

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

Tags: Test thing architecture China plus output middle view success one line host parameter suggestion log server module virtual host error service check application Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS MySQL Shulou Information NVidia OPPO Reno