Nginx使用Memcached
来源:互联网 发布:精锐摇杆淘宝店 编辑:程序博客网 时间:2024/06/01 09:24
Nginx使用Memcached 第一步:Nginx服务器必须要安装吧 php也要安装吧 mysql无所谓 php操作memcached扩展也要安装上吧 如有不懂 请参看下面的文章 安装Nginx+PHP http://blog.csdn.net/qq_36030288/article/details/53858357 安装Memached http://blog.csdn.net/qq_36030288/article/details/52613847 安装PHP操作memcached的扩展 http://blog.csdn.net/qq_36030288/article/details/52614703 第二步:修改Nginx的配置文件(我是安装上面的环境修改的) 启动你的memcached服务 /usr/local/memcached/bin/memcached -m 64 -p 11211 -u nobody -vv -d 启动你的php /usr/local/src/php/sbin/php-fpm vim usr/local/src/nginx/conf/nginc.conf 在server中加上一段代码 如果不懂请看 location定位的用法(http://blog.csdn.net/qq_36030288/article/details/54576449) location / { set $memcached_key $uri; memcached_pass memcacheserver; error_page 404 /callback.php; } 在你的nginx中html目录创建一个callback.php 这个页面的内容自己模拟一下 如: //获取uri $uri = $_SERVER['REQUEST_URI']; //new一个memcache对象出来 $memcache = new Memcache; $memcache->addServer('127.0.0.1', 11211); $num = rand(1,999).$uri.'not use databases'; $memcache->add($uri,$num ); echo 'This is a',$uri,'sb memcache';
配置文件所有内容如下:
#user nobody;worker_processes 2;#error_log logs/error.log;#error_log logs/error.log notice;#error_log logs/error.log info;#pid logs/nginx.pid;events { worker_connections 1024;}http { include mime.types; default_type application/octet-stream; #日志的格式 log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #显示目录 autoindex on; autoindex_exact_size on; autoindex_localtime on; server { listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; # location / { # root html; # index index.html index.htm; # } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } #简单配置一下nginx使用memcache后面有第三方模块解决算法的问题 location / {set $memcached_key "$uri";root html;memcached_pass 127.0.0.1:11211;error_page 404 /callback.php;} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #这里是配置nginx把请求交给php进程进行处理返回 location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }}
0 0
- Nginx 中使用 Memcached
- Nginx使用Memcached
- Nginx使用memcached集群
- nginx安装和使用 memcached session 共享
- 使用nginx, memcached, libevent, mysql实现url排重
- Nginx+Memcached+mysql+php
- memcached&nginx安装
- nginx+memcached+tomact 集群
- nginx+tomcat+memcached 搭建
- nginx+tomcat+memcached
- Nginx + Memcached + Tomcat 集群
- Nginx + Memcached + Tomcat 集群
- nginx memcached模块解析
- Nginx+Tomcat+Memcached集群
- Lua+Nginx+Memcached整合
- Nginx+Tomcat+Memcached集群
- Nginx+Tomcat+Memcached集群
- Nginx+Tomcat+Memcached集群
- 站在巨人的肩膀上,C++开源库大全
- Bluebird 高性能揭秘
- java实现Json格式美化
- Processing中shapes3d库的utils包中的Bezier2与Shape3D包中的BezShape类
- 动态规划算法的个人理解
- Nginx使用Memcached
- 银行账号同步多线程处理
- list列表去除重复项以及查询某个字符串在list的出现次数
- IO 端口和IO 内存
- 高一寒假竞赛知识点梳理1
- iOS开发之支付宝集成问题 'openssl/asn1.h' file not found
- Java高并发编程:使用JDK5中同步技术的3个面试题
- 模拟php curl向远程服务器上传文件
- SMP、NUMA、MPP体系结构介绍