lnnujxxy的博客
lnnujxxy · 共 23 篇文章
lua 实现请求签名验证
签名类 --第三方类库 dofile("/usr/local/nginx/lua/resty/sha1.lua"); --调试日志 local function log(msg) local file = io.open('/tmp/test', 'a+') io.output(file) io.write('==========='..msg.."\n") io.close(file) end local Auth = {} Auth.__index = Auth function Auth:new() local self = {} setmetatable(self, Auth) re…
2014-11-21 16:57 · lua · 评论(0)
lua 字符串扩展处理类
类代码 local StringUtil = {} StringUtil.__index = StringUtil function StringUtil:new() local self = {} setmetatable(self, StringUtil) return self end function StringUtil:trim(s) return (string.gsub(s, "^%s*(.-)%s*$", "%1")) end function StringUtil:unescape(s) s = string.gsub(s, "+", " ") s = string.gs…
2014-11-19 17:30 · lua · 评论(0)
lua实现类和继承
通过一个例子说明 local Person = {name, age} Person.__index = Person function Person:talk(word) print(self.name.." say "..word) end function Person:setAge(age) self.age = age end function Person:getAge() return self.age end function Person:new(name, age) local p = {} setmetatable(p, Person) p.name = name p.…
2014-11-12 19:43 · lua · 评论(0)
redis主从原理及配置说明
redis同步原理 (1)Slave服务器连接到Master服务器 (2)Slave服务器发送SYCN命令 (3)Master服务器收到SYNC执行BGSAVE,并保存操作执行期间,新执行的写入命令都保存到一个缓存区 (4)Master服务器把BGSAVE执行完,将.rdb文件传输给Slave服务器. (5)Slave服务器接收到.rdb文件数据导入到内存中 (6)Master服务器以Redis命令协议格式,将写命令缓存中所有内容发给从服务器 (7)接下来就是增量同步 2.8之前不支持部分同步,2.8以后支持了(PSYNC命令) 主服务器配置 daemonize yes pidfile /v…
2014-11-05 18:23 · redis · 评论(0)
关于php curl支持并发请求,并毫秒控制超时
为什么这么做? 目前的接口话的服务调用,为了保证性能和稳定性,我们都会对调用的第三方接口做并发,超时控制。 代码实现(网上找的现成的) public static function curlMultiRequest($urls, $options = array()) { $ch= array(); $results = array(); $mh = curl_multi_init(); foreach($urls as $key => $val) { $ch[$key] = curl_init(); if ($options) { curl_setopt_array($ch[$key], …
2014-11-05 17:42 · PHP · 评论(0)
php-fpm nginx php 日志输出日志文件配置
php-fpm.conf yes php.ini error_log =/dir/you/want/to/use/for/logging.log nginx.conf The final "error" text at the end of the next line is crucial# You can also use any of the following in it's place:# "debug | info | notice | warn | error | crit | alert | emerg" error_log /dir/to/your/nginx/site.lo…
2014-09-16 14:37 · nginx · 评论(0)
nginx upload模块使用
安装 #wget -O nginx-upload-module.tar.gz https://github.com/vkholodkov/nginx-upload-module/archive/2.2.0.tar.gz #tar zxvf nginx-upload-module.tar.gz 重新编译nginx --add-module=指定模块目录 nginx配置 location /upload { upload_pass /test.php; upload_store /tmp/nginx_upload; upload_store_access user:rw; upload_set_…
2014-08-27 18:46 · nginx · 评论(0)
nginx 安装lua扩展
nginx的强大,lua的高性能,真是一个不错的组合,合到一起就无敌了,呵呵。 下面开始配置nginx,使其支持lua,是通过一个nginx模块实现的, 模块地址: https://github.com/chaoslawful/lua-nginx-module 下载链接: https://github.com/chaoslawful/lua-nginx-module/archive/v0.8.10.tar.gz 1、下载源码、解压缩 a、nginx源码: 1 2 [root@localhost ~]# wget http://nginx.org/download/nginx-1.4.2.ta…
2014-08-20 23:28 · lua · 评论(0)
源代码安装go
安装Mercurial 如何在Ubuntu上安装Mercurial? sudo apt-get install python2.5 sudo apt-get install python-all-dev sudo apt-get install python-setuptools sudo easy_install -U mercurial hg --version 安装GO hg clone -u release https://code.google.com/p/go ~/dist cd go/src ./all.bash 运行all.bash后,出现“ALL TESTS PASSED”…
2014-02-06 20:59 · go · 评论(0)
linux memcached 源码安装
memcached最新的安装使用记录一下 下载 #wget http://memcached.googlecode.com/files/memcached-1.4.15.tar.gz(memcached下载地址) #wget https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz(libevent下载地址) 安装 libevent #tar zxvf libevent-2.0.21-stable.tar.gz #cd libevent-2.0.21-stable #./configure --p…
2014-01-22 22:13 · memcached · 评论(0)
igbinary msgpack bson json php中使用
简介 igbinary, mspack, bson在数据格式话,类似json使用 安装igbinary #git clone https://github.com/igbinary/igbinary.git #/usr/local/php5.3/bin/phpize #./configure CFLAGS="-O2 -g" --enable-igbinary --with-php-config=/usr/local/php5.3/bin/php-config #make #make install 增加igbinary.so 到php.ini中 安装msgpack # /usr/local/…
2014-01-21 22:42 · PHP · 评论(0)
mcrypt 安装使用
用途: 用于加密,解密数据。 安装: 先安装libmcrypt库 #wget http://softlayer.dl.sourceforge.net/sourceforge/mcrypt/libmcrypt-2.5.8.tar.gz#tar -zxvf libmcrypt-2.5.8.tar.gz#cd 源代码/libmcrypt-2.5.8#./configure --prefix=/usr/local#make#make install 安装php扩展 cd php-5.x.x/ext/mcrypt# phpize# aclocal# ./configure# make && make …
2014-01-17 23:24 · PHP · 评论(0)
openssl 使用
用途: 保证传输安全,对数据进行加密和解密 安装: 官网: http://www.openssl.org 下载页面: http://www.openssl.org/source/ 选择最新版本下载 http://www.openssl.org/source/openssl-1.0.0a.tar.gz 解压: tar –zxvf openssl-1.0.0a.tar.gz,解压目录为:openssl-1.0.0a 然后进入到 cd openssl-1.0.0a,进行配置、编译、安装 配置 ./configure或./config 编译 make 安装 make install 可以用which…
2014-01-16 23:04 · PHP · 评论(0)
Linux 下 PHP 扩展 PDO 编译安装(转)
1、进入 PHP 的软件包 pdo 扩展目录中(注:不是 PHP 安装目录) [plain] view plain copy [root@gamejzy /]# cd /tmp/lamp/php-5.3.19/ext/pdo_mysql/ 注:我的 php 软件包在 /tmp/lamp/php-5.3.19 下 执行 phpize 命令 [plain] view plain copy [root@gamejzy pdo_mysql]# /usr/local/php/bin/phpize 注:/usr/local/php 是我的 php 安装目录 执行完 phpize 命令后,在 pdo_my…
2014-01-09 21:42 · mysql · 评论(0)
mysql 安装 (转)
1.安装make编译器(默认系统自带) 下载地址: http://www.gnu.org/software/make/ [c-sharp] view plain copy tar zxvf make-3.82.tar.gz cd make-3.82 ./configure make make install [c-sharp] view plain copy tar zxvf make-3.82.tar.gz cd make-3.82 ./configure make make install 2.安装bison(最好在编译LAMP前安装好所有基类软件) 下载地址: http://www.g…
2014-01-09 21:40 · mysql · 评论(0)