2010年11月28日星期日

Bootstraping WordPress/Nginx/PHP/MySQL on a Cheap VPS with lowendscript

One constantly posted question on LowEndBox and LowEndTalk is — how to get the same setup as LowEndBox, a WordPress site that runs on cheap VPS with 80MB of memory? Instead of doing a step-by-step explanation (damn I hate writing long blog posts), I decided to wrap it into a bash script that does it all.

Nginx PHP
WordPress MySQL

It is based on my previous script here, and it has been tested on both Debian 5 "Lenny" and Ubuntu 10.04 "Lucid Lynx". Sorry no other distributions are supported. It is currently hosted at github so feel free to branch it and tune it to your heart's desire.

Usage

Here is a quick step by step on how to set up a WordPress blog running on Nginx, PHP/FastCGI and MySQL on a low end box. Let's assume that you are going to set up a blog on hostname "blog.example.com".

  1. Go and buy a cheap VPS. Yes, you know where to find cheap virtual servers under $7/month, don't you? :) I am using my 6 pound/year RackVM VPS with 128MB memory to test this script, and the performance turns out to be quite good. YMMV.

    Make sure it is either a Debian or a Ubuntu distro though.

  2. After gaining root access to your VPS,

    # wget http://github.com/lowendbox/lowendscript/raw/master/setup-debian.sh
    ...
    # bash setup-debian.sh system
    ...
    # bash setup-debian.sh exim4
    ...
    # bash setup-debian.sh nginx
    ...
    # bash setup-debian.sh mysql
    ...
    # bash setup-debian.sh php
    ...
    # bash setup-debian.sh wordpress blog.example.com
    ...
  3. Now altering your DNS entry to point blog.example.com to your new VPS (or alter your local /etc/hosts entry). Navigate to it from your browser, and you should be presented with WordPress set up page. Fill in your blog's name, admin's password and contact email, and your new WordPress is online!

    Just repeat the last step (running bash setup-debian.sh wordpress <hostname>) to set up more blogs on the same box.

That's it!

Software Stack

It's pretty similar to my own stack that runs LowEndBox.com.

  • dropbear to replace openssh. Invoked from xinetd.
  • inetutils-syslogd to replace rsyslog.
  • exim4 to replace sendmail (if installed). Re-configured to allow Internet delivery.
  • cron
  • nginx
  • mysql. Re-configured to remove innodb support, remove query cache and reduce key buffer size.
  • php with built-in FastCGI interface. Running only 1 child process and respawn after 5,000 requests.

The lowendscript is also

  • Removing some commonly bundled applications that should not be there in the first place for a minimal distro (apache2, sendmail, bind9, samba, nscd, etc).
  • MySQL root is given a new password (which can be found in ~root/.my.cnf)
  • Installing each WordPress site under /var/www/<hostname>. It will create appropriate database, users and password for the site.

I have to say that it is still "work in progress", but if you want to figure out the internals please check the source code of that bash script.

Memory Usage

I am testing the same script on the following 3 systems:

  • Ubuntu 10.04 64bit (RackVM)
  • Debian 5 64bit (RackVM)
  • Debian 5 32bit (VPSGuy)

They are all showing different memory usage. I am taking the snapshot of memory usage AFTER 10 page loads on the WordPress blog that has been created to ensure PHP process is fully loaded.

Ubuntu 10.04 64bit

root@ubuntu64:~# ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.5 23300 1536 ? Ss 06:58 0:00 init
root 10124 0.0 0.5 23576 1496 ? Ss 07:34 0:00 dropbear -i
root 15742 0.0 0.7 17880 1944 pts/0 Ss 07:35 0:00 -bash
root 15754 0.0 0.4 14960 1084 pts/0 R+ 07:35 0:00 ps aux
root 24290 0.0 0.3 12508 788 ? S 07:22 0:00 /usr/sbin/syslo
root 24524 0.0 0.3 21064 1004 ? Ss 07:22 0:00 cron
root 25689 0.0 0.3 19512 972 ? Ss 07:22 0:00 /usr/sbin/xinet
mysql 26346 0.0 4.2 61812 11248 ? Ssl 07:23 0:00 /usr/sbin/mysql
www-data 27920 0.0 2.6 87768 7048 ? Ss 07:23 0:00 /usr/bin/php-cg
www-data 27922 0.5 15.0 122460 39432 ? S 07:23 0:04 /usr/bin/php-cg
103 30162 0.0 0.3 44356 1000 ? Ss 07:24 0:00 /usr/sbin/exim4
root 30267 0.0 0.3 28104 932 ? Ss 07:24 0:00 nginx: master p
www-data 30268 0.0 0.8 28744 2196 ? S 07:24 0:00 nginx: worker p

root@ubuntu64:~# free
total used free shared buffers cached
Mem: 262144 100500 161644 0 0 0
-/+ buffers/cache: 100500 161644
Swap: 0 0 0

Memory Usage: 98.1MB

Debian 5 64bit

debian64:~# ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.2 10304 740 ? Ss 12:22 0:00 init [2]
106 1414 0.0 0.3 42708 1004 ? Ss 12:26 0:00 /usr/sbin/exim4
www-data 1655 0.0 2.5 72028 6560 ? Ss 12:26 0:00 /usr/bin/php-cg
www-data 1657 0.9 11.7 98500 30928 ? S 12:26 0:03 /usr/bin/php-cg
www-data 3126 0.0 0.7 28380 1912 ? S 12:29 0:00 nginx: worker p
root 7668 0.1 0.5 23340 1528 ? Rs 12:31 0:00 dropbear -i
root 7831 0.0 0.6 17472 1716 pts/0 Ss 12:32 0:00 -bash
root 7836 0.0 0.3 14720 980 pts/0 R+ 12:32 0:00 ps aux
root 20169 0.0 0.3 18540 936 ? Ss 12:22 0:00 /usr/sbin/cron
root 24462 0.0 0.2 12236 732 ? S 12:25 0:00 /usr/sbin/syslo
root 25637 0.0 0.3 19256 952 ? Ss 12:25 0:00 /usr/sbin/xinet
root 25694 0.0 0.5 28380 1552 ? Ss 12:25 0:00 nginx: master p
root 32427 0.0 0.2 3872 588 ? S 12:26 0:00 /bin/sh /usr/bi
mysql 32466 0.0 3.0 50420 8124 ? Sl 12:26 0:00 /usr/sbin/mysql
root 32468 0.0 0.2 3772 592 ? S 12:26 0:00 logger -p daemo

debian64:~# free
total used free shared buffers cached
Mem: 262144 61008 201136 0 0 0
-/+ buffers/cache: 61008 201136
Swap: 0 0 0

Memory Usage: 59.6MB

Debian 5 32bit

debian32:~# ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.1 1980 688 ? Ss 23:34 0:00 init [2]
root 14064 0.0 0.1 1704 512 ? S 23:52 0:00 /bin/sh /usr/bi
mysql 14119 0.0 1.7 20056 6968 ? Sl 23:52 0:00 /usr/sbin/mysql
root 14120 0.0 0.1 1628 536 ? S 23:52 0:00 logger -p daemo
www-data 15968 0.0 1.2 16352 4996 ? Ss 23:53 0:00 /usr/bin/php-cg
www-data 15971 0.5 4.7 29436 18576 ? S 23:53 0:01 /usr/bin/php-cg
root 16040 0.0 0.3 2700 1464 ? Rs 23:53 0:00 dropbear -i
root 16119 0.0 0.1 1880 684 ? S 23:44 0:00 /usr/sbin/syslo
root 16133 0.0 0.3 2780 1536 pts/0 Ss 23:54 0:00 -bash
root 17728 0.0 0.2 2352 896 ? Ss 23:45 0:00 /usr/sbin/xinet
www-data 17758 0.0 0.3 5004 1488 ? S 23:54 0:00 nginx: worker p
root 27834 0.0 0.3 4548 1236 ? Ss 23:47 0:00 nginx: master p
root 28146 0.0 0.2 2296 896 pts/0 R+ 23:57 0:00 ps aux
102 32065 0.0 0.2 6104 900 ? Ss 23:49 0:00 /usr/sbin/exim4

debian32:~# free
total used free shared buffers cached
Mem: 262144 44272 217872 0 0 0
-/+ buffers/cache: 44272 217872
Swap: 0 0 0

Memory Usage: 43.2MB

So to put that in summary form

  • Ubuntu 10.04 uses significantly more memory than Debian 5 (PHP5.3/MySQL5.1 vs. PHP5.2/MySQL5.0). So pick your distro wisely and maybe you don't need the latest and greatest if your application does not need it.
  • 32bit also uses quite a bit less than 64bit, running exactly the same version of stack. That pretty much confirms what I posted before.

And hopefully the above script is useful for your next WordPress splog farm :P

VPS Kloxo使用教程(二):安装后必须做的

