仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 582|回复: 7
打印 上一主题 下一主题

[学习教程] PHP编程:纪录php5.4与php-redis抵触的办理

[复制链接]
冷月葬花魂 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-1-16 22:13:32 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
我的这套线路可能跟许多学习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:42 | 只看该作者
为了以后维护的方便最好是代码上都加上注释,“予人方便,自己方便”。此外开发文档什么的最好都弄齐全。我觉得这是程序员必备的素质。虽然会消耗点很多的时间。但是确实是非常有必要的。
再见西城 该用户已被删除
板凳
发表于 2015-2-5 14:40:12 | 只看该作者
学习php的目的往往是为了开发动态网站,phper就业的要求也涵盖了很多。我大致总结为:精通php和mysql
小女巫 该用户已被删除
地板
发表于 2015-2-12 08:49:14 | 只看该作者
其实没啥难的,多练习,练习写程序,真正的实践比看100遍都有用。不过要熟悉引擎
愤怒的大鸟 该用户已被删除
5#
发表于 2015-3-3 01:59:05 | 只看该作者
我还是推荐用firefox ,配上firebug 插件调试js能省下不受时间。谷歌的浏览器最好也不少用,因为谷歌的大侠们实在是太天才啦,把一些原来的js代码加了一些特效。
若天明 该用户已被删除
6#
发表于 2015-3-11 08:35:45 | 只看该作者
如果你已经到这种程度了,那么你已经可以做我的老师了。其实php也分很多的区域,
飘灵儿 该用户已被删除
7#
发表于 2015-3-18 02:18:26 | 只看该作者
我学习了一段时间后,我发现效果并不好(估计是我自身的问题)。因为一个人的精力总是有限的,同时学习这么多,会导致每个的学习时间都得不到保证。
admin 该用户已被删除
8#
发表于 2015-3-25 09:47:40 | 只看该作者
兴趣是最好的老师,百度是最好的词典。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-12-24 02:43

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表