仓酷云
标题:
PHP编程:纪录php5.4与php-redis抵触的办理
[打印本页]
作者:
冷月葬花魂
时间:
2015-1-16 22:13
标题:
PHP编程:纪录php5.4与php-redis抵触的办理
我的这套线路可能跟许多学习PHP的爱好者不谋而合,这也算是一个循序渐进的学习过程,不过新手不要看到上面的概括就以为学习蛮简单的,默默在此不得不对您稍微泼一下冷水,任何工具其实都不简单。比来因为update了ubuntu的源,招致本来新源与当地体系库一些lib抵触,招致体系桌面显现非常,厥后只要重装,新安装了php5.4.9,还安装了redis,php-redis扩大,php-redis扩大2,10。但把本来的项目一放上往,就报nginx502毛病(nginx502毛病真是个很头疼的成绩)。翻开nginx日记检察[error]29229#0:*1403recv()failed(104:Connectionresetbypeer)whilereadingresponseheaderfromupstream,client:127.0.0.1,server:不晓得所云。厥后翻开php-fpm毛病日记,失掉的log日记[08-Oct-201321:22:23]WARNING:[poolwww]child12026exitedonsignal11(SIGSEGV-coredumped)after5.997917secondsfromstart[08-Oct-201321:22:23]NOTICE:[poolwww]child12034started能够断定的一点,是php-fpm在一个工夫点后重启了一个历程。仍是毫无眉目。在网上搜了一年夜遍,有个有效的跟踪办法。1、设置php-fpm,只起一个work历程2、重启php-fpm,实行psauxgrepphp-fpm失掉work历程号pid3、strace-ppid上面是我失掉的信息getcwd("/home/www/wms2.xxxx.com",4096)=26lstat("/home/www/wms2.xiaomi.com/./RWebUser.php",0x7ffff4e30a10)=-1ENOENT(Nosuchfileordirectory)lstat("/home/www/wms2.xiaomi.com/protected/vendor/wms/api/RWebUser.php",0x7ffff4e30a10)=-1ENOENT(Nosuchfileordirectory)lstat("/home/www/wms2.xiaomi.com/protected/vendor/wms/RWebUser.php",0x7ffff4e30a10)=-1ENOENT(Nosuchfileordirectory)lstat("/home/www/wms2.xiaomi.com/protected/extensions/log/RWebUser.php",0x7ffff4e30a10)=-1ENOENT(Nosuchfileordirectory)lstat("/home/www/wms2.xiaomi.com/protected/modules/rights/components/RWebUser.php",{st_mode=S_IFREG0777,st_size=2945,...})=0lstat("/home/www/wms2.xiaomi.com/protected/modules/rights/components",{st_mode=S_IFDIR0777,st_size=4096,...})=0lstat("/home/www/wms2.xiaomi.com/protected/modules/rights",{st_mode=S_IFDIR0777,st_size=4096,...})=0lstat("/home/www/wms2.xiaomi.com/protected/modules",{st_mode=S_IFDIR0777,st_size=4096,...})=0open("/home/www/wms2.xiaomi.com/protected/modules/rights/components/RWebUser.php",O_RDONLY)=5fstat(5,{st_mode=S_IFREG0777,st_size=2945,...})=0fstat(5,{st_mode=S_IFREG0777,st_size=2945,...})=0fstat(5,{st_mode=S_IFREG0777,st_size=2945,...})=0fstat(5,{st_mode=S_IFREG0777,st_size=2945,...})=0mmap(NULL,2945,PROT_READ,MAP_SHARED,5,0)=0x7fd9b4804000mmap(NULL,266240,PROT_READPROT_WRITE,MAP_PRIVATEMAP_ANONYMOUS,-1,0)=0x7fd9b442f000munmap(0x7fd9b4804000,2945)=0close(5)=0getcwd("/home/www/wms2.xxx.com",4096)=26lstat("/home/www/wms2.xxx.com/./XMCCacheHttpSession.php",0x7ffff4e31060)=-1ENOENT(Nosuchfileordirectory)lstat("/home/www/wms2.xxx.com/protected/vendor/wms/api/XMCCacheHttpSession.php",0x7ffff4e31060)=-1ENOENT(Nosuchfileordirectory)lstat("/home/www/wms2.xxx.com/protected/vendor/wms/XMCCacheHttpSession.php",0x7ffff4e31060)=-1ENOENT(Nosuchfileordirectory)lstat("/home/www/wms2.xxx.com/protected/extensions/log/XMCCacheHttpSession.php",0x7ffff4e31060)=-1ENOENT(Nosuchfileordirectory)lstat("/home/www/wms2.xxx.com/protected/modules/rights/components/XMCCacheHttpSession.php",0x7ffff4e31060)=-1ENOENT(Nosuchfileordirectory)lstat("/home/www/wms2.xxx.com/protected/modules/rights/XMCCacheHttpSession.php",0x7ffff4e31060)=-1ENOENT(Nosuchfileordirectory)lstat("/home/www/wms2.xxx.com/protected/components/XMCCacheHttpSession.php",{st_mode=S_IFREG0777,st_size=2612,...})=0open("/home/www/wms2.xxx.com/protected/components/XMCCacheHttpSession.php",O_RDONLY)=5fstat(5,{st_mode=S_IFREG0777,st_size=2612,...})=0fstat(5,{st_mode=S_IFREG0777,st_size=2612,...})=0fstat(5,{st_mode=S_IFREG0777,st_size=2612,...})=0fstat(5,{st_mode=S_IFREG0777,st_size=2612,...})=0mmap(NULL,2612,PROT_READ,MAP_SHARED,5,0)=0x7fd9b4804000munmap(0x7fd9b4804000,2612)=0close(5)=0sendto(4,"get6cacd9674ad21aa083b5032b1a29"...,39,MSG_DONTWAITMSG_NOSIGNAL,NULL,0)=39recvfrom(4,0x2806d88,8196,64,0,0)=-1EAGAIN(Resourcetemporarilyunavailable)poll([{fd=4,events=POLLIN}],1,5000)=1([{fd=4,revents=POLLIN}])recvfrom(4,"VALUE6cacd9674ad21aa083b5032b1a"...,8196,MSG_DONTWAIT,NULL,NULL)=128lstat("/home/www/wms2.xxx.com/yii/web/CHttpCookie.php",{st_mode=S_IFREG0777,st_size=2772,...})=0lstat("/home/www/wms2.xxx.com/yii/web",{st_mode=S_IFDIR0777,st_size=4096,...})=0open("/home/www/wms2.xxx.com/yii/web/CHttpCookie.php",O_RDONLY)=5fstat(5,{st_mode=S_IFREG0777,st_size=2772,...})=0fstat(5,{st_mode=S_IFREG0777,st_size=2772,...})=0fstat(5,{st_mode=S_IFREG0777,st_size=2772,...})=0fstat(5,{st_mode=S_IFREG0777,st_size=2772,...})=0mmap(NULL,2772,PROT_READ,MAP_SHARED,5,0)=0x7fd9b4804000munmap(0x7fd9b4804000,2772)=0close(5)=0stat("/home/www/wms2.xxx.com/protected/extensions/redis/XMRedis.php",{st_mode=S_IFREG0777,st_size=2672,...})=0lstat("/home/www/wms2.xxx.com/protected/extensions/redis/XMRedis.php",{st_mode=S_IFREG0777,st_size=2672,...})=0lstat("/home/www/wms2.xxx.com/protected/extensions/redis",{st_mode=S_IFDIR0777,st_size=4096,...})=0lstat("/home/www/wms2.xxx.com/protected/extensions",{st_mode=S_IFDIR0777,st_size=4096,...})=0open("/home/www/wms2.xxx.com/protected/extensions/redis/XMRedis.php",O_RDONLY)=5fstat(5,{st_mode=S_IFREG0777,st_size=2672,...})=0fstat(5,{st_mode=S_IFREG0777,st_size=2672,...})=0fstat(5,{st_mode=S_IFREG0777,st_size=2672,...})=0fstat(5,{st_mode=S_IFREG0777,st_size=2672,...})=0mmap(NULL,2672,PROT_READ,MAP_SHARED,5,0)=0x7fd9b4804000munmap(0x7fd9b4804000,2672)=0close(5)=0socket(PF_INET6,SOCK_DGRAM,IPPROTO_IP)=5close(5)=0socket(PF_INET,SOCK_STREAM,IPPROTO_IP)=5fcntl(5,F_GETFL)=0x2(flagsO_RDWR)fcntl(5,F_SETFL,O_RDWRO_NONBLOCK)=0connect(5,{sa_family=AF_INET,sin_port=htons(22122),sin_addr=inet_addr("10.237.36.231")},16)=-1EINPROGRESS(Operationnowinprogress)poll([{fd=5,events=POLLINPOLLOUTPOLLERRPOLLHUP}],1,3000)=1([{fd=5,revents=POLLOUT}])getsockopt(5,SOL_SOCKET,SO_ERROR,[0],[4])=0fcntl(5,F_SETFL,O_RDWR)=0setsockopt(5,SOL_TCP,TCP_NODELAY,[1],4)=0poll([{fd=5,events=POLLINPOLLPRIPOLLERRPOLLHUP}],1,0)=0(Timeout)sendto(5,"*2
$4
AUTH
$9
xm_wms_rs
",29,MSG_DONTWAIT,NULL,0)=29poll([{fd=5,events=POLLINPOLLPRIPOLLERRPOLLHUP}],1,0)=0(Timeout)poll([{fd=5,events=POLLINPOLLERRPOLLHUP}],1,3000)=1([{fd=5,revents=POLLIN}])recvfrom(5,"+OK
",8192,MSG_DONTWAIT,NULL,NULL)=5---SIGSEGV(Segmentationfault)@0(0)---Process6011detached能够看得出,在实行XMRedis落后程6011就逝世失落了。基础能够定位是php-redis出了成绩。持续清查终极发明了有段代码成绩publicfunctionconn(){try{$this->_redis->pconnect($this->host,$this->port,$this->timeout);//Setclientoption.mustAFTERconnected//var_dump(Redis::OPT_SERIALIZER,Redis::SERIALIZER_PHP);exit();$this->_redis->setOption(Redis::OPT_SERIALIZER,Redis::SERIALIZER_PHP);//$this->_redis->setOption(0,0);$this->_redis->auth("xm_wms_rs");$this->connected=true;}catch(RedisException$e){thrownewCHttpException(500,"Redisoccursanerror:".$e->getMessage());}}用白色的代码那段,就会报502毛病,而用绿色代码这段就没成绩。setOption这个是个神马器材呢?查了下php-redisapi$redis->setOption(Redis::OPT_SERIALIZER,Redis::SERIALIZER_NONE);//dontserializedata不序列化数据$redis->setOption(Redis::OPT_SERIALIZER,Redis::SERIALIZER_PHP);//usebuilt-inserialize/unserialize用php内置的序列化$redis->setOption(Redis::OPT_SERIALIZER,Redis::SERIALIZER_IGBINARY);//useigBinaryserialize/unserialize用扩大IGBINARY序列化$redis->setOption(Redis::OPT_PREFIX,myAppName:);//usecustomprefixonallkeysrediskey前缀$redis->setOption(Redis::OPT_SERIALIZER,Redis::SERIALIZER_PHP);用此就报502为何用php内置的序列化就会堕落呢?究竟产生了甚么?厥后又安装了IGBINARY扩大,仍是不可。最初把php-redis安装了最新的版本2.24,再运转,就完整没成绩了。如果不会怎么办,我的视频教程里有个最简单的留言板最开始离不开模仿,
作者:
飘飘悠悠
时间:
2015-1-19 05:10
为了以后维护的方便最好是代码上都加上注释,“予人方便,自己方便”。此外开发文档什么的最好都弄齐全。我觉得这是程序员必备的素质。虽然会消耗点很多的时间。但是确实是非常有必要的。
作者:
再见西城
时间:
2015-2-5 14:40
学习php的目的往往是为了开发动态网站,phper就业的要求也涵盖了很多。我大致总结为:精通php和mysql
作者:
小女巫
时间:
2015-2-12 08:49
其实没啥难的,多练习,练习写程序,真正的实践比看100遍都有用。不过要熟悉引擎
作者:
愤怒的大鸟
时间:
2015-3-3 01:59
我还是推荐用firefox ,配上firebug 插件调试js能省下不受时间。谷歌的浏览器最好也不少用,因为谷歌的大侠们实在是太天才啦,把一些原来的js代码加了一些特效。
作者:
若天明
时间:
2015-3-11 08:35
如果你已经到这种程度了,那么你已经可以做我的老师了。其实php也分很多的区域,
作者:
飘灵儿
时间:
2015-3-18 02:18
我学习了一段时间后,我发现效果并不好(估计是我自身的问题)。因为一个人的精力总是有限的,同时学习这么多,会导致每个的学习时间都得不到保证。
作者:
admin
时间:
2015-3-25 09:47
兴趣是最好的老师,百度是最好的词典。
欢迎光临 仓酷云 (http://ckuyun.com/)
Powered by Discuz! X3.2