第一:安装中文语言包:
1.用ssh登陆你的vps
2.进入lang目录
cd /usr/local/lxlabs/kloxo/httpdocs/lang
3.下载语言包
wget http://www.vpsyou.com/wp-content/uploads/2010/02/Kloxo_cn.zip
3 解压语言包
unzip Kloxo_cn.zip
4.访问http://你的IP:7778/ 进行lxadmin语言设置
在Advanced->Appearance->Language里选择Chinese,然后点击update确认.
第二:解决中文网页显示乱码
修改apache的httpd.conf默认编码的设置,如下:
首先用SSH登陆VPS,修改httpd.conf文件
vi /etc/httpd/conf/httpd.conf
查找:AddDefaultCharset
把:AddDefaultCharset UTF8
改为:AddDefaultCharset OFF 或改为 #AddDefaultCharset UTF8
(不只知道怎么用vi?G一下吧)
这样的话,打开页面的时候就会按照网页的编码设置来打开网页。
输入以下命令重启Apache
service httpd restart
第三:删除Kloxo日志(这个得弄一下,要不然没几天你的磁盘就会被日志塞满的)
1.登上ssh
2.在/etc/cron.daily目录下新建cleankloxolog.sh
vi /etc/cron.daily/cleankloxolog.sh
3.编辑cleankloxolog.sh,并输入以下内容
# !/bin/bash
rm -rf /home/admin/_processed_stats/*
rm -rf /home/kloxo/httpd/lighttpd/*
rm -rf /var/log/kloxo/*
rm -f /home/httpd/*/stats/*
然后保存推出.
4.把该文件改为755权限
chmod 755 /etc/cron.daily/cleankloxolog.sh
第四:添加DNS模板
Kloxo有个奇怪的地方就是即使你不使用Kloxo自带的DNS服务器,你也要添加DNS模板,否则你就无法添加域名,这个一定要注意。注解:
1 == DNS模板名,建议使用英文名,无特殊
2 == 网站的IP,这个添加时默认,如果你有多个IP可以下拉选择
3 == 邮寄的IP,这个添加时默认,如果你有多个IP可以下拉选择
4 == 主DNS,如果你想要使用kloxo自带的DNS服务器,请填写正确已注册的dns服务器
5 == 主DNS,如果你想要使用kloxo自带的DNS服务器,请填写正确已注册的dns服务器

VPS Kloxo使用教程(三):优化设置

好多客户反映kloxo安装后内存使用非常厉害,网上搜索了一下,总结了几点kloxo安装后的优化设置:
一,禁用一些服务:如果你不使用kloxo的named来解析域名,不用qmail发邮件,那你可以禁用named和qmail,具体方法:
用putty登陆你的VPS,执行:

service named stop;
chkconfig named off;
service qmail stop;
chkconfig qmail off;
chkconfig courier-imap off;

其实vps也可以禁用iptables的:

service iptables stop;
chkconfig iptables off;

二,优化mysql:

[mysqld]
port = 3306
socket = /var/lib/mysql/mysql.sock
skip-locking
key_buffer = 16K
max_allowed_packet = 1M
table_cache = 4
sort_buffer_size = 64K
read_buffer_size = 256K
read_rnd_buffer_size = 256K
net_buffer_length = 2K
thread_stack = 64K
skip-bdb
skip-innodb

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash
#safe-updates

[isamchk]
key_buffer = 8M
sort_buffer_size = 8M

[myisamchk]
key_buffer = 8M
sort_buffer_size = 8M

[mysqlhotcopy]
interactive-timeout

进入/etc 目录,编辑my.cnf
在[mysqld]下面加入以下三行:
skip-locking
skip-bdb
skip-innodb

ZZ保存之后重启Mysql

命令:

/sbin/service mysqld restart
键入top查看内存占用已经降到100M以下。
命令详解:
使用�skip -locking的MySQL选项避免外部锁定
加载�skip-bdb �skip-innodb参数以避免内存浪

2010年11月27日星期六

网站开发人员应该知道的61件事

作者: 阮一峰

日期: 2010年11月25日

有人在Stack Overflow上发问,动手 开发网站之前,需要知道哪些事情?

不出意料地,他得到了一大堆回答。

通常情况下,你需要把所有人的发言从头到尾读一遍。但是,Stack Overflow有一个很贴心的设计,它允许在问题下方开设一个wiki区,让所有人共同编辑一个最佳答案。于是,就有了下面这篇文章,一共总结出六个方 面共计61条"网站开发须知"。

我发现,这种概述性的问题,最适合这种集合群智、头脑风暴式的回答方式了。这也是我第一次觉得,Stack Overflow做到了Wikipedia做不到的事。(难怪它最近挤进了全美前400大网站。)

在我的印象中,关于网站开发,这样全面的概述性文章非常少见,因此也就非常有用。大家不妨看看,61件事情中你做到了多少?

(更新:刚刚发现,一共应该是62条建议,我先前数错了,这个......太窘了。)

=============================

网站开发人员应该知道的61件事

原文网址:http://stackoverflow.com/questions/72394

译者:阮一峰

一、界面和用户体验(Interface and User Experience)

1.1

知道各大浏览器执行Web标准的情况,保证你的站点在主要浏览器上都能正常运行。你至少要测试以下引擎:Gecko(用 于Firefox)、Webkit(用于SafariChrome和一些手机浏览器)、 IE(你可以利用微软发布的Application Compatibility VPC Images进行测试)和Opera。同时,不同的操作系统,可能也会影响浏览器如何呈现你的网站。

1.2

除了浏览器,网站还有其他使用方式:手机、屏幕朗读器、搜索引擎等等。你应该知道在这些情况下,你的网站的运行状况。MobiForge提供了手机网站开发的一些相关 知识。

1.3

知道如何在基本不影响用户使用的情况下升级网站。通常来说,你必须有版本控制系统(CVS、Subversion、Git等等)和数据备份机制 (backup)。

1.4

不要让用户看到那些不友好的出错提示。

1.5

不要直接显示用户的Email地址,至少不要用纯文本显示。

1.6

为你的网站设置一些合理的使用限制, 一旦超过门槛值,就自动停止服务。(这也与网站安全相关。)

1.7

知道如何实现网页的渐进式增强(progressive enhancement)。

1.8

用户发出POST请求后,总是将其重导向(redirect)至 另外一个网页。

1.9

不要忘记网站的可访问性(accessibility,即残疾人如何使用网站)。对于美国网站来说,有时这是法定要求WAI-ARIA有一些这方面很好的参考资料。

二、安全性(Security

2.1

阅读《OWASP 开发指南》,它提供了全面的网站安全指导。

2.2

了解SQL注入(SQL injection)及其预防方法。

2.3

永远不要信任用户提交的数据(cookie也是用户端提交的!)。

2.4

不要明文(plain-text)储存用户的密码,要hash处理后再储存。

2.5

不要对你的用户认证系统太自信,它可能很容易就被攻破,而你事先根本没意识到存在相关漏洞。

2.6

了解如何处 理信用卡

2.7

在登录页面及其他处理敏感信息的页面,使用SSL/HTTPS

2.8

知道如何对付session劫持(session hijacking)。

2.9

避免"跨站点执行" (cross site scripting,XSS)。

2.10

避免"跨域伪造请求" (cross site request forgeries,XSRF)。

2.11

及时打上补丁,让你的系统始终跟上最新版本。

2.12

确认你的数据库连接信息的安全性。

2.13

跟踪攻击技术的最新发展,以及你使用的平台的最新安全漏洞。

2.14

阅读Google的《浏览器安全手册》(Browser Security Handbook)。

2.15

阅读《网络软件的黑客手册》(The Web Application Hackers Handbook)。

三、性能(Performance)

3.1

只要有可能,就使用缓存(caching)。正确理解和使用HTTP cachingHTML5离线储存

3.2

优化图片。不要把一个20KB的图片文件,作为重复出现的网页背景图案。

3.3

学习如何用gzip/deflate 压缩内容(deflate 方式更可取)。

3.4

将多个样式表文件或脚本文件,合为一个文件,这样可以减少浏览器的http请求数,以及减小gzip压缩后的文件总体积。

3.5

浏览Yahoo的Exceptional Performance网 站,里面有大量提升前端性能的优秀建议,还有他们的YSlow工具。Google的page speed则是另一个用来分析网页性能的工具。两者都要求安装Firebug

3.6

如果你的网页用到大量的小体积图片(比如工具栏),就应该使用CSS Image Sprite,目的是减少 http请求数。

3.7

大流量的网站应该考虑将网页对象分散在多个 域名(split components across domains)。

3.8

静态内容(比如图片、CSS、JavaScript、以及其他cookie无关的网页内容)都应该放在一个不 需要使用cookie的独立域名之上。因为域名之下如果有cookie,那么客户端向该域名发出的每次http请求,都会附上cookie内容。 这里的一个好方法就是使用"内容分发网络"(Content Delivery Network,CDN)。

3.9

将浏览器完成网页渲染所需要的http请求数最小化。

3.10

使用Google的Closure Compiler压缩 JavaScript文件,YUI Compressor亦可。

3.11

确保网站根目录下有favicon.ico文件,因为即使网页中根本不包括这个文件,浏览器也会自动发出对它的请求。所以如 果这个文件不存在,就会产生大量的404错误,消耗光你的服务器的带宽。

四、搜索引擎优化(Search Engine Optimization,SEO)

4.1

使用"搜索引擎友好"的URL形式,比如example.com/pages/45-article-title,而不是example.com /index.php?page=45。

4.2

不要使用"点击这里"之类的超级链接,因为这样等于浪费了一个SEO机会,而且降低了"屏幕朗读器"(screen reader)的使用效果。

4.3

创建一个XML sitemap文 件,它的缺省位置一般是/sitemap.xml(即放在网站根目录下)。

4.4

当你有多个URL指向同一个内容时,在网页代码中使用<link rel="canonical" ... />

4.5

使用Google的Webmaster Tools和Yahoo的Site Explorer

4.6

从一开始就使用Google Analytics(或者开源的访问量分析工具Piwik)。

4.7

知道robots.txt的 作用,以及搜索引擎蜘蛛的工作原理。

4.8

www.example.com的访问请求导向example.com(使用301 Moved Permanently重定向),或者采用相反的做法,目的是防止Google把它们当做两个网站,分开计算排名。

4.9

知道存在着恶意或行为不正当的网络蜘蛛。

4.10

如果你的网站有非文本的内容(比如视频、音频等等),你应该参考Google的sitemap 扩展协议

五、技术(Technology)

5.1

理解HTTP协 议,以及诸如GET、POST、sessions、cookies之类的概念,包括"无状态"(stateless)是什么意思。

5.2

确保你的XHTML/HTMLCSS符合W3C标准,使得它们能够通过检验。这可以使你的网页避免触发浏览器的古 怪行为(quirk),而且使它在"屏幕朗读器"和手机上也能正常工作。

5.3

理解浏览器如何处理JavaScript脚本。

5.4

理解网页上的JavaScript文件、样式表文件和其他资源是如何装载及运行的,考虑它们对页面性能有何影响。在某些情况下,可能应该将脚本文件放 置在网页的尾部

5.5

理解JavaScript沙箱(Javascript sandbox)的工作原理,尤其是如果你打算使用iframe。

5.6

知道JavaScript可能无法使用或被禁用,以及Ajax并不是一定会运行。记住,"不允许脚本运行"(NoScript)正在某些用户中变得 流行,手机浏览器对脚本的支持千差万别,而Google索引网页时不运行大部分的脚本文件。

5.7

了解301重定向和302重定向之间的区 别(这也是一个SEO相关问题)。

5.8

尽可能多得了解你的部署平台(deployment platform)。

5.9

考虑使用样 式表重置(Reset Style Sheet)。

5.10

考虑使用JavaScript框架(比如jQueryMooToolsPrototype),它们可以使你 不用考虑浏览器之间的差异。

六、解决bug

6.1

理解程序员20%的时间用于编码,80%的时间用于维护,根据这一点相应安排时间。

6.2

建立一个有效的错误报告机制。

6.3

建立某些途径或系统,让用户可以与你接触,向你提出建议和批评。

6.4

为将来的维护和客服人员撰写文档,解释清楚系统是怎么运行的。

6.5

经常备份!(并且确保这些备份是有效的。)除了备份机制,你还必须有一个恢复机制。

6.6

使用某种版本控制系统储存你的文件,比如SubversionGit

6.7

不要忘记做单元测试(Unit Testing),Selenium之类的框架会对你有用。

(完)

2010年11月24日星期三

如何在winxp/win7下建立vpn连接

大家好,现在教大家如何在winXP和win7(vista)下设置vpn连接。

winXP

1. 单击"开始",然后单击"控制面板",再在"控制面板"中双击"网络连接"或是右键桌面的"网上邻居" > "属性"。如图

2.点击左侧"网络任务"中的"创建一个新的连接"。如图

3.单击"下一步",选择"连接到我的工作场所的网络",下一步。如图

4.选择"虚拟专用网络连接",下一步。如图

5.这里的公司名可以随便输的,输入个容易记的吧。如图

6.选择"不拨初始连接",下一步。如图

7.这里的"主机名或是IP地址"写上VPN服务器的地址,可以是域名也可以是IP,请点击这里查看服务器列表.以美国服 务器为例:us02.lonlife.net如图。一定要注意这里只能添加域名或是ip,不能加服务器后的端口。如 us02.lonlife.net:1012.这里只写us02.lonlife.net就行了,后面的:1012绝对不能加。

8.选择"不使用我的智能卡",下一步。如图

9.这里勾上"在我的桌面上添加一个到此连接的快捷方式"。点"完成"连接就建好了。如图。还没完!!!!!继续往下看,取消数据加密。

10.取消数据加密。在用户名和密码里分别填上登陆用的用户名和密码,勾上"为下面用户保存用户名和密码"并选择"只是我"。这样会方便很多,以后 需要上代理直接点连接就行了。如图,打开虚拟连接后,点击"属性"。

11.一般情况这样的vpn就能用了,不过呢,登陆我们的代理会报错742,这里还要进行一些小小的设置,点"属性"> "安全",这里要取消"要求数据加密"前面的勾。大功告成。点"确定"保存设置即可。如图。如果使用时报错619的话还要继续往下看。

12.如果没有报错619的话则不要使用l2tp,这种模式现在已经不再提供支持。启用l2tp连接,l2tp 是一种兼容模式非常强的vpn模式,如果拨号时出现报错619,则请使用l2tp连接vpn服务器,双击刚刚新建的放在桌面上的vpn连接或是对"网上邻 居"点右键 > "属性",再双击刚刚建立的vpn连接,接着点"属性"。如图

13.再点"网络",在"VPN类型"下选择"L2TP IPSec VPN"再点确定就行了。如图

14.还没完,单击这 里下载l2tp补丁(仅针对winxp),然后导入注册表。导入完成后需要重启一下电脑,然后再选择l2tp就能连接vpn了。如果在网吧这类有 还原卡的地方呢?重启了什么就都没有了。这时需要下载下我们的vpn客户端,然后随便输入个账号密码,勾上"l2tp模式",再 点"启用连接",系统会询问是否要强制启用l2tp?这点一定要点"取消"进行强制启用l2tp。稍等片刻,程序会提示"找不到电话本",不用管它,点了 "确定"后,退出我们的vpn客户端。再启用刚刚建立的虚拟连接,然后使用l2tp连接就行了。如图

win7/Vista

win7和Vista差别不大,这里用英文版win7做演示。

1.单击左下角的"Start"(开始) > "Control Panel"(控制面版).如图

2.双击"Network and Sharing Center"(网络连接).如图

3.双击"Set up a new connection or network"(创建一个新连接).如图

4.双击"Connect to a workplace"(连接到工作场所).如图

5.单击"No,create a new connect"(创建一个新连接),"Next"(下一步).右以前未建立过vpn连接,则不会有此选项.也就是有可能在建立vpn时不会有此提示.如 图

6.双击"Use my Internet Connection(VPN)"(使用我的internet连接).如图

7.出现下面这个提示主要是因为我这里没有联网,系统问在创建VPN前是不是要先创建到Internet的连接,意思就是说,要创建VPN连接需要 先上网,你现在没上网,先设置下如何上网吧,如果大家在联网环境,则不会出现此提示.这里选择"I'll set up a Internet connection later"(稍后设置Internet连接).如图

8.这里的"Internet address"是指要VPN服务器的地址,下面的"Destination name"就是此连接的名字,跟XP一样,写上容易记的吧.至于下面的"Use a smart card"和"Allow other people to use this connection"可以不用选,意思是使用智能卡和允许别人共享此连接.不用选了.Next(下一步)如图

9.在这里分别输入用户名和密码,并选上"Remember this password"(记住密码),再单击"Create"(创建),VPN连接就创建好了.

10.跟XP一样,win7/Vista也需要设置为可选加密.方法是进入"Control Panel"(控制面版),双击"Network and Sharing Center"(网络连接),然后双击"Connect to a network"(连接至网络).如图

11.此时右下角会出现一个选择连接的窗口,对刚才创建的"lonlife"点右键 > "Properties"(属性).如图

12.打开后,选择"Security"(安全),在"Date encryption"(数据加密)内选择"Optional encryption(connect even if no encryption)"(可选加密,无加密也连接),单击"OK"确定退出.如图

13.单击桌面右下角的"Network and Sharing Center",再单击lonlife下面的"connect"即可.如图

Kloxo Lighttpd伪静态收集

Discuz!X
url.rewrite = (
"^/topic-(.+)\.html$" => "/portal.php?mod=topic&topic=$1",
"^/article-([0-9]+)\.html$" => "/portal.php?mod=article&articleid=$1",
"^/forum-(\w+)-([0-9]+)\.html$" => "/forum.php?mod=forumdisplay&fid=$1&page=$2",
"^/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$" => "/forum.php?mod=viewthread&tid=$1&extra=page=$3&page=$2",
"^/group-([0-9]+)-([0-9]+)\.html$" => "/forum.php?mod=group&fid=$1&page=$2",
"^/space-(username|uid)-(.+)\.html$" => "/home.php?mod=space&$1=$2",
"^/([a-z]+)-(.+)\.html$" => "/$1.php?rewrite=$2"
)


PHPWind
url.rewrite = ("^(.*)-htm-(.*)$" => "$1.php?$2")

WordPress
url.rewrite = (
"^/(wp-.+).*/?" => "$0",
"^/(sitemap.xml)" => "$0",
"^/(xmlrpc.php)" => "$0",
"^/(.+)/?$" => "/index.php/$1"
)

