Using Redis storage session

Source: Internet
Author: User

1. Install Httpd,epel,redis, PHP's Redis extension

Yum install-y epel* (install Epel extension Yum source first)

Yum install-y httpd Redis Php*redis (after installing the Epel, and then installing Redis, the Redis extension with PHP)


2. Start Httpd,redis

Service httpd Restart

Service Redis Restart



3, vim/var/www/html/01.php

<?php

Phpinfo ();

?>


4. Browser Open http://192.168.20.95/01.php

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/5D/F1/wKiom1UnkzWSCT-eAAFaF7ujHD4536.jpg "title=" Qq20150410170901.png "alt=" Wkiom1unkzwsct-eaafaf7ujhd4536.jpg "/>

Indicates that a PHP extension is installed


5, vim/var/www/html/02.php

<?php

Ini_set (' Session.gc_maxlifetime ', 3600);

Ini_set ("Session.save_handler", "Redis");

Ini_set ("Session.save_path", "tcp://127.0.0.1:6379");

Session_Start ();

$_session[' name '] = "Liu de hua";

echo $_session[' name ']. " <br/> ";

Echo session_id (). ' <br/> ';

?>


Browser opens http://192.168.20.95/02.php

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/5D/F1/wKiom1UnlOGwF_W_AACvxJljw3g133.jpg "title=" Qq20150410171622.png "alt=" Wkiom1unlogwf_w_aacvxjljw3g133.jpg "/>



6. We enter Redis to view information

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/5D/EC/wKioL1UnlmWimQeFAAGO6Rvosx0826.jpg "title=" Qq20150410171718.png "alt=" Wkiol1unlmwimqefaago6rvosx0826.jpg "/>


We found this information in Redis and said it was successful.




7, we can also modify the following parameters in/etc/php.ini

Session.gc_maxlifetime

Session.save_handler

Session.save_path


This article is from the "Lao Cai" blog, please be sure to keep this source http://877763363.blog.51cto.com/1200927/1631009

Using Redis storage session

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.