<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[Enjoy]]></title> 
<link>http://www.9enjoy.com/index.php</link> 
<description><![CDATA[分享、学习、提高]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[Enjoy]]></copyright>
<item>
<link>http://www.9enjoy.com/mysql-profile/</link>
<title><![CDATA[MYSQL的profile使用]]></title> 
<author>enjoy &lt;&gt;</author>
<category><![CDATA[PHP+MYSQL]]></category>
<pubDate>Tue, 24 Apr 2012 03:08:32 +0000</pubDate> 
<guid>http://www.9enjoy.com/mysql-profile/</guid> 
<description>
<![CDATA[ 
	MYSQL的profiling功能要在Mysql版本5.0.37以上才能使用。<br/><br/>开启profiling:<br/>set profiling=1;<br/><br/>查看是否设置生效：<br/>select @@profiling;<br/>默认是0，设置成功是1<br/><br/>运行SQL语句：<br/>mysql&gt; select * FROM hx_line WHERE id = &#039;1455023&#039;;<br/><br/>查看profiles<br/>mysql&gt; show profiles;<br/>+----------+------------+---------------------------------------------+<br/>&#124; Query_ID &#124; Duration&nbsp;&nbsp; &#124; Query&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#124;<br/>+----------+------------+---------------------------------------------+<br/>&#124;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1 &#124; 0.00036150 &#124; select * FROM hx_line WHERE id = &#039;1455023&#039; &#124;<br/>+----------+------------+---------------------------------------------+<br/><br/>查看具体某条的profile<br/><br/>mysql&gt; show profile FOR QUERY 1;<br/>+--------------------------------+----------+<br/>&#124; Status&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#124; Duration &#124;<br/>+--------------------------------+----------+<br/>&#124; starting&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#124; 0.000013 &#124;<br/>&#124; Waiting for query cache lock&nbsp;&nbsp; &#124; 0.000014 &#124;<br/>&#124; checking query cache for query &#124; 0.000038 &#124;<br/>&#124; checking permissions&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#124; 0.000006 &#124;<br/>&#124; Opening tables&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#124; 0.000013 &#124;<br/>&#124; System lock&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#124; 0.000009 &#124;<br/>&#124; Waiting for query cache lock&nbsp;&nbsp; &#124; 0.000024 &#124;<br/>&#124; init&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#124; 0.000060 &#124;<br/>&#124; optimizing&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#124; 0.000014 &#124;<br/>&#124; statistics&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#124; 0.000046 &#124;<br/>&#124; preparing&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#124; 0.000017 &#124;<br/>&#124; executing&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#124; 0.000004 &#124;<br/>&#124; Sending data&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#124; 0.000081 &#124;<br/>&#124; end&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#124; 0.000005 &#124;<br/>&#124; query end&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#124; 0.000004 &#124;<br/>&#124; closing tables&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#124; 0.000008 &#124;<br/>&#124; freeing items&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#124; 0.000009 &#124;<br/>&#124; Waiting for query cache lock&nbsp;&nbsp; &#124; 0.000003 &#124;<br/>&#124; freeing items&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#124; 0.000013 &#124;<br/>&#124; Waiting for query cache lock&nbsp;&nbsp; &#124; 0.000003 &#124;<br/>&#124; freeing items&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#124; 0.000003 &#124;<br/>&#124; storing result in query cache&nbsp;&nbsp;&#124; 0.000005 &#124;<br/>&#124; logging slow query&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#124; 0.000003 &#124;<br/>&#124; cleaning up&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#124; 0.000004 &#124;<br/>+--------------------------------+----------+<br/>24 rows<br/><br/>我们看到了一个简单的查询，MYSQL内部做了24次操作。<br/>另外，看到了一堆query cache的操作，试着把query_cache_size=0，把query_cache关闭，再次测试：<br/><br/><br/>mysql&gt; show profile FOR QUERY 1;<br/>+----------------------+----------+<br/>&#124; Status&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#124; Duration &#124;<br/>+----------------------+----------+<br/>&#124; starting&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#124; 0.000040 &#124;<br/>&#124; checking permissions &#124; 0.000007 &#124;<br/>&#124; Opening tables&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#124; 0.000015 &#124;<br/>&#124; System lock&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#124; 0.000010 &#124;<br/>&#124; init&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#124; 0.000061 &#124;<br/>&#124; optimizing&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#124; 0.000013 &#124;<br/>&#124; statistics&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#124; 0.000059 &#124;<br/>&#124; preparing&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#124; 0.000018 &#124;<br/>&#124; executing&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#124; 0.000004 &#124;<br/>&#124; Sending data&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#124; 0.000092 &#124;<br/>&#124; end&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#124; 0.000006 &#124;<br/>&#124; query end&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#124; 0.000004 &#124;<br/>&#124; closing tables&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#124; 0.000008 &#124;<br/>&#124; freeing items&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#124; 0.000020 &#124;<br/>&#124; logging slow query&nbsp;&nbsp; &#124; 0.000003 &#124;<br/>&#124; cleaning up&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#124; 0.000004 &#124;<br/>+----------------------+----------+<br/>16 rows in set (0.00 sec)<br/><br/>当开启了query_cache的情况下，需要多操作6次，在这个示例里面多化了0.000087s。<br/><br/><strong>查询这条语句对CPU的使用情况：</strong><br/>mysql&gt; show profile cpu FOR QUERY 1;<br/>+----------------------+----------+----------+------------+<br/>&#124; Status&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#124; Duration &#124; CPU_user &#124; CPU_system &#124;<br/>+----------------------+----------+----------+------------+<br/>&#124; starting&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#124; 0.000037 &#124; 0.000000 &#124;&nbsp;&nbsp; 0.000000 &#124;<br/>&#124; checking permissions &#124; 0.000009 &#124; 0.000000 &#124;&nbsp;&nbsp; 0.000000 &#124;<br/>&#124; Opening tables&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#124; 0.000014 &#124; 0.000000 &#124;&nbsp;&nbsp; 0.000000 &#124;<br/>&#124; System lock&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#124; 0.000009 &#124; 0.000000 &#124;&nbsp;&nbsp; 0.000000 &#124;<br/>&#124; init&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#124; 0.000059 &#124; 0.000000 &#124;&nbsp;&nbsp; 0.000000 &#124;<br/>&#124; optimizing&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#124; 0.000009 &#124; 0.000000 &#124;&nbsp;&nbsp; 0.000000 &#124;<br/>&#124; statistics&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#124; 0.000044 &#124; 0.000000 &#124;&nbsp;&nbsp; 0.000000 &#124;<br/>&#124; preparing&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#124; 0.000015 &#124; 0.000000 &#124;&nbsp;&nbsp; 0.000000 &#124;<br/>&#124; executing&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#124; 0.000004 &#124; 0.000000 &#124;&nbsp;&nbsp; 0.000000 &#124;<br/>&#124; Sending data&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#124; 0.000081 &#124; 0.000000 &#124;&nbsp;&nbsp; 0.000000 &#124;<br/>&#124; end&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#124; 0.000006 &#124; 0.000000 &#124;&nbsp;&nbsp; 0.000000 &#124;<br/>&#124; query end&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#124; 0.000004 &#124; 0.000000 &#124;&nbsp;&nbsp; 0.000000 &#124;<br/>&#124; closing tables&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#124; 0.000008 &#124; 0.000000 &#124;&nbsp;&nbsp; 0.000000 &#124;<br/>&#124; freeing items&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#124; 0.000021 &#124; 0.000000 &#124;&nbsp;&nbsp; 0.000000 &#124;<br/>&#124; logging slow query&nbsp;&nbsp; &#124; 0.000004 &#124; 0.000000 &#124;&nbsp;&nbsp; 0.000000 &#124;<br/>&#124; cleaning up&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#124; 0.000004 &#124; 0.000000 &#124;&nbsp;&nbsp; 0.000000 &#124;<br/>+----------------------+----------+----------+------------+<br/><br/><strong>show profile额外一些命令：</strong><br/>* ALL - displays all information<br/>* BLOCK IO - displays counts for block input and output Operations<br/>* CONTEXT SWITCHES - displays counts for voluntary and involuntary context switches<br/>* ipC - displays counts for messages sent and received<br/>* MEMORY - is not currently implemented<br/>* PAGE FAULTS - displays counts for major and minor page faults<br/>* SOURCE - displays the names of functions from the source code, together with the name and line number of the file in which the function occurs<br/>* SWAPS - displays swap counts<br/>Tags - <a href="http://www.9enjoy.com/tags/mysql/" rel="tag">mysql</a> , <a href="http://www.9enjoy.com/tags/%25E6%2580%25A7%25E8%2583%25BD/" rel="tag">性能</a>
]]>
</description>
</item><item>
<link>http://www.9enjoy.com/php-display-errors/</link>
<title><![CDATA[display_errors设置为Off无效，仍然输出报错]]></title> 
<author>enjoy &lt;&gt;</author>
<category><![CDATA[默认分类]]></category>
<pubDate>Tue, 27 Mar 2012 05:39:55 +0000</pubDate> 
<guid>http://www.9enjoy.com/php-display-errors/</guid> 
<description>
<![CDATA[ 
	某台服务器php.ini的设置：<br/>error_reporting = E_ALL &amp; ~E_NOTICE<br/>display_errors = Off<br/>log_errors = On<br/>error_log = /www/logs/php_error.log<br/><br/>按理说这样，错误信息是不会输出了，但是当PHP有错误时，会把报错提示显示在页面上。<br/><br/>搜索了下，发现有人说当log_errors开启时，如果error_log的路径不对，会导致报错显示。经查与此无关。<br/><br/>输出phpinfo()，查看到display_errors是On。在页面中指定：ini_set(&quot;DISPLAY_ERRORS&quot;,0)，仍然无效！<br/><br/>最后发现php-fpm.conf里有句：<div class="quote"><div class="quote-title">引用</div><div class="quote-content">Additional php.ini defines, specific to this pool of workers.<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;value name=&quot;php_defines&quot;&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;value name=&quot;sendmail_path&quot;&gt;/usr/sbin/sendmail -t -i&lt;/value&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;value name=&quot;display_errors&quot;&gt;1&lt;/value&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/value&gt;</div></div><br/>原来忘了修改这个地方的配置，display_errors被设置为1了！这里面也说明了在php_defines里可以额外指定某些php的参数。<br/>直接将这两段注释掉，php-fpm reload后，报错提示不再显示到页面上了。<br/>Tags - <a href="http://www.9enjoy.com/tags/php/" rel="tag">php</a> , <a href="http://www.9enjoy.com/tags/%25E6%2597%25A5%25E5%25BF%2597/" rel="tag">日志</a>
]]>
</description>
</item><item>
<link>http://www.9enjoy.com/seo-abc/</link>
<title><![CDATA[SEO入门培训文稿]]></title> 
<author>enjoy &lt;&gt;</author>
<category><![CDATA[网站相关]]></category>
<pubDate>Thu, 15 Mar 2012 02:22:12 +0000</pubDate> 
<guid>http://www.9enjoy.com/seo-abc/</guid> 
<description>
<![CDATA[ 
	昨天(11.03.14)晚上给同事分享SEO知识，听众有近40人，自我感觉还是不错的：）<br/>还是有一些干货的，希望有来听的同事都能有所收获。<br/><br/>下面是我这次培训的一个文稿，也分享出来：）<br/><br/>培训大纲：<br/>1、SEO基本概念和常用工具分享，<br/>2、SEO实现过程，收录-&gt;排名-&gt;点击率。<br/><br/>一：SEO基本知识：<br/><br/>1 几点基础知识：PR，世界排名，百度权重，收录数<br/><br/>1.1 PR<br/><br/>1.1.1什么是PR?<br/><br/>PageRank(网页级别)，2001年9月被授予美国专利，专利人是Google创始人之一拉里·佩奇（Larry Page）。<br/>因此，PageRank里的page不仅指网页，还指佩奇。<br/>它是Google排名运算法则（排名公式）的一部分，是Google用于用来标识网页的等级/重要性的一种方法，是Google用来衡量一个网站的好坏的重要标准之一。<br/>早几年，交换链接时几乎只看PR，因为没有其它的考察网站好坏的渠道。<br/><br/>1.1.2.哪里看PR?<br/>IE浏览器：Google工具条：<a href="http://www.google.com/intl/zh-CN/toolbar/ie/" target="_blank">http://www.google.com/intl/zh-CN/toolbar/ie/</a><br/>安装后在选项里启用Pagerank。<br/>360浏览器：站长工具 的插件 <a href="http://open.se.360.cn/app2/detail/appid/183" target="_blank">http://open.se.360.cn/app2/detail/appid/183</a><br/>Firebug浏览器：使用SearchStatus扩展。<br/>Chrome浏览器、360极速浏览器，使用PageRank Status扩展。<br/><br/>网站上查询 站长站：<a href="http://pr.chinaz.com/" target="_blank">http://pr.chinaz.com/</a><br/><br/>1.2 世界排名(Alexa)<br/><br/>网址：<a href="http://cn.alexa.com/siteinfo/cncn.com" target="_blank">http://cn.alexa.com/siteinfo/cncn.com</a><br/><br/>国内：<a href="http://alexa.chinaz.com/?domain=cncn.com" target="_blank">http://alexa.chinaz.com/?domain=cncn.com</a><br/><br/>1.3 百度权重<br/><br/>印象中，2010年下半年开始有的，第一个站是爱站。<br/><br/><a href="http://www.aizhan.com/baidu/cncn.com/" target="_blank">http://www.aizhan.com/baidu/cncn.com/</a><br/><br/><a href="http://mytool.chinaz.com/baidusort.aspx?host=cncn.com" target="_blank">http://mytool.chinaz.com/baidusort.aspx?host=cncn.com</a><br/><br/>1.4 百度指数<br/><br/><a href="http://index.baidu.com" target="_blank">http://index.baidu.com</a><br/>通过观察指数，了解搜索词的大致搜索量。<br/><br/>1.5 收录数<br/><br/><a href="http://www.baidu.com/s?wd=site%3Acncn.com" target="_blank">http://www.baidu.com/s?wd=site%3Acncn.com</a><br/><a href="http://www.baidu.com/s?wd=site%3Awww.cncn.com" target="_blank">http://www.baidu.com/s?wd=site%3Awww.cncn.com</a><br/><br/>如何查看某网页是否被收录？<br/>直接把网址放到百度的搜索框里搜索。<br/><br/>1.6 百度快照<br/><br/>确实是时间越近越好，交换链接时许多人关注。<br/>但与权重关系不大，有的页面是很老的百度快照，但不影响其排第一名。<br/><br/>1.6 搜索技巧：intitle,inurl<br/><br/><a href="http://www.baidu.com/gaoji/advanced.html" target="_blank">http://www.baidu.com/gaoji/advanced.html</a><br/>按时间搜索，一天内收录lm=1、一周内收录lm=7等，baidu返回结果有Bug<br/><br/>总结：<br/>tool.chinaz.com 输入网站域名后，点SEO综合查询，上面说的基本上都帮你查好了。<br/><br/>二：SEO实现过程<br/><br/>SEO实现整体分三部分：第一是收录；第二是排名；第三是点击率<br/><br/>3.1 收录：<br/>内容原创性<br/>要有良好的结构，使蜘蛛方便的找到新加的页面<br/><br/>3.2 排名三部分：<br/>第一部分是页面基础的优化(页面实施细节，略过)<br/>第二部分是关键词策略，通过百度搜索框的下拉提示和结果页面的相关搜索<br/>第三部分是链接<br/><br/>3.3 点击率：<br/>标题、描述要吸引人，促进用户点击，进而再次提高或稳持排名。<br/>网页的描述对排名没有作用，但对吸引用户点击有用。<br/>Tags - <a href="http://www.9enjoy.com/tags/seo/" rel="tag">seo</a> , <a href="http://www.9enjoy.com/tags/%25E7%2599%25BE%25E5%25BA%25A6/" rel="tag">百度</a> , <a href="http://www.9enjoy.com/tags/%25E6%2594%25B6%25E5%25BD%2595/" rel="tag">收录</a> , <a href="http://www.9enjoy.com/tags/%25E6%258E%2592%25E5%2590%258D/" rel="tag">排名</a>
]]>
</description>
</item><item>
<link>http://www.9enjoy.com/pragma-no-cache-session/</link>
<title><![CDATA[Pragma:no-cache哪里来的？]]></title> 
<author>enjoy &lt;&gt;</author>
<category><![CDATA[PHP+MYSQL]]></category>
<pubDate>Sat, 11 Feb 2012 14:45:42 +0000</pubDate> 
<guid>http://www.9enjoy.com/pragma-no-cache-session/</guid> 
<description>
<![CDATA[ 
	今天给同事分享了一下前端性能优化，在介绍了php文件缓存的方法后，发现一个AJAX请求的文件，在请求头中始终有一个：Pragma:no-cache，导致这个文件不能被浏览器缓存。接着发现这个站几乎所有动态页面都有这个参数Pragma:no-cache。<br/><br/>开始怀疑是不是设置了Cache-control:no-cache导致的，但查遍程序没发现。怀疑服务器的配置，没什么异常的。<br/>最后，同事定位到了页面开始的session_start()身上。。。<br/><br/>问题果然出现在它session身上！<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content">session.cache_limiter string <br/>session.cache_limiter 指定会话页面所使用的缓冲控制方法（none/nocache/private/private_no_expire/public）。默认为 nocache。参见 session_cache_limiter()。 </div></div><div class="quote"><div class="quote-title">引用</div><div class="quote-content">string session_cache_limiter ( [string cache_limiter] )<br/><br/>session_cache_limiter() returns the name of the current cache limiter. If cache_limiter is specified, the name of the current cache limiter is changed to the new value. <br/><br/>The cache limiter defines which cache control HTTP headers are sent to the client. These headers determine the rules by which the page content may be cached by the client and intermediate proxies. Setting the cache limiter to nocache disallows any client/proxy caching. A value of public permits caching by proxies and the client, whereas private disallows caching by proxies and permits the client to cache the contents. <br/><br/>In private mode, the Expire header sent to the client may cause confusion for some browsers, including Mozilla. You can avoid this problem by using private_no_expire mode. The expire header is never sent to the client in this mode. <br/><br/>The cache limiter is reset to the default value stored in session.cache_limiter at request startup time. Thus, you need to call session_cache_limiter() for every request (and before session_start() is called). </div></div><br/><br/>当启用了session后，session.cache_limiter就被默认设置为nocache，所以就在http头里发送no-cache信息，导致页面不会被缓存。<br/>当然一般需要缓存的文件是不需要session的，因此去掉头部的session_start()即可。<br/>如果实在需要在启用session后还需要把这个页面缓存，则需要在session_start之前设置下session_cache_limiter(&#039;public&#039;)。<br/><br/><br/><br/>Tags - <a href="http://www.9enjoy.com/tags/%25E7%25BC%2593%25E5%25AD%2598/" rel="tag">缓存</a> , <a href="http://www.9enjoy.com/tags/session/" rel="tag">session</a> , <a href="http://www.9enjoy.com/tags/cache/" rel="tag">cache</a>
]]>
</description>
</item><item>
<link>http://www.9enjoy.com/json_encode_zhongwen/</link>
<title><![CDATA[json_encode后的中文不编码成unicode]]></title> 
<author>enjoy &lt;&gt;</author>
<category><![CDATA[PHP+MYSQL]]></category>
<pubDate>Wed, 01 Feb 2012 05:53:48 +0000</pubDate> 
<guid>http://www.9enjoy.com/json_encode_zhongwen/</guid> 
<description>
<![CDATA[ 
	当使用php自带的json_encode对数据进行编码时，中文都会变成unicode，导致不可读。如：对字符串”厦门“进行json_encode后，输出的是&quot;&#92;u53a6&#92;u95e8&quot;。<br/><br/>查询了一下，有两种方法：<br/>1.将&quot;&#92;u53a6&#92;u95e8&quot;还原成“厦门”，使用如下的代码：<div class="code">$str= preg_replace(&quot;#&#92;&#92;&#92;u(&#91;0-9a-f&#93;+)#ie&quot;, &quot;iconv(&#039;UCS-2&#039;, &#039;UTF-8&#039;, pack(&#039;H4&#039;, &#039;&#92;&#92;1&#039;))&quot;, $str);</div><br/>2.先将中文字段urlencode，json_encode后，再用urldecode，也可以显示中文。<div class="code">$code = urldecode(json_encode(urlencode(&quot;厦门&quot;)));</div><br/>PHP5.4版本，已经给Json新增了一个选项: JSON_UNESCAPED_UNICODE。加上这个选项后，就不会自动把中文编码了。<div class="code">echo json_encode(&quot;厦门&quot;, JSON_UNESCAPED_UNICODE);</div><br/><br/>另，由于 json_encode 和 json_decode只支持utf-8编码的字符，GBK的字符要用json就得转换一下，附自己写的GBK转UTF-8的代码：<div class="code"><br/>/*<br/>&nbsp;&nbsp;&nbsp;&nbsp;字符串GBK转码为UTF-8，数字转换为数字。<br/>*/<br/>function ct2($s)&#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;if(is_numeric($s)) &#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return intval($s);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&#125; else &#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return iconv(&quot;GBK&quot;,&quot;UTF-8&quot;,$s);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&#125;<br/>&#125;<br/>/*<br/>&nbsp;&nbsp;&nbsp;&nbsp;批量处理gbk-&gt;utf-8<br/>*/<br/>function icon_to_utf8($s) &#123;<br/><br/>&nbsp;&nbsp;if(is_array($s)) &#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;foreach($s as $key =&gt; $val) &#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$s&#91;$key&#93; = icon_to_utf8($val);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;&#125; else &#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$s = ct2($s);<br/>&nbsp;&nbsp;&#125;<br/>&nbsp;&nbsp;return $s;<br/><br/>&#125;<br/><br/>echo json_encode(icon_to_utf8(&quot;厦门&quot;));</div><br/>Tags - <a href="http://www.9enjoy.com/tags/%25E7%25BC%2596%25E7%25A0%2581/" rel="tag">编码</a> , <a href="http://www.9enjoy.com/tags/json/" rel="tag">json</a> , <a href="http://www.9enjoy.com/tags/%25E4%25B8%25AD%25E6%2596%2587/" rel="tag">中文</a>
]]>
</description>
</item><item>
<link>http://www.9enjoy.com/curl_get_contents/</link>
<title><![CDATA[分享比file_get_contents稳定的curl_get_contents]]></title> 
<author>enjoy &lt;&gt;</author>
<category><![CDATA[PHP+MYSQL]]></category>
<pubDate>Tue, 03 Jan 2012 12:29:06 +0000</pubDate> 
<guid>http://www.9enjoy.com/curl_get_contents/</guid> 
<description>
<![CDATA[ 
	分享一个实际在用的函数：<br/><div class="code">/*比file_get_contents稳定的多！$timeout为超时时间，单位是秒，默认为1s。*/<br/>function curl_get_contents($url,$timeout=1) &#123;<br/>&nbsp;&nbsp;$curlHandle = curl_init();<br/>&nbsp;&nbsp;curl_setopt( $curlHandle , CURLOPT_URL, $url );<br/>&nbsp;&nbsp;curl_setopt( $curlHandle , CURLOPT_RETURNTRANSFER, 1 );<br/>&nbsp;&nbsp;curl_setopt( $curlHandle , CURLOPT_TIMEOUT, $timeout );<br/>&nbsp;&nbsp;$result = curl_exec( $curlHandle );<br/>&nbsp;&nbsp;curl_close( $curlHandle );<br/>&nbsp;&nbsp;return $result;<br/>&#125;<br/>$hx = curl_get_contents(&#039;http://www.9enjoy.com&#039;);</div><br/>相信使用过file_get_contents函数的朋友都知道，当获取的$url访问不了时，会导致页面漫长的等待，甚至还能导致PHP进程占用CPU达100%，因此这个函数就诞生了。<a href="http://www.9enjoy.com/post/300" target="_blank">curl的一些常识介绍</a><br/><br/>保留原file_get_contents函数的原因是当读取本地文件时，用原生的file_get_contents显然更合适。<br/><br/>另来自张宴的file_get_contnets的优化，具体可看：<a href="http://blog.s135.com/file_get_contents" target="_blank">http://blog.s135.com/file_get_contents</a><br/>同样是设置超时时间来解决这个问题。如果没装curl，就必须得用这个方式了。<br/><div class="code">$ctx = stream_context_create(array(&nbsp;&nbsp; <br/>&nbsp;&nbsp; &#039;http&#039; =&gt; array(&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &#039;timeout&#039; =&gt; 1 //设置一个超时时间，单位为秒&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )&nbsp;&nbsp; <br/>&nbsp;&nbsp; )&nbsp;&nbsp; <br/>);&nbsp;&nbsp; <br/>file_get_contents(&quot;http://www.9enjoy.com/&quot;, 0, $ctx); </div><br/><br/>另外，据不完全测试，使用curl获取页面比用file_get_contents稳定的多。<br/><br/><br/>Tags - <a href="http://www.9enjoy.com/tags/curl/" rel="tag">curl</a> , <a href="http://www.9enjoy.com/tags/%25E9%2587%2587%25E9%259B%2586/" rel="tag">采集</a>
]]>
</description>
</item><item>
<link>http://www.9enjoy.com/no-deserializer-defined-for-array-type/</link>
<title><![CDATA[ArrayOf_xsd_string格式在php下的处理]]></title> 
<author>enjoy &lt;&gt;</author>
<category><![CDATA[PHP+MYSQL]]></category>
<pubDate>Mon, 07 Nov 2011 06:51:56 +0000</pubDate> 
<guid>http://www.9enjoy.com/no-deserializer-defined-for-array-type/</guid> 
<description>
<![CDATA[ 
	使用某服务商的webservice服务，其wsdl里有个这样一个变量： <br/>&lt;&lt;wsdl:part name=&quot;mobiles&quot; type=&quot;impl:ArrayOf_xsd_string&quot; /&gt; <br/>而php里并没有对应的类型。<br/>使用<br/>$mobiles = &#039;18900000000&#039;;<br/>$mobiles[0]=&#039;18900000000&#039;;<br/>甚至mobiles[0][0]=&#039;18900000000&#039;;<br/>都不行，会提示：<br/>Fatal error: Uncaught SoapFault exception: [soapenv:Server.userException] org.xml.sax.SAXException: No deserializer defined for array type &#123;<a href="http://www.w3.org/2001/XMLSchema&#125;string" target="_blank">http://www.w3.org/2001/XMLSchema&#125;string</a> in /www/9enjoy.com/include/hx.php:46 Stack trace: #0 /www/9enjoy.com/include/hx.php(46): SoapClient-&gt;__call(&#039;sendSM&#039;, Array) #1 /www/9enjoy.com/include/hx.php(2): send_mobile(&#039;18900000000&#039;, &#039;&#123;????????&#125;?????...&#039;) #2 &#123;main&#125; thrown in /www/9enjoy.com/include/hx.php on line 46<br/><br/>使用.NET WebService Studio工具测试，将参数填入后，得到request的xml为：<br/><br/>&lt;q1:sendSM&gt;<br/><br/>​&nbsp;&nbsp;&nbsp;&nbsp;&lt;mobiles href=&quot;#id1&quot; /&gt;<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;&lt;content xsi:type=&quot;xsd:string&quot;&gt;test&lt;/content&gt;​<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;...<br/><br/>&lt;/qi:sendSM&gt;<br/><br/>&lt;soapenc:Array id=&quot;id1&quot; soapenc:arrayType=&quot;xsd:string[1]&quot;&gt;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Item&gt;18900000000&lt;/Item&gt;<br/>&lt;/soapenc:Array&gt;<br/><br/><br/>测试多次后发现有两种解决办法：<br/><br/>1.较简单，把ArrayOf_xsd_string这种格式转换为数组格式<br/><br/>&lt;?php<br/>$client = new SoapClient(&quot;some.wsdl&quot;, array(&#039;features&#039; =&gt; SOAP_USE_XSI_ARRAY_TYPE));<br/>?&gt; <br/><br/>这时，可使用$mobiles = array(&#039;18900000000&#039;);来传递$mobiles变量。<br/>这是php5.2.2起增加的功能<div class="quote"><div class="quote-title">引用</div><div class="quote-content">- Improved SOAP<br/>&nbsp;&nbsp;. Added ability to encode arrays with &quot;SOAP-ENC:Array&quot; type instead of WSDL<br/>&nbsp;&nbsp;&nbsp;&nbsp;type. To activate the ability use &quot;feature&quot;=&gt;SOAP_USE_XSI_ARRAY_TYPE<br/>&nbsp;&nbsp;&nbsp;&nbsp;option in SoapClient/SoapServer constructors. (Rob, Dmitry)</div></div><br/><br/>2.将整个xml文档用doRequest 方法发送出去<br/><br/>public string SoapClient::__doRequest ( string $request , string $location , string $action , int $version [, int $one_way = 0 ] )<br/>Tags - <a href="http://www.9enjoy.com/tags/array/" rel="tag">array</a> , <a href="http://www.9enjoy.com/tags/soap/" rel="tag">soap</a> , <a href="http://www.9enjoy.com/tags/php/" rel="tag">php</a> , <a href="http://www.9enjoy.com/tags/websevice/" rel="tag">websevice</a>
]]>
</description>
</item><item>
<link>http://www.9enjoy.com/trying-to-clone-uncloneable-object-of-class/</link>
<title><![CDATA[Trying to clone an uncloneable object of class Imagic的解决]]></title> 
<author>enjoy &lt;&gt;</author>
<category><![CDATA[PHP+MYSQL]]></category>
<pubDate>Sun, 25 Sep 2011 10:14:51 +0000</pubDate> 
<guid>http://www.9enjoy.com/trying-to-clone-uncloneable-object-of-class/</guid> 
<description>
<![CDATA[ 
	使用网上流传的一个程序实现pdf截图为png，需要使用Imagic扩展。在windows下安装完后提示：<div class="code">Fatal error: Trying to clone an uncloneable object of class Imagick in C:&#92;www&#92;hx&#92;pdf_to_png.php on line 17</div><br/><br/>使用IIS和Apache均会有这个提示。经多次测试后，发现两种解决方法:<br/><br/>1.php.ini中; Enable compatibility mode with Zend Engine 1 (PHP 4.x)<br/>zend.ze1_compatibility_mode = Off<br/><br/>默认是On，改为Off后，即可解决。<br/><br/>2.使用imagick::...这种方法调用。<br/>即$im-&gt;setResolution(120, 120);可以改写为：<br/>imagick::setResolution(120, 120);<br/><br/><br/>如果其它扩展出现这类错误，一般也是可以使用这两种方法解决的。<br/><br/>附pdf转png的程序代码片断：<div class="code">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;function pdf2png($pdf, $filename, $page=0) &#123;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (!extension_loaded(&#039;imagick&#039;)) &#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exit(&#039;no imagick&#039;);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return false;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125; <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (!file_exists($pdf)) &#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return false;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$im = new Imagick();<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$im-&gt;setResolution(120, 120);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$im-&gt;setCompressionQuality(100);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$im-&gt;readImage($pdf . &quot;&#91;&quot; . $page . &quot;&#93;&quot;);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$im-&gt;setImageFormat(&#039;png&#039;);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$im-&gt;writeImage($filename);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$im-&gt;readImage($filename);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$im-&gt;resizeImage(120, 150, Imagick::FILTER_LANCZOS, 1);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$im-&gt;writeImage($filename);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return $filename;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;</div><br/><br/> <br/>Tags - <a href="http://www.9enjoy.com/tags/%25E6%2589%25A9%25E5%25B1%2595/" rel="tag">扩展</a>
]]>
</description>
</item><item>
<link>http://www.9enjoy.com/wps-com-exception/</link>
<title><![CDATA[win2003服务器使用WPS的COM组件的一些问题解决]]></title> 
<author>enjoy &lt;&gt;</author>
<category><![CDATA[PHP+MYSQL]]></category>
<pubDate>Sat, 17 Sep 2011 11:02:17 +0000</pubDate> 
<guid>http://www.9enjoy.com/wps-com-exception/</guid> 
<description>
<![CDATA[ 
	项目中使用了新功能，gump同学研究出来的使用WPS的COM组件用PHP实现将doc等office格式转换成pdf。由于COM组件只能在windows上使用，因为程序必须放在windows的服务器上运行。在本地xp系统上搭建安装没任何问题，在服务器win2003上安装，碰到了N个问题，最后还是gump同学出手才解决，整整折腾了不少于10个小时才搞定。<br/><br/>安装完Wps office个人版最新的12012版后，按理说就完成了，但运行程序在服务器上报错如下：<br/><br/>Fatal error: Uncaught exception &#039;com_exception&#039; with message &#039;Failed to create COM object `WPS.Application&#039;: 拒绝访问。 &#039; in D:&#92;www&#92;9enjoy.com&#92;hx.php:12 Stack trace: #0 D:&#92;www&#92;9enjoy.com&#92;hx.php(12): com-&gt;com(&#039;WPS.Application&#039;) #1 &#123;main&#125; thrown in D:&#92;www&#92;9enjoy.com&#92;hx.php on line 12<br/><br/>是运行这句就$wps = new COM(&quot;WPS.Application&quot;);报错。经过一翻查找，在DCOM配置里做了配置，解决了这个提示。<br/><br/>1、打开控制面板 - 管理工具 - 组件服务<br/><br/>2、在组件服务面板中依次打开 控制台根目录 - 组件服务 - 计算机 - 我的电脑 - DCOM 配置<br/><br/>3、找到Kingsoft Writer Application Class(金山的文档应用服务)，打开属性窗口，切换到安全标签。将“启动和激活权限”选择自定义，编辑，添加everyone权限即可。“访问权限”也一样处理。<br/><br/>这个错误提示通过，运行到$doc = $wps-&gt;Documents-&gt;Open($src_filename); 时又出现错误<br/><br/>Fatal error: Uncaught exception &#039;com_exception&#039; with message &#039;Error [0x800706be] 远程过程调用失败。 &#039; in D:&#92;www&#92;9enjoy.com&#92;hx.php:15 Stack trace: #0 D:&#92;www&#92;9enjoy.com&#92;hx.php(15): variant-&gt;Open(&#039;d:&#92;www&#92;9enjoy.com...&#039;) #1 &#123;main&#125; thrown in D:&#92;www&#92;9enjoy.com&#92;hx.php on line 15<br/><br/>在“标识”标签，将启动用户改为交互式用户，又出现了另一个错误提示：<br/><br/>Fatal error: Uncaught exception &#039;com_exception&#039; with message &#039;Failed to create COM object `WPS.Application&#039;: 因为配置类型不正确，系统无法开始服务器进程。请检查用户名和密码。 &#039; in D:&#92;www&#92;9enjoy.com&#92;hx.php:15 Stack trace: #0 D:&#92;www&#92;9enjoy.com&#92;hx.php(15): com-&gt;com(&#039;WPS.Application&#039;) #1 &#123;main&#125; thrown in D:&#92;www&#92;9enjoy.com&#92;hx.php on line 15<br/><br/>反复尝试，都不行，包括重装WPS。<br/><br/>后&quot;标识&quot;标签，使用指定用户运行，先使用网站用的用户运行，通不过。再使用管理员账号运行，点确定时也会弹出出错信息。应该是这两个选项(启动用户和指定用户)都无法把这个com组件启动起来。如果用交互式用户，是可以的，就是提示用户名和密码不对：（<br/><br/>后测试中有时出现长时间运行，一直不报错...还有出现过如下错误：<br/>Fatal error: Uncaught exception &#039;com_exception&#039; with message &#039;Failed to create COM object `WPS.Application&#039;: 服务器运行失败 &#039; in D:&#92;www&#92;9enjoy.com&#92;hx.php:30 Stack trace: #0 D:&#92;www&#92;9enjoy.com&#92;hx.php(30): com-&gt;com(&#039;WPS.Application&#039;) #1 &#123;main&#125; thrown in D:&#92;www&#92;9enjoy.com&#92;hx.php on line 30<br/><br/>期间还发现，由于执行到$wps-&gt;Documents-&gt;Open就停了，会在进程中出现一个wps或wpsupdate进程，每刷新一次出现一个。最多一次发现有30多个这类进程，有时还会影响程序，需要手工一个一个删除。<br/><br/>最后，使用了一个很BT的做法，将这个站点的IIS身份验证方式使用administrator管理员账号运行，居然好了！。。。<br/><br/><br/>参考了如下文章：<br/><br/><a href="http://tech.cncms.com/web/php/108706.html" target="_blank">http://tech.cncms.com/web/php/108706.html</a><br/><a href="http://blog.csdn.net/fkedwgwy/article/details/5731166" target="_blank">http://blog.csdn.net/fkedwgwy/article/details/5731166</a><br/><a href="http://hi.baidu.com/kashifs/blog/item/4f643bafcdde5c194b36d6b7.html" target="_blank">http://hi.baidu.com/kashifs/blog/item/4f643bafcdde5c194b36d6b7.html</a><br/><br/><br/>Tags - <a href="http://www.9enjoy.com/tags/wps/" rel="tag">wps</a> , <a href="http://www.9enjoy.com/tags/%25E8%25BD%25AC%25E6%258D%25A2/" rel="tag">转换</a> , <a href="http://www.9enjoy.com/tags/pdf/" rel="tag">pdf</a>
]]>
</description>
</item><item>
<link>http://www.9enjoy.com/root-domain-301-www/</link>
<title><![CDATA[首选域的选择(根域名如何正确的跳转到www域名)]]></title> 
<author>enjoy &lt;&gt;</author>
<category><![CDATA[网站相关]]></category>
<pubDate>Wed, 31 Aug 2011 03:16:09 +0000</pubDate> 
<guid>http://www.9enjoy.com/root-domain-301-www/</guid> 
<description>
<![CDATA[ 
	一个网站，用户访问到的其实可能有两个版本，一个是带www的，一个是不带www的。如：<a href="http://www.itlearner.com" target="_blank">www.itlearner.com</a>和itlearner.com。内页同样如此。<br/><br/>一般来说，经常见到的应该是带www的域名，但是有不少人在直接输网址的时候喜欢省略掉www，而不带www和带www的域名原则上说是不同的，因此有些站（甚至有些是小有名气的站）都没有注意到这点，解析了www，没解析没带www的，导致访问不带www域名时失败。<br/><br/>因此，带www和不带www的都要做解析。但是两个都解析后，产生一个问题，搜索引擎认为这是两个站点。<br/><br/>比较好的处理方式是不带www的域名301到带www的域名下。下面提供两种方案，一种新建一个根域名的主机配置，专门用来跳转，第二种是直接在www域名的主机配置文件中设定。<br/><br/>第一种方案：<br/><br/>Nginx下的规则：<br/><br/>server &#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;listen 80;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;server_name itlearner.com;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rewrite ^/(.*)$ <a href="http://www.itlearner.com/$1" target="_blank">http://www.itlearner.com/$1</a> permanent;<br/>&#125;<br/><br/>Apache下的规则：<br/><br/>RewriteEngine On<br/>RewriteRule ^(.*)$&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="http://www.itlearner.com/$1" target="_blank">http://www.itlearner.com/$1</a> [R=301] <br/><br/>第二种方案：<br/><br/>Nginx下的规则：<br/>server &#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;listen 80;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;server_name <a href="http://www.itlearner.com" target="_blank">www.itlearner.com</a> itlearner.com;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ($host != &#039;<a href="http://www.itlearner.com&#039;" target="_blank">www.itlearner.com&#039;</a> ) &#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rewrite ^/(.*)$ <a href="http://www.itlearner.com/$1" target="_blank">http://www.itlearner.com/$1</a> permanent;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#125;<br/>&#125;<br/><br/>Apache下的规则：<br/><br/>RewriteEngine On<br/>RewriteCond %&#123;HTTP_HOST&#125;&nbsp;&nbsp; ^www&#92;.itlearner&#92;.com$ [NC]<br/>RewriteRule ^(.*)$&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="http://www.itlearner.com/$1" target="_blank">http://www.itlearner.com/$1</a> [L,R=301] <br/><br/> <br/>第一种方案略嫌麻烦，因为需要新建一个主机，一般直接使用第二种方案。但如果www下的rewrite比较多，访问量又非常大，这时，就建议采用第一种方案了。<br/><br/>谷歌都这点处理的比较好，如果网站主要来路是Google，这一点都可以不用做，因为使用网站管理员工具，可以设定首选域(位置在 网站配置-&gt;设置)。但是我仍然建议这么做，因为这样可以帮助其它搜索引擎和访问者了解到您网站的首选域。<br/><br/>百度在这个问题上的处理还是有点问题的，比较喜欢收录不带www的域名(即使不带www的域名一直以来都是301到带www的域名上)，造成一个网站有两个首页。<br/><br/>Tags - <a href="http://www.9enjoy.com/tags/%25E5%259F%259F%25E5%2590%258D/" rel="tag">域名</a> , <a href="http://www.9enjoy.com/tags/301/" rel="tag">301</a> , <a href="http://www.9enjoy.com/tags/seo/" rel="tag">seo</a>
]]>
</description>
</item>
</channel>
</rss>