Discuz 6.0/6.1/7.0/7.1/7.2
url.rewrite-once = (
"^/archiver/((fid|tid)-[\w\-]+\.html)$" => "archiver/index.php?$1",
"^/forum-([0-9]+)-([0-9]+)\.html$" => "forumdisplay.php?fid=$1&page=$2",
"^/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$" => "viewthread.php?tid=$1&extra=page=$3&page=$2",
"^/space-(username|uid)-(.+)\.html$" => "space.php?$1=$2",
"^/tag-(.+)\.html$" => "tag.php?name=$1"
)

dede标签大全

{dede:global.cfg_webname/} 站点名称

{dede:global.cfg_basehost/} 站点url(后台设置)

{dede:global.cfg_cmsurl/} 站点实际url(奇奇推荐)

{dede:global.cfg_memberurl/} 会员中心地址

{dede:global.cfg_dataurl/} 站点data目录地址

{dede:global.cfg_templeturl/} 模板目录地址

{dede:global.cfg_powerby/} 底部版权

{dede:global.cfg_beian/} 备案信息

{dede:field.description function='html2text(@me)'/} 站点描述

{dede:field.phpurl/} 站点plus目录站点地址

{dede:field.title/} 标题

{dede:field.keywords/} 关键字

{dede:flink row='24'/}友情链接

{dede:field.content/} 栏目内容

{dede:field.position/} 当前位置

{dede:field.pubdate function="MyDate('Y-m-d H:i',@me)"/} 时间

{dede:field.source/} 来源

{dede:field.writer/} 作者

<script src="{dede:field name='phpurl'/}/count.php?view=yes&aid={dede:field name='id'/}&mid={dede:field name='mid'/}" type='text/javascript' language="javascript"></script> 点击次数

