maketop’s blog

Just another WordPress weblog

Archive for the ‘代码香槟’ Category

SiteMap Protocol一种站点地图协议,由Google, MSN, Yahoo共同推出。这个协议定义了如何定义一个网站地图以便于搜索引擎的收录。对协议本身的讨论已经比较多了,可以通过官方网站学习详细的协议内容。

SiteMap Index则解决了如果网站存在多个SiteMap文件的情况下如何处理。在SiteMap Protocol中定义通过<sitemapindex>标签来定义多个sitemap文件的位置。语法方式为

<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
   <sitemap>
      <loc>http://www.example.com/sitemap1.xml.gz</loc>
      <lastmod>2004-10-01T18:23:17+00:00</lastmod>
   </sitemap>
   <sitemap>
      <loc>http://www.example.com/sitemap2.xml.gz</loc>
      <lastmod>2005-01-01</lastmod>
   </sitemap>
</sitemapindex>

每一个<sitemap>标签定义一个sitemap文件,<loc>标签定义文件位置,<lastmod>则定义了最近修改时间。<lastmod>支持 YYYY-MM-DDThh:mm:ssTZD, YYYY-MM-DDThh:mmTZD,YYYY-MM-DD格式。

编辑完成这个文件后,将文件按以下语法放到robots.txt文件中。

Sitemap: <your_sitemap_index_file_location>

必须注意的是,这个文件必须是utf-8编码格式。

Comments (0) Posted on Tuesday, March 24th, 2009

下面是PHP, ASP, CGI和RoR的301转向代码写法。如果要验证是否对搜索引擎有效可以通过 http://www.webconfs.com/redirect-check.php 检查

