apache+php using memcached to store session information

Source: Internet
Author: User
Tags install php memcached

Demand:

Apache Use PHP Support memcached Storage Session Information

** following Apache , PHP , memcached are used Yum mode installation, if there is a special need to use the source package installation, the configuration method differs from this

turn off the firewall and SElinux Security Mechanisms

Service Iptables Stop

Setenforce 0

1. Install and deploy Apache

using the system's own Apache can be

Modify Apache configuration file to support PHP

Vim/etc/httpd/conf/httpd.conf

402 directoryindexindex.html Index.html.var index.php

Start Apache

Service httpd Start

2. install php

There are special needs available source package installation, in this experiment use Yum installation can

Yum-y Install PHP Php-devel

3. set up a test page to test the combination of Apache and php

vim/var/www/html/index.php

<?php

Phpinfo ();

?>

access using a browser http://192.168.1.11 , the following page appears

650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M02/9C/BF/wKiom1l1oQuDqoN4AAD5_z52JQM524.png "style=" float : none; "title=" 1.png "alt=" Wkiom1l1oqudqon4aad5_z52jqm524.png "/>

4. Install the deployment memcached

Use Yum Mode installation

Yum-y Install memcached

# execution after installation is complete : 
Memcached-h
# appear memcached help information stating that the installation was successful

Memcached configuration information for:

vim/etc/sysconfig/memcached
#The contents of the file are as follows, modified as needed: 
port= "11211" # Port 
user= "Root" # User name 
maxconn= "1024x768" # Maximum number of connections 
cachesize= "Up" # Memory Size 
options= "" # Additional Parameters

5. install php support memcached module

need to install libmemcached Client library, PHP the extension memcached module, because the extension is dependent on the libmemcached of the API

installation libmemcached Client Library

Tar XF libmemcached-1.0.18.tar.gz

CD libmemcached-1.0.18

./configure-prefix=/usr/local/libmemcached-with-memcached

Make &&make Install

installation PHP the extension memcached Module

Tar XF memcached-2.2.0.tgz

CD memcached-2.2.0

/usr/bin/phpize// First Use phpize command to generate a Configure file

./configure-enable-memcached-with-php-config=/usr/bin/php-config-with-zlib-dir-with-libmemcached-dir=/usr/ Local/libmemcached-prefix=/usr/local/phpmemcached--DISABLE-MEMCACHED-SASL

Make &&make Install

Note the prompt after successful installation, similar to the following:

Installing sharedextensions:/usr/lib64/php/modules/

Increase extension extension configuration file

Vim/etc/php.d/memcached.ini // This configuration file needs to be created manually

Extension=memcached.so

Execution php–m Command See if you have loaded the memcached Module

6. launch Apache and memcached

Service httpd Restart// Restart Apache Service

/usr/bin/memcached-u root-m 512m-n 10-f 2-d-vvv-c// Start memcached Service

You can install the Telnet service to test if the memcached service is normal

Yum–y Install Telnet

telnet localhost 11211

7. Create a test page to test if PHP supports memcached Reading session Information

vim/var/www/html/memcached.php

<?php

Session_Start ();

if (!isset ($_session[' test ')) {

$_session[' Test ']= time ();

}

print$_session[' Test '];

print "<br><br>";

Print "SessionID:". session_id ();

?>

access using a browser http://192.168.1.11/memcached.php , the following page appears;

650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M02/9C/BF/wKioL1l1oQzjDw-TAACbIxJwcoY723.png "title=" 2.png "Style=" Float:none; "alt=" Wkiol1l1oqzjdw-taacbixjwcoy723.png "/>

This article is from the "Lyndon" blog, make sure to keep this source http://lyndon.blog.51cto.com/11474010/1950475

apache+php using memcached to store session information

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.