{dede:field.body/} 文章内容

{dede:adminname/} 责任编辑

{dede:pagebreak/} 页码

{dede:prenext get='pre'/} 上一篇

{dede:prenext get='next'/} 下一篇

导航

 {dede:channel type='self' currentstyle="<span><a href='~typelink~' class='thisclass'>~typename~</a></span>"}

  <span><a href='[field:typeurl/]'>[field:typename/]</a></span>{/dede:channel}

{dede:include filename="*.htm"/} 调用模板文件

{dede:memberinfos}

<a href="[field:spaceurl /]" class="userface"><img src="[field:face/]" width="52" height="52" /></a> 头像

<a href='[field:spaceurl /]' class="username">[field:uname/]</a> 用户名

<a href="[field:spaceurl /]" class="useract-vi">查看详细资料</a>

<a href="[field:spaceurl /]&action=guestbook" class="useract-pm">发送留言</a>

<a href="[field:spaceurl /]&action=newfriend" class="useract-af">加为好友</a>

用户等级:</small>[field:rankname /]

注册时间:</small>[field:jointime function="MyDate('Y-m-d H:m',@me)"/]

最后登录:</small>[field:logintime function="MyDate('Y-m-d H:m',@me)"/]

{/dede:memberinfos}

{dede:global.cfg_webname/} 站点名称

{dede:global.cfg_basehost/} 站点url(后台设置)

{dede:global.cfg_cmsurl/} 站点实际url(奇奇推荐)

{dede:global.cfg_memberurl/} 会员中心地址

{dede:global.cfg_dataurl/} 站点data目录地址

{dede:global.cfg_templeturl/} 模板目录地址

{dede:global.cfg_powerby/} 底部版权

{dede:global.cfg_beian/} 备案信息

{dede:field.description function='html2text(@me)'/} 站点描述

{dede:field.phpurl/} 站点plus目录站点地址

{dede:field.title/} 标题

{dede:field.keywords/} 关键字

{dede:flink row='24'/}友情链接

{dede:field.content/} 栏目内容

{dede:field.position/} 当前位置

{dede:field.pubdate function="MyDate('Y-m-d H:i',@me)"/} 时间

{dede:field.source/} 来源

{dede:field.writer/} 作者

<script src="{dede:field name='phpurl'/}/count.php?view=yes&aid={dede:field name='id'/}&mid={dede:field name='mid'/}" type='text/javascript' language="javascript"></script> 点击次数

{dede:field.body/} 文章内容

{dede:adminname/} 责任编辑

{dede:pagebreak/} 页码

{dede:prenext get='pre'/} 上一篇

{dede:prenext get='next'/} 下一篇

导航

 {dede:channel type='self' currentstyle="<span><a href='~typelink~' class='thisclass'>~typename~</a></span>"}

  <span><a href='[field:typeurl/]'>[field:typename/]</a></span>{/dede:channel}

{dede:include filename="*.htm"/} 调用模板文件

{dede:memberinfos}

<a href="[field:spaceurl /]" class="userface"><img src="[field:face/]" width="52" height="52" /></a> 头像

<a href='[field:spaceurl /]' class="username">[field:uname/]</a> 用户名

<a href="[field:spaceurl /]" class="useract-vi">查看详细资料</a>

<a href="[field:spaceurl /]&action=guestbook" class="useract-pm">发送留言</a>

<a href="[field:spaceurl /]&action=newfriend" class="useract-af">加为好友</a>

用户等级:</small>[field:rankname /]

注册时间:</small>[field:jointime function="MyDate('Y-m-d H:m',@me)"/]

最后登录:</small>[field:logintime function="MyDate('Y-m-d H:m',@me)"/]

{/dede:memberinfos}

<a href="{dede:field name='phpurl'/}/stow.php?aid={dede:field.id/}" target="_blank">收藏</a>

<a href="{dede:field name='phpurl'/}/erraddsave.php?aid={dede:field.id/}&title={dede:field.title/}" target="_blank">挑错</a>

<a href="{dede:field name='phpurl'/}/recommend.php?aid={dede:field.id/}" target="_blank">推荐</a>

<a href="#" onClick="window.print();">打印</a>

文档列表

{dede:arclist titlelen=42 row=10}

           <li><a href="[field:arcurl/]">[field:title/]</a>

             <p>[field:description function='cn_substr(@me,80)'/]...</p>

            </li>{/dede:arclist}

文档列表

{dede:arclist titlelen=42 row=10}

           <li><a href="[field:arcurl/]">[field:title/]</a>

             <p>[field:description function='cn_substr(@me,80)'/]...</p>

            </li>{/dede:arclist}

Lighttpd Module : Rewrites 使用详解

原文地址: http://redmine.lighttpd.net/wiki/1/Docs:ModRewrite
h1. URL Rewrites
*Module: mod_rewrite*
h2. Description
     [描述]
internal redirects, url rewrite
内部从定向,URL重写

h2. Options
        [选项]
h3. url.rewrite-once

Rewrites a set of URLs internally in the webserver BEFORE they are handled.[在URL设置被处理之前,在webserver服务器内部重写这个URL,只匹配一次]

e.g.

<pre>
url.rewrite-once = ( "<regex>" => "<relative-uri>" )
(说明:在上面的语句中, <regex> 代表正则表达式部分, <relative-uri>代表被替换或处理的文本部分,也就是说,凡是URL设置中,符合<regex>部分正则表达式部分 的字符串会被后面的<relative-uri>替换, 这个有点向javascript 字符串处理,其中url.rewrite-once,表示URL字符对象本身。)
</pre>

h3. url.rewrite-repeat

Rewrites a set of URLs internally in the webserver BEFORE they are handled
[解释如上, 本语句进行多次重复处理,也就是多次寻找负责正则表达式设置规则的字符串,并进行替换。]
e.g.

<pre>
url.rewrite-repeat = ( "<regex>" => "<relative-uri>" )
(解释如上)
</pre>

The difference between these options is that, while url.rewrite-repeat allows for applying multiple (seperately defined) rewrite rules in a row, url.rewrite-once will cause further rewrite rules to be skipped if the expression was matched. As such, url.rewrite-once behaves like Apaches' RewriteRule ... [L]: http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewriterule
[以上两个选项的区别在于url.rewrite-repeat 允许在一行中进行多次URL重写,而url.rewrite-once 只能重写一次,其它匹配重写规则会跳过,只有第一次生效。例如:url.rewrite-once行为类似Apaches 的 RewriteRule,呵呵,这里言下之意,就是url.rewrite-repeat是lighttpd的独特之处了。]

The options @url.rewrite@ and @url.rewrite-final@ were mapped to @url.rewrite-once@ in 1.3.16.
[url.rewrite和url.rewrite-final 在1.3.16的url.rewrite-once中说明。]