PHP
<?
Header( “HTTP/1.1 301 Moved Permanently” );
Header( “Location: http://www.newdomain.com” );
?>

ASP
<%@ Language=VBScript %>
<%
Response.Status=”301 Moved Permanently”
Response.AddHeader “Location”,”http://www.newdomain.com/”
%>

ASP.NET

CGI/Perl
$q = new CGI;
print $q->redirect(”http://www.newdomain.com/”);

Ruby on Rails
def old_action
headers[”Status”] = “301 Moved Permanently”
redirect_to “http://www.newdomain.com/”
end

Comments (0) Posted on Wednesday, March 18th, 2009

MySQLTuner 是一个简易的Perl脚本,可以对你的MySQL性能进行简易分析,并给出优化建议。执行这个脚本进行优化前,简易MySQL在工作状态下工作24个小时。

先下载执行

debian:/usr/local/bin# wget http://mysqltuner.com/mysqltuner.pl
debian:/usr/local/bin# chmod +x mysqltuner.pl
debian:/usr/local/bin# ./mysqltuner.pl
>>  MySQLTuner 1.0.0 - Major Hayden <major@mhtx.net>
>>  Bug reports, feature requests, and downloads at http://mysqltuner.com/
>>  Run with ‘–help’ for additional options and output filtering
Please enter your MySQL administrative login: root
Please enter your MySQL administrative password:
——– General Statistics ————————————————–
[–] Skipped version check for MySQLTuner script
[OK] Currently running supported MySQL version 5.0.32-Debian_7etch6-log
[OK] Operating on 32-bit architecture with less than 2GB RAM

——– Storage Engine Statistics ——————————————-
[–] Status: +Archive -BDB -Federated +InnoDB -ISAM -NDBCluster
[–] Data in MyISAM tables: 609M (Tables: 3461)
[–] Data in InnoDB tables: 9M (Tables: 185)
[–] Data in MEMORY tables: 213K (Tables: 5)
[!!] Total fragmented tables: 64

——– Performance Metrics ————————————————-
[–] Up for: 2d 16h 7m 39s (4M q [19.375 qps], 64K conn, TX: 1B, RX: 624M)
[–] Reads / Writes: 87% / 13%
[–] Total buffers: 626.0M global + 2.6M per thread (500 max threads)
[!!] Maximum possible memory usage: 1.9G (95% of installed RAM)
[OK] Slow queries: 0% (0/4M)
[OK] Highest usage of available connections: 1% (7/500)
[OK] Key buffer size / total MyISAM indexes: 400.0M/32.2M
[OK] Key buffer hit rate: 99.9% (9M cached / 11K reads)
[OK] Query cache efficiency: 84.4% (3M cached / 4M selects)
[OK] Query cache prunes per day: 0
[OK] Sorts requiring temporary tables: 0% (0 temp sorts / 33K sorts)
[!!] Temporary tables created on disk: 43% (21K on disk / 48K total)
[OK] Thread cache hit rate: 99% (7 created / 64K connections)
[OK] Table cache hit rate: 72% (3K open / 5K opened)
[OK] Open file limit used: 10% (6K/65K)
[OK] Table locks acquired immediately: 99% (835K immediate / 835K locks)
[!!] InnoDB data size / buffer pool: 9.5M/8.0M

——– Recommendations —————————————————–
General recommendations:
Run OPTIMIZE TABLE to defragment tables for better performance
Reduce your overall MySQL memory footprint for system stability
Enable the slow query log to troubleshoot bad queries
When making adjustments, make tmp_table_size/max_heap_table_size equal
Reduce your SELECT DISTINCT queries without LIMIT clauses
Variables to adjust:
*** MySQL’s maximum memory usage is dangerously high ***
*** Add RAM before increasing MySQL buffer variables ***
tmp_table_size (> 32M)
max_heap_table_size (> 16M)
innodb_buffer_pool_size (>= 9M)

最后一个部分给出了优化简易。

Comments (0) Posted on Sunday, March 8th, 2009

maketop.net作为开始试验性的项目。采用zend framework + sphinx完成50万数据的展示和搜索,下一步是将 dojo/jquery引入进来实现product review的功能。目的是找到MVC framework(zend) + ajax framework(dojo/jquery) + template engine(smarty) 的组合之道。

Comments (0) Posted on Tuesday, December 23rd, 2008

补充一点Notepad++的说明。往往第一次用Notepad++会发现缺少文件导航栏,另外代码(函数)自动完成也不是马上有效果。

这里有最全的官方插件 http://sourceforge.net/projects/npp-plugins/ 。 解决导航栏的问题,需要下载 Explorer  插件。并复制到 /plugins/ 目录下。重新启动后在Plugin中选择’explorer’左侧就会自动展现explorer插件。

自动完成在 settings->Backup/Auto-completion中把Enable Auto-completion on each input打开就可以了。下面还有一个涉及函数的Function parameter’s hit on input选上。如果是中文版本找到相对应的参数内容即可。

Comments (0) Posted on Saturday, December 6th, 2008

今天在处理一个客户的服务器的时候,我发现我们的电子商务软件邮件总是不能发送出去邮件或者超时。这台独立主机没有安装任何邮件服务软件,只能依靠外部的SMTP发送邮件。

但是即便设定了正确的SMTP服务器也还是不能发出。最后换了几个SMTP总是这样,于是打开程序的debug状态,根据对代码的最终发现邮件始终收到SMTP 451错误。错误内容很简单“Requested action aborted: local error in processing”。但451之后还带有http://www.spamhaus.org/query/bl?ip=xxx.xxx.40.246的提示。于是猜测这个服务器的ip可能进入了spam监控的名单。依照上面的链接查过去,果然提示该IP被列为spamhaus的PBL之中。好在PBL清单不是绝对spamer的清单,所以在首页提交Remove IP address之后几分钟服务器的ip就从中删除。再测试果然没有再出现451错误。

备注一下,我利用的smtp是ipower的smtp。所以如果有朋友的服务器发现无法利用外部smtp发送邮件,可以考虑是否由于服务器的ip进入了spamhaus.org的清单。

Comments (0) Posted on Monday, November 19th, 2007

    Popular Post

    Most Commented Posts

    Random Posts