*{color:red}NOTE: url rewriting does not work within a $HTTP["url"] conditional.* [http://forum.lighttpd.net/topic/1092#3028]
[ 注释: url rewriting 在$HTTP['url']情况下无效。 ]


h2. Regular Expressions
    [正则表达式]

* Patterns ("wildcards") are matched against a string
  模式("通配符")被用来陪陪一个字符串
* Special characters (see [http://www.regular-expressions.info/reference.html] for reference):
  特殊字符请参考: http://www.regular-expressions.info/reference.html  , (这个网站似乎是正则表达式官方网站,看来lighttpd正则表达式很规范。)
** . (full stop) - match any character 匹配任何字符
** \* (asterisk) - match zero or more of the previous symbol匹配零或多个符号
** \+ (plus) - match one or more of the previous symbol匹配一个或多个前面的符号
** ? (question) - match zero or one of the previous symbol匹配零个或一个前面的符号
** \\? (backslash-something) - match special characters匹配一个特殊字符
** ^ (caret) - match the start of a string匹配一个字符串开始
** $ (dollar) - match the end of a string匹配一个字符串结束
** [set] - match any one of the symbols inside the square braces.匹配方括号内的任意一个字符
** [^set] - match any symbol that is NOT inside the square braces.匹配任何一个不再这个括号内的字符
** (pattern) - grouping, remember what the pattern matched as a special variable 子查询
** {n,m} - from n to m times matching the previous character (m could be omitted to mean >=n times) 匹配n到m次。
** (?!expression) - match anything BUT expression at the current position. Example: @"^(/(?!(favicon.ico$|js/|images/)).*)" => "/fgci/$1"@
      匹配当前位置的任何一个符号

* Normal alphanumeric characters are treated as normal
  正常的字母和数字还保持原样

h3. Replacement Patterns 替换模式

If the matched regex contains groups in parentheses, $1..$9 in the replacement refer to the captured text in the
matching group "$1" meaning the first group, "$2" the second, and so on.
如果匹配的正则中包括子集,那么$1--$9所在的位置会被替换成扑获到的文本,在匹配的子集中$1表似乎第一个子集,$2表示第二个子集,以此类推。

Note that % replacements (like %1, %2, %0, etc.) in url.rewrite-* targets are permitted, but do *not* have the meaning they would have in evhost.path-pattern.  If url.rewrite-* is specified within a regex conditional, % patterns are replaced by the corresponding groups from the condition regex.  %1 is replaced with the first subexpression, %2 with the second, etc.  %0 is replaced by the entire substring matching the regexp.  See below for an example using "%0".
注释: %替换符,(例如%1,%2,%0等等) 在url.rewrite-*选项中是许可的,但是这并不意味着可以在evhost.path-pattern模式中许可。如果 url.rewrite-*是通过正则表达式指定的,%模式被相应的正则自己所替换。%1被第一个子集替换,%2被第二个子集替换,依次类推。%0被整个 的字符串替换,下面是一个用%0的例子。

h2. Examples例子

The regex is matching the full REQUEST_URI which is supplied by the user including
query-string.
正则表达式匹配全部用户提交的REQUEST_URI,包括查询字符串(query-string:a=123&b=234).

<pre>
# the following example, is, however just simulating vhost by rewrite
# * you can never change document-root by mod_rewrite
# use mod_*host instead to make real mass-vhost
下面的例子描述了怎样可以通过重写来模拟虚拟域名,这样你不再需要通过mod_rewrite模块修改document-root参数参数,通过mod_*host来代替产生一个真实的虚拟主机集群。

server.document-root = "/www/htdocs/"
$HTTP["host"] =~ "^.*\.([^.]+\.com)$" {
  url.rewrite-once = ( "^/(.*)" => "/%0/$1" )
}

# request:        http://any.domain.com/url/
# before rewrite: REQUEST_URI="/www/htdocs/url/"
# and DOCUMENT_ROOT="/www/htdocs/" %0="any.domain.com" $1="url/"
# after rewrite:  REQUEST_URI="/www/htdocs/any.domain.com/url/"
# still, you have DOCUMENT_ROOT=/www/htdocs/
注释:通过上面的实例可以看出,重写模块url.rewrite-* 是在url被服务器执行之前所调用的,因此我猜测lighttpd 的WEB服务器是有事件管理的,通过事件管理来增强服务器性能。
     url.rewrite-*的事件顺序是,REQUEST_URL被扑获后,和被正式处理前的这一段时间执行。可以通过url.rewrite-once('.*'=>"/%0");获取完成的URL字符串,输出%0就可以了。
         个人猜想url这个模块应该有办法可以直接输出url字符,进行一些常规的字符串判断或处理。

# please note, that we have two regular expressions: the one which
# $HTTP["host"] is been compared with, and the one of the rewrite rule.
# the numbered subexpressions available to build the relative uri are
# being prefixed by '%' for subexpressions of the first regular expression
# match and by '$' for subexpressions of the second one.
# subexpression 0 interpolates the whole matching string: %0 for the whole
# string matching the conditional, and $0 for the whole string matching the
# rewrite rule.
请注意,我们有两个正则表达式,$HTTP['host']被匹配的是第一个。能够用来建立相关URI的数字化表达式由‘%’作为前缀,这个数字化的表达 式是作为第一个正则表达式的子表达式。第二个是用‘$’作为前缀。   第一个正则表达式,由‘%’作为前缀,数字化的表示方式,例如(%1,%2 ...)能够用来建立相关的URI,表达式0(%0或$0)包含了整个匹配的字符串。


# if the rewrite rule is not included in a conditional
# block, only the '$' prefixed variables are available.
如果rewrite rule(重写规则)没有被包含在一个条件代码块内,只有'$'作为前缀的变量是有效的。所谓代码块,指被大括号‘{’和‘}’包围着的一段代码,这里看起来有点局部变量的意思。
也就是在局部范围内%是有效的变量前缀,在全局范围内$是有效的变量前缀。
(附加注释:在lighttpd的evhost模块中有说明,$1-$5是REQUEST_URL的指定变量,分别表示一个REQUEST_URL的不同部分,即使$HTTP['host']=~"正则表达式"{},$1-$5的内并并没有被改变
   ,在上面的实例中可以看到$1代表的是"url/"部分,因此$1-$5和全局变量是有区别的,而下面的正则表达式通过$1、$2....这样的形式来提取正则表达式子集匹配,那么这个是否会和全局$1-$5的定义冲突?)
url.rewrite-once = ( "^/id/([0-9]+)$" => "/index.php?id=$1",
                     "^/link/([a-zA-Z]+)" => "/index.php?link=$1" )

</pre>

h3. With mod_redirect 重定向模块

Rewrite rules always execute before redirect rules. This is true regardless of the order of module loading or the order of rules in the configuration (lighttpd v1.4.13). However, mod_rewrite provides a mechanism to pass URLs through unmangled: specify "$0" as the rule target.
重写规则允许在重定向之前执行,忽视模块导入请求和配置规则是一个事实。但是,重写模块提供了一个机制,通过unmangled来传递URL,指定的"$0"作为规则的目标.

e.g.

<pre>
url.rewrite-once = (
    "^/foo"  => "$0",
    "^/(.*)" => "/handler/$1"
)

url.redirect = (
    "^/foo"  => "http://foo.bar/"
)
</pre>
h3. Workaround for "File name too long" on Windows
在windows工作环境下,文件明太长的问题

While running Lighttpd on Windows you may get @500 Internal Server Error@ if computed filename is longer than 255 symbols.
In error log it will be @(response.c.537) file not found ... or so:  File name too long /very_looooong_path ->@.
As workaround you can use @mod_rewrite@ to avoid this error.
当在windows下运行Lighttpd时,如果文件名长度大于225个字符,也许你会获得 @500 Internal Server Error@ 服务器错误,在错误日志中,这个记录是@(response.c.537)
文件没有找到,或着,文件名太长等等,在这个情况下,你可以通过mod_rewrite来避免这个问题。

<pre>
server.modules += ("mod_rewrite")
url.rewrite-once = ( ".{250,}" => "/toolong.php" )
</pre>

If error handler is PHP, @$_SERVER['REQUEST_URI']@ will contain full URI.
如果由PHP来处理这个错误,那么$_SERVER['REQUEST_URI']会包含全部的URI。

h3. Passing / Matching the Query string (GET variables)

If you wanna pass the Query String (?foo=bar) to the rewrite destination you have to explicitly match it:
如果你想通过rewrite功能来传递query-string,你必须明确匹配。

<pre>
url.rewrite-once = (
    "^/news/([^\?]+)(\?(.*))?" => "/news.php?title=$1&$3"
)
</pre>

2010年11月23日星期二

[linux服务器] 监控系统的平均负载

为什么要监控系统的平均负载?
     有时我们会感觉到系统响应很慢,但是又找不到原因,这时要查平均负载,是否有大量的进程在排队等待  
1,平均负载是什么?
           特定时间间隔内运行队列中的平均进程数,好象还不够明白:就是进程队列的长度,有多少个进程在排队等待运行
2,什么是"进程队列"?
           一个进程满足以下条件就会位于进程队列中
                  1,它没有在等待I/O操作的结果
                  2,它没有主动进入等待状态(即没有调用wait)
                  3,它没有被停止
3,如何查看平均负载?
  最简单的命令是uptime
  例子:
  [lhd@localhost ~]$ uptime
  00:44:22 up  1:17,  3 users,  load average: 8.13, 5.90, 4,94
4,显示的内容是什么意思?
          load average:    8.13,5.90,4,94
          显示的是过去的1,5,15分钟内进程队列中的平均进程数量
5,如何衡量当前系统是否负载过高?
        如果每个cpu(可以按CPU核心的数量计算)上当前活动进程数不大于3,则系统性能良好,
        不大于4,表示可以接受
        如大于5,则系统性能问题严重
        上面例中的8.13,如果有2个cpu核心,则8.13/2=4.065,   此系统性能可以接受
        建议设置严格的报警值为: CPU核心的数量
        比如:CPU核心数量为2,则设置报警值为2
        (这样设置是合理的,因为毕竟不是每个应用都支持多CPU及多核心)
6,查看平均负载的命令
                 有5个可用:
                 tload    能够绘制出负载变化的图形
                 uptime   同时显示开机以来的时间
                 w        同时显示出已登录的用户
                 top      这个对资源占用太高,不建议使用
                 cat /proc/loadavg   通过/proc系统信息得到平均负载
注意:如果你要持续的观察平均负载,建议用 watch uptime  或 watch cat /proc/loadavg
备注:关于watch:每隔一定时间执行指定的程序,并全屏显示结果。时间默认是2秒

--------------------------------------------------------------------

uptime

这个uptime外壳命令产生下列输出:

[pax:~]% uptime
9:40am up 9 days, 10:36, 4 users, load average: 0.02, 0.01, 0.00

它显示自从上次系统重启以来,活动的用户进程数量和所谓的平均负荷指标(load average)。

procinfo

在Linux系统上,procinfo命令产生以下输出:

[pax:~]% procinfo
Linux 2.0.36 (root@pax) (gcc 2.7.2.3) #1 Wed Jul 25 21:40:16 EST 2001 [pax]

Memory: Total Used Free Shared Buffers Cached
Mem: 95564 90252 5312 31412 33104 26412
Swap: 68508 0 68508

Bootup: Sun Jul 21 15:21:15 2002 Load average: 0.15 0.03 0.01 2/58 8557
...

平均负载指标出现在这个输出的左下角。

w

w(ho)命令产生下列输出:

 [pax:~]% w
  9:40am  up 9 days, 10:35,  4 users,  load average: 0.02, 0.01, 0.00
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
mir ttyp0 :0.0 Fri10pm 3days 0.09s 0.09s bash
neil ttyp2 12-35-86-1.ea.co 9:40am 0.00s 0.29s 0.15s w
...

请注意,第一行的输出与uptime命令的输出相同。

top

top命令是最近加入到UNIX命令集中的,它通过计算进程消耗CPU的时间来给进程排名。它产生下列输出:

  4:09am  up 12:48,  1 user,  load average: 0.02, 0.27, 0.17
58 processes: 57 sleeping, 1 running, 0 zombie, 0 stopped
CPU states: 0.5% user, 0.9% system, 0.0% nice, 98.5% idle
Mem: 95564K av, 78704K used, 16860K free, 32836K shrd, 40132K buff
Swap: 68508K av, 0K used, 68508K free 14508K cched

PID USER PRI NI SIZE RSS SHARE STAT LIB %CPU %MEM TIME COMMAND
5909 neil 13 0 720 720 552 R 0 1.5 0.7 0:01 top
1 root 0 0 396 396 328 S 0 0.0 0.4 0:02 init
2 root 0 0 0 0 0 SW 0 0.0 0.0 0:00 kflushd
3 root -12 -12 0 0 0 SW< 0 0.0 0.0 0:00 kswapd
...

所有这些命令,请注意,输出中都有三个数字报告平均负载。相当普遍的是,这些数字显示出从左至右的降序但是有时,又是升序排列,正如上面的输出。

2010年11月15日星期一

CentOS 5.5硬盘安装方法详解

CentOS ― 全名为"社区企业操作系统"(Community Enterprise Operating System)。CentOS 是 RHEL(Red Hat Enterprise Linux)源代码再编译的产物,而且在 RHEL 的基础上修正了不少已知的 Bug ,相对于其他 Linux 发行版,其稳定性值得信赖,CentOS就是Redhat的AS/ES/WS的免费版本。使用CentOS,可以获得和AS/ES/WS相同的性能和感 受。CentOS的最新版本是CentOS5.5,是RHEL 5.5的再编译版本,相对于以前版本有着更加强大的功能。
下面介绍entOS 5.5硬盘安装方法详解(假定电脑上C盘已经安装了windows xp):

一、资料备份:
经常备份资料,是一种很好的习惯。假定windows xp系统下的硬盘分区为:C盘、D盘、E盘、F盘,其中C盘安装的是windows xp系统,这里我们把CentOS5.5安装到最后一个硬盘分区(F盘,当然也可以安装到其它分区,不过后面会出问题,这里不建议安装到其它分区。这里强 调安装到硬盘的最后一个分区上,当然该分区不能太小)。所以,我们要把F盘里有用的资料备份到其它地方,并且建议用windows xp磁盘管理工具(在计算管理中)把硬盘的最后一个分区(F盘)删掉。

二、下载资料:
1、下载CentOS-5.5-i386-bin-DVD.iso
下载地址:http://blog.zhsrf.com/centos-5-5%e6%ad%a3%e5%bc%8f%e7%89%88%e5%8f %91%e5%b8%83%e5%8f%8a%e4%b8%8b%e8%bd%bd%e5%9c%b0%e5%9d%80/
建议下载DVD镜像(找到较近、较快的镜像下载),下载完后,建议校核文件(安装时再校核也可以),保存CentOS-5.5-i386-bin- DVD.iso到硬盘的fat分区,这里放到D盘根目录下(D:\,D盘是fat32文件系统,不要修改文件名);
2、下载grub for dos
http://download.gna.org/grub4dos/下载最新版的grub文件,下载完后,也保存到D盘根目录下;
3、备份资料
这两个文件以后可能还要用到,如:重装CentOS等。建议一直保存在D盘根目录下。

三、准备安装:
1、将grub4dos-0.4.4-2009-03-07.zip里面的grldr文件提取(复制)出来,保存到C盘根目录下,也就是C:\;
2、将CentOS-5.5-i386-bin-DVD.iso下的isolinux文件夹里面的vmlinuz和initrd.img提取出来,保存到 C盘根目录;
3、修改 C:\boot.ini 文件,在 [operating systems] 区域(该文件最后面)加上:C:\grldr="Grub Boot"。(也可以通过右击我的电脑-属性-高级-设置-编辑中修改)。

四、正式安装:
1、重启系统,选择Grub Boot启动选项,按 c 键进入 grub 的 commandline(命令行);
2、在grub>提示符后输入:kernel (hd0,0) /vmlinuz 然后回车,(注意:/前面有个空格);
3、在grub>提示符后输入:initrd (hd0,0) /initrd.img 然后回车,(注意:/前面有个空格);
4、在grub>提示符后输入:boot 然后回车。其中(hd0,0)指第一块硬盘的第一分区,下面的hda5指D盘;
5、进入 CentOS5.2的安装界面, CentOS5.2 会问用什么介质安装,这里选择硬盘安装,并指定hda5,回车;
6、进入正式安装界面,直接回车,启动安装向导。按照向导一步一步来(可选中文语言),安装过程省略。

五、安装后处理
1、进入CentOS5.2后,修改grub.conf文件:
a、注释掉hiddenmenu,在其前面加上#,变成#hiddenmenu,这样启动系统时,就可以显示不同启动项;
b、将倒数第三行的title others 改为title windows xp(sp2),这样启动时就可以选择进入windows xp。
2、删掉刚才安装时,保存到C盘根目录下的三个文件:grldr、vmlinuz和initrd.img,保持系统干净,简单;
3、还原C:\boot.ini 文件,即删除刚才我们加上去的那一行C:\grldr="Grub Boot",然后保存;
4、这样设置后,系统基本上可以使用了。熟悉CentOS5.2操作系统后,还可以进行更多的其它设置。

修改kloxo开通网站后的默认页面

最近一直在使用Kloxo的空间面板,每次开通一个网站都是Kloxo的Kloxo Default Page默认页面,这个页面不符合我的要求,所有要修改下。
修改办法如下:
1、首先得先准备好你的默认首页,设计个自己感觉非常满意的首页。
2、上传你准备好的满意页面,但要上传到哪呢?几经琢磨,原来这个默认页面就藏在/home/kloxo/httpd/default/
那么知道了路径,就该来上传文件了。这里最简单的方法是进入Kloxo控制面板,依次进入"服务器 ―> localhost―>文件管理器",英文的路径是:"Server ―> localhost―>File Manager"

Kloxo成功安装后必做的三件事

第一:安装中文语言包:
1.用ssh登陆你的vps
2.进入lang目录
cd /usr/local/lxlabs/kloxo/httpdocs/lang
3.下载语言包
wget http://www.vpsyou.com/wp-content/uploads/2010/02/Kloxo_cn.zip
3 解压语言包
unzip Kloxo_cn.zip
4.访问http://你的IP:7778/ 进行lxadmin语言设置
在Appearance->Language里选择Chinese,然后点击update确认.如下图所示:

第二:解决中文网页显示乱码
修改apache的httpd.conf默认编码的设置,如下:
首先用SSH登陆VPS,修改httpd.conf文件
vi /etc/httpd/conf/httpd.conf
查找:AddDefaultCharset
把:AddDefaultCharset UTF8
改为:AddDefaultCharset OFF 或改为 #AddDefaultCharset UTF8
(不只知道怎么用vi?G一下吧)
这样的话,打开页面的时候就会按照网页的编码设置来打开网页。
输入以下命令重启Apache
service httpd restart
第三:删除Kloxo日志(这个得弄一下,要不然没几天你的磁盘就会被日志塞满的)
1.登上ssh
2.在/etc/cron.daily目录下新建cleankloxolog.sh
vi /etc/cron.daily/cleankloxolog.sh
3.编辑cleankloxolog.sh,并输入以下内容
# !/bin/bash
rm -rf /home/admin/_processed_stats/*
rm -rf /home/kloxo/httpd/lighttpd/*
rm -rf /var/log/kloxo/*
rm -f /home/httpd/*/stats/*
然后保存推出.
4.把该文件改为755权限
chmod 755 /etc/cron.daily/cleankloxolog.sh
第四:添加DNS模板
Kloxo有个奇怪的地方就是即使你不使用Kloxo自带的DNS服务器,你也要添加DNS模板,否则你就无法添加域名,这个一定要注意
添加方法如图

注解:
1 == DNS模板名,建议使用英文名,无特殊
2 == 网站的IP,这个添加时默认,如果你有多个IP可以下拉选择
3 == 邮寄的IP,这个添加时默认,如果你有多个IP可以下拉选择
4 == 主DNS,如果你想要使用kloxo自带的DNS服务器,请填写正确已注册的dns服务器
5 == 主DNS,如果你想要使用kloxo自带的DNS服务器,请填写正确已注册的dns服务器

用DEDE做英文站一些说明-非常重要

无法查看这则摘要。请 点击此处查看博文。

一劳永逸解决kloxo日志占满磁盘的问题

一劳永逸解决kloxo日志占满磁盘的问题
1.删除kloxo日志方法。

用KLOXO的同学可能都有这个烦恼,磁盘空间莫名其妙就被占用满了。其实这都是KLOXO日志惹的祸,KLOXO一共会自动生成2个日志文件,随 着使用VPS使用时间越久,这2个日志文件会越来越臃肿。其实我们可以自己动手删除他们,下面deepvps简单介绍一下方法。

第一个
rm -rf /home/admin/__processed_stats
touch /home/admin/__processed_stats

第二个
cd /usr/local/lxlabs/kloxo/httpdocs/lib/domain/web/driver
mv web__lighttpdlib.php web__lighttpdlib.php.bak
mv web__apachelib.php web__apachelib.php.bak
wget http://svn.lxcenter.org/svn/kloxo/trunk/kloxo/httpdocs/lib/domain/web/driver/web__lighttpdlib.php
wget http://svn.lxcenter.org/svn/kloxo/trunk/kloxo/httpdocs/lib/domain/web/driver/web__apachelib.php
chown lxlabs:lxlabs *

手工操作开始:
(1)编辑web__lighttpdlib.php,去掉下面的代码:
$string .=  ”accesslog.filename  =   \”$cust_log\”\n”;
$string .=   ”server.errorlog    =  \”$err_log\”\n”;
(2)编辑web__apachelib.php,去掉下面的代码:
$string .= “CustomLog      {$cust_log} combined  \n”;
$string .= “ErrorLog       {$err_log}\n”;
(3)编辑web__apachelib.php,把下面的代码
lxuser_cp($this->main->username, “/etc/php.ini”, “/home/httpd/{$this->main->nname}/php.ini”);
改成
lxfile_cp(“/etc/php.ini”, “/home/httpd/{$this->main->nname}/php.ini”);

第一个删除的很明显。
第二个删除的是/home/httpd/域名/stats/下面的日志。

2.彻底解决

删除Kloxo日志(这个得弄一下,要不然没几天你的磁盘就会被日志塞满的)
1.登上ssh
2.在/etc/cron.daily目录下新建cleankloxolog.sh
vi /etc/cron.daily/cleankloxolog.sh
3.编辑cleankloxolog.sh,并输入以下内容
# !/bin/bash
rm -rf /home/admin/_processed_stats/*
rm -rf /home/kloxo/httpd/lighttpd/*
rm -rf /var/log/kloxo/*
rm -f /home/httpd/*/stats/*
然后保存推出.
4.把该文件改为755权限
chmod 755 /etc/cron.daily/cleankloxolog.sh

2010年11月14日星期日

英文文章目录站及Web2.0站点列表

文网站优化时,很多情况下都需要这些英文文章目录站,blog,或者web2.0站来作为辅助资源。我有时有些帖子也会涉及到点这方面的内容,比如怎样利 用这些资源站来做好英文SEO,所以还是从别处搜集整理了这么一个资源贴。
英文文章目录站列表
EzineArticles.com
GoArticles
ArticlesBase
Searchwarp
Article City
Article Alley
Article Snatch
Article Dashboard
iSnare
SearchWarp
EasyArticles
Amazines
Article Alley
Articles Base
eHow.com
Wikihow
helium.com
Blog及 Web2.0网站列表
Wordpress
Vox
Tumblr
Squidoo
Hubpages
Blogger
LiveJournal
Xanga
Jimdo
Scribd
Multiply
Wetpaint
Zimbio
Blinkweb
Google Sites
Live Spaces
Gather
Clearblogs
MyLot
Buzzle
Blogpico
Bloglines
Blogsome
Terapad
Quizilla
Gather
Weebly
Blogr
Blog.com
Blog.co.uk
Quizilla.teennick.com
43things.com
ning.com
360.Yahoo.com
squarespace.com
ever.com
其 中你能自定义二级域名的
gather
wetpaint
blog.com
blogspot
webs.com
typepad
wordpress
livejournal
diaryland
21publish
bravenet
easyjournal
edublogs
hpage
insanejournal
nexo
ning
onsugar
sosblog
terapad
zoho
wikidot
wikispaces
xanga
zoomgroups
jimdo
tripod
blogetry
zoomshare

2010年11月13日星期六

Centos5下安装PPTPD(含一键包)

1.删除之前已安装的相关软件:

1
2
3
  yum remove -y pptpd ppp
rm -rf /etc/pptpd.conf
rm -rf /etc/ppp

删除iptables规则:

1
  iptables --flush POSTROUTING --table nat

2.下载相关软件:

3.安装相关软件

1
2
3
4
5
6
  yum -y install make libpcap iptables gcc-c++ logrotate tar vim-minimal cpio perl pam tcp_wrappers
rpm -ivh dkms-2.0.17.5-1.noarch.rpm
rpm -ivh kernel_ppp_mppe-1.0.2-3dkms.noarch.rpm
rpm -qa kernel_ppp_mppe
rpm -Uvh ppp-2.4.4-9.0.rhel5.i386.rpm
rpm -ivh pptpd-1.3.4-1.rhel5.1.i386.rpm

4.相关配置:
a.ppp配置:

1
  mknod /dev/ppp c 108 0

设置vps启动时加载此项,编辑/etc/rc.local,加入:

1
  mknod /dev/ppp c 108 0

修改配置文件/etc/ppp/options.pptpd,加入:

1
2
  ms-dns 8.8.8.8
ms-dns 8.8.4.4

b.配置文件/etc/sysctl.conf,修改

1
  net.ipv4.ip_forward = 0

为:

1
  net.ipv4.ip_forward = 1

然后执行:

1
  /sbin/sysctl -p

c.配置文件/etc/pptpd.conf,加入:

1
2
  localip 192.168.9.1
remoteip 192.168.9.11-30

d.修改配置文件/etc/ppp/chap-secrets,加入:

1
2
3
  # Secrets for authentication using CHAP
# client server secret IP addresses
myusername pptpd mypassword *

PS:myusername为vpn用户名,mypassword为密码
5.启动iptables.加入规则,启动pptpd

1
2
3
4
5
6
7
8
  iptables -t nat -A POSTROUTING -s 192.168.9.0/255.255.255.0 -j SNAT --to-source `ifconfig  | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk 'NR==1 { print $1}'`
service iptables save
 
chkconfig iptables on
chkconfig pptpd on
 
service iptables start
service pptpd start

安装一键包地址:pptpd.sh

Linux常用命令

目录操作:
rm -rf mydir /*删除mydir目录*/
cd mydir /*进入mydir目录*/
cd � /*回上一级目录*/
cd .. /*回父目录,中间有空格*/
cd ~ /*回根目录*/
mv tools tool /*把tools目录改名为tool */
ln -s tool bac /*给tool目录创建名为bac的符号链接,最熟悉的应该就是FTP中www链接到public_html目录了*/
cp -a tool /home/vpser/www /*把tool目录下所有文件复制到www目录下 */

文件操作:
rm go.tar /* 删除go.tar文件 */
find mt.cgi /* 查找文件名为mt.cgi的文件 */
df �h /* 查看磁盘剩余空间,好像没这个必要,除非你太那个了 */

解压缩:
tar xvf wordpress.tar /* 解压tar格式的文件 */
tar -tvf myfile.tar /* 查看tar文件中包含的文件 */
tar cf toole.tar tool /* 把tool目录打包为toole.tar文件 */
tar cfz vpser.tar.gz tool /* 把tool目录打包且压缩为vpser.tar.gz文件,因为.tar文件几乎是没有压缩过的,MT的.tar.gz文件解压成.tar文件后差不多是 10MB */
tar jcvf /var/bak/www.tar.bz2 /var/www/ /*创建.tar.bz2文件,压缩率高*/
tar xjf www.tar.bz2 /*解压tar.bz2格式*/
gzip -d ge.tar.gz /* 解压.tar.gz文件为.tar文件 */
unzip phpbb.zip /* 解压zip文件,windows下要压缩出一个.tar.gz格式的文件还是有点麻烦的 */
下载:
wget http://www.vpsyou.com/lnmp/lnmp.zip / *下载远程服务器上的文件到自己的服务器,连上传都省了,服务器不是100M就是1000M的带宽,下载一个2-3兆的MT还不是几十秒的事 */
wget -c http://www.vpsyou.com/lnmp/lnmp.zip /* 继续下载上次未下载完的文件 */

进程管理:
ps -aux /*ps 进程状态查询命令*/

  ps命令输出字段的含义:

[*]USER,进程所有者的用户名。
[*]PID,进程号,可以唯一标识该进程。
[*]%CPU,进程自最近一次刷新以来所占用的CPU时间和总时间的百分比。
[*]%MEM,进程使用内存的百分比。
[*]VSZ,进程使用的虚拟内存大小,以K为单位。
[*]RSS,进程占用的物理内存的总数量,以K为单位。
[*]TTY,进程相关的终端名。
[*]STAT,进程状态,用(R�运行或准备运行;S�睡眠状态;I�空闲;Z�冻结;D�不间断睡眠;W-进程没有驻留页;T停止或跟踪。)这些字母 来表示。
[*]START,进程开始运行时间。
[*]TIME,进程使用的总CPU时间。
[*]COMMAND,被执行的命令行。
  ps -aux | grep nginx /*在所有进程中,查找nginx的进程*/

  kill 1234 /*1234为进程ID,即ps -aux 中的PID*/

  killall nginx /*killall 通过程序的名字,直接杀死所有进程,nginx为进程名*/

Vim操作:

移动类的:

h/j/k/l: 左/下/上/右 移一格
w : 向后词移动 (前面加数字移动多少个词)
b : 向前词移动 (前面加数字移动多少个词)
e : 向后移到词末
ge : 向前移到词末
$ : 行末
0 : 行首
tx : 向右查找本行的x并移到那儿(大写时向左)
33G : 移到文件的第33行
gg : 文件首行
G : 文件尾行
33% : 文件的33%处
H/M/L : 屏幕的首/中/尾行
zt/zz/zb : 当前行移到屏幕的首/中/底部
跳转:

" : 回到跳转来的地方
CTRL-O : 跳到一个 "较老" 的地方
CTRL-I : 则跳到一个 "较新" 的地方
查找:

/ : 向下查找(后加关键字)
? : 向上查找(后加关键字)
n : 下一条符合的记录

编辑:

i : 转换到插入模式
x : 删除当前字符
. : 重复最后一次的修改操作(同PS里ctrl+f执行滤镜)
u : 撤销操作
CTRL-R : 重做
p : 将删除的字符插入到当前位置(put)
退出保存:

:q : 退出
:q! : 不保存退出
ZZ : 保存后退出
:e! : 放弃修改重新编辑

linux开通SSH代理上网专用账号

首先创建一个sh文件。
以创建/bin/ssh.sh 文件内容如下:

#!/bin/sh
echo ""
echo " ********************************************************************"
echo " * welcome to http://cuxian.info- SSH , press a key to exit. *"
echo " ********************************************************************"
echo ""
read x
exit

保存为:

/bin/ssh.sh
chmod 755 /bin/ssh.sh #加权限
useradd ssh账号 -g nobody -s /bin/ssh.sh #加用户
passwd ssh账号 #给他个密码。

centOS 5.4 vsftpd安装配置

1. 查看有没有安装vsftpd:
rpm -qa | grep vsftpd
2.yum安装vsftpd:
yum install vsftpd
touch /var/log/vsftpd.log # 创建vsftp的日志文件

3.rpm 安装vsftpd:
    可以从下面两个地方获得最新的vsftpd的RPM包https://www.redhat.com/或 者http://www.rpmfind.net/
安装命令:
rpm -Uvh vsftpd-1.1.3-8.i386.rpm
4.设置每次开机时自动运行及手工启动它:
chkconfig vsftpd on
service vsftpd start
netstat -tl 可以查看ftp端口是否在侦听了!
5.配置文件
/etc/vsftpd/ftpusers 和 /etc/vsftpd/user_list,#不能登陆FTP的用户;
/etc/vsftpd/vsftpd.conf
#anonymous_enable=YES
anonymous_enable=NO     #设定不允许匿名用户访问
chroot_local_user=YES      #把系统内所有的FTP用户都限制在家目录中 xferlog_file=/var/log/vsftpd.log 设定vsftpd的服务日志保存路径。注意,该文件默认不存在。必须要手动touch出来
ascii_upload_enable=YES
ascii_download_enable=YES 设定支持ASCII模式的上传和下载功能。
pam_service_name=vsftpd   PAM认证文件名。PAM将根据/etc/pam.d/vsftpd进行认证
以下这些是关于Vsftpd虚拟用户支持的重要配置项目。默认vsftpd.conf中不包含这些设定项目,需要自己手动添加配置。
guest_enable=YES   设定启用虚拟用户功能。
guest_username=ftp   指定虚拟用户的宿主用户。-CentOS中已经有内置的ftp用户了
user_config_dir=/etc/vsftpd/vuser_conf 设定虚拟用户个人vsftp的配置文件存放路径。存放虚拟用户个性的配置文件(配置文件名=虚拟用户名)
6.设定个FTP目录
修改 /var/www 目录属性:
$ chmod -R 777 /var/www 递归地给此目录下所有文件和子目录的读、写、执行权限
$ chgrp -R ftp   /var/www 递归地把此目录及该目录下所有文件和子目录的组属性设置成ftp组
7.增加FTP用户
adduser -d /var/www -g ftp -s /sbin/nologin 用户名 #增加用户,组是FTP,目录是/var/www
passwd 用户名 #设定密码
Changing password for user beinan.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
8.重启FTP
service vsftpd restart
9.如果ftp服务器连接失败,错误提示:
500 OOPS: cannot change directory:/home/*******
500 OOPS: child died
当你看到以上提示时,试着在输入以下命令解决
setsebool -P ftpd_disable_trans 1
service vsftpd restart
第一行中的-P参数是为了以后不需要每次开机都输入这个命令
10.用户管理
userdel 选项 用户名   #删除用户
常用的选项是-r,它的作用是把用户的主目录一起删除。
passwd 选项 用户名 #修改口令
passwd -l 用户名 锁定口令,即禁用账号。
passwd -u 用户名 口令解锁。
passwd -d 用户名 使账号无口令。
passwd -f 用户名 强迫用户下次登录时修改口令。
如果默认用户名,则修改当前用户的口令。
如果是超级用户,可以用下列形式指定任何用户的口令:
passwd 用户名
passwd -d 用户名 此命令将用户的口令删除,这样用户下一次登录时,系统就不再询问口令
11.是否想修改21端口呢?
先修改防火墙,增加其FTP端口,下面使用921
-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 921 -j ACCEPT
/etc/init.d/iptables restart   #重启防火墙
/etc/vsftpd/vsftpd.conf 里增加加   listen_port=921
/etc/rc.d/init.d/vsftpd restart    #重启vsftpd
netstat -an |grep 921             #查看端口是否正常启动:

12. 有时客户端反应很慢,可以使用被动模式

添加以下内容
use_localtime=YES
listen_port=25682
pasv_enable=YES
pasv_min_port=25683
pasv_max_port=25686

如果开启了防 火墙,需要放行端口25682:25686
客户端使用25682进行连接

2010年11月11日星期四

取消WordPress2.71的自动保存和日志修订版本

WordPress的日志修订版本确实很烦,修改一次占一个post_id,现在这篇文章的id是1536了,而上一篇文章才1493,id整整相 差了43.......原因就是WordPress版本控制功能太强了...
取消WordPress2.71的自动保存和日志修订版本

而用Windows Live Writer离线发布,发布之后不再修改,ID就会连续...

而,我比较喜欢上网站后台发布...  :-)

为了WordPress的ID不太离谱...我取消了WordPress的自动保存和日志修订版本功能...

方法如下:

用DreamWeaver(千万别用Windows的记事本...)打开/wp-includes/default-filters.php这个文 件,第189行的

add_action( 'pre_post_update', 'wp_save_post_revision' );

修改为:

//add_action( 'pre_post_update', 'wp_save_post_revision' );

打开/wp-admin/includes/post.php这个文件,第1043行的

return _wp_put_post_revision( $_POST, true );

修改为:

//return _wp_put_post_revision( $_POST, true );
return edit_post();



http://deloz.net/1000000313.html

2010年11月5日星期五

Micolog博客主题终极优化篇

之前google app的一些动作让我们有些失望,他们将CPU的使用率和每日的输出流量都减少了,CPU的影响倒不是很大,因为博客使用了缓存,其中每日输出流量从2G 改为1G最使人恼火。当然对大多数博客已经够用了,但我们还要未雨绸缪,做些优化来减少或平摊一下流量。

使用绝对路径,路径中注意大 小写(使用python的缘故)。目的是减少重复加载文件。减少宽带输出量,并且也对网站有加速的作用。调用js文件较多的网站尤为重 要。

1.将站内所有的图片都用绝对路径,包括css中的。

在style.css 中的所有相对路径替换成绝对路径 如

#container #wrapper {
    width: 900px;
    float: left;
    overflow: hidden;
    background: #d6ded4 url(http://hou-kai.appspot.com/themes/Devart/images/sidebar-bg.gif) repeat-y top right;
}

2.改javascript函数为文件调用形式。并用绝对路径。

其中公用的部分建议用官方提供的链 接,比如jquey库。这样做的好处是大多数网站都在使用这样通用库,如果访问到您的博客就不用重新加载了。如

<script type="text/javascript" language="javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>

把其他的改为绝对路径调用,如

QQ表情的js
<script type="text/javascript" src="http://hou-kai.appspot.com/themes/Devart/smile.js">

其他的同样,如果js中有中文字符,需将js文件以utf-8格式保存。比如下面commnent.js是 利用ajexa提交评论,但函数内有中文提示。还有taotao.js也是utf-8格式。

<script src="http://hou-kai.appspot.com/themes/Devart/cookie.js" type="text/javascript"></script> 
<SCRIPT src="http://hou-kai.appspot.com/themes/Devart/commenttips.js" type="text/javascript"></SCRIPT>
<SCRIPT src="http://hou-kai.appspot.com/themes/Devart/comment.js" type="text/javascript"></SCRIPT>
<script type="text/javascript">var taotao_qq=63956135; var taotao_num=5;var taotao_type=0;</script><script type="text/javascript" charset="utf-8" src="http://hou-kai.appspot.com/themes/Devart/taotao.js"></script>

经过这步,我明显感觉用ajexa提交留言的速度快了。还可以对js进行合并,并用YUI Compressor 工具对 JavaScript 和 CSS 代码进行压缩(非必要)。

3.绝对路径中用 yourID.appspot.com二级域名。

为什么上面我用http://hou- kai.appspot.com/,而不用http://www.houkai.com/呢,因为我们绑定的域名只是google在ghs服务器上做了一 个反向代理,最终还是调用前者的内容,这也是为什么*.appspot.com支持https,而绑定的域名不支持,是因为反向代理没有提供这样的功能。

前面写过一篇博文,来 悼念阵亡的ip,现在用来绑定域名的ip已经是聊聊无几,我一直在想ip用完了怎么办,难道我们的博客就关门大吉,或者导出数据转移到 Wordpress。现在Micolog程序还有缺陷,如果转移到Wordpress感觉数据也会有所丢失。而且,我还是比较喜欢python的。有没有 其他办法呢。

请大家先看看 http://w92.houkai.com。这是我用国内ip做了一个反向代理,很简单,就是用w92.houkai.com来代理hou- kai.appspot.com。这台机子的ip是个公网ip,我在该机子用phpnow搭建了个php环境,本来想用来做个掘客,但一直太懒闲置着。如 果我在Micolog后台设置域名为w92.houkai.com,是不是和google提供的ghs效果一样

上面用appspot.com的绝对路径的目的就是要绕过反向代理直接调用,这样就可以减少对反向代理的压力。毕竟用的ghs都放在国外的某个 主机,appspot的速度还是很快的(我猜想它有流量均衡机制)!

4.分摊流量。

因 为google app 对每个项目都有流量和cpu方面的限制,但每个用户可以最多申请10个项目。所以我们可以用两个或者三个项目来分散流量,你可以观察,凡是大型网站一般主 题发面的图片都会存放在另一个二级域名下。这样可以减少对主站的压力。

那么如果分摊流量呢。一般用Micolog的博主也都在用大菠萝 相册来做图床。您可以将主题包放在大菠萝程序内。修改一下app.yaml来缩短路径(非必要),把Micolog主题中的hou- kai.appspot.com换成大菠萝相册的二级域名路径。

还有一种最最简单的方法,就是再开一个项目,比如我再新建一个 houkaiblog.appspot.com,把Micolog程序中的hou-kai.appspot.com主题中绝对路径全部替换成 houkaiblog.appspot.com。将同一程序分别上传到两个项目传就ok了!这样www.houkai.com 主题中css、js、图片等文件调用的就是houkaiblog.appspot.com的流量,其他调用的是自己hou-kai.appspot的流 量。

使用绝对路径要注意的地方:在本地测试的时候,如果修改那个css或js的调用文件 一定要在html文件中将该文件的路径改成相对路径才能看到效果,上传前在改回绝对路径!虽然麻烦,但修改调用文件几率还是很小的!