<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Verdana DevNotes</title>
	<atom:link href="http://www.phpvim.net/feed" rel="self" type="application/rss+xml" />
	<link>http://www.phpvim.net</link>
	<description>{coding, life, love}</description>
	<lastBuildDate>Sun, 14 Feb 2010 22:48:44 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>设置 SSH 自动登陆多个不同的主机</title>
		<link>http://www.phpvim.net/ubuntu/setup-ssh-auto-login-for-multi-server.html</link>
		<comments>http://www.phpvim.net/ubuntu/setup-ssh-auto-login-for-multi-server.html#comments</comments>
		<pubDate>Fri, 12 Feb 2010 14:09:47 +0000</pubDate>
		<dc:creator>Verdana Mu</dc:creator>
				<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Cygwin]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.phpvim.net/?p=527</guid>
		<description><![CDATA[在《使用 Putty 自动登陆远程 Linux 主机》一文中曾经讲过如何设置 SSH （客户端为 Putty） 来自动登陆 Linux 主机。当需要自动登陆的主机有多台的时候，上文的方法就有点不适合了。这里补全一下，如何搞定多台服务器的 SSH 自动登录。
假设有两台远端 Linux 服务器，host-jack 和 host-vicki。

1. 分别为两台服务器生成密钥对
你可以在任何一台 Linux 服务器上面运行 ssh-keygen 程序来生成密钥对。我这里使用的是本机系统的 Cygwin 环境。 
$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/verdana/.ssh/id_rsa): /home/verdana/.ssh/id_rsa_jack
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/verdana/.ssh/id_rsa_jack.
Your [...]]]></description>
			<content:encoded><![CDATA[<p>在《<a title="使用 Putty 自动登陆远程 Linux 主机" href="http://www.phpvim.net/ubuntu/auto-login-using-putty.html">使用 Putty 自动登陆远程 Linux 主机</a>》一文中曾经讲过如何设置 SSH （客户端为 Putty） 来自动登陆 Linux 主机。当需要自动登陆的主机有多台的时候，上文的方法就有点不适合了。这里补全一下，如何搞定多台服务器的 SSH 自动登录。</p>
<p>假设有两台远端 Linux 服务器，host-jack 和 host-vicki。</p>
<p><span id="more-527"></span></p>
<p>1. <strong>分别为两台服务器生成密钥对</strong><br />
你可以在任何一台 Linux 服务器上面运行 ssh-keygen 程序来生成密钥对。我这里使用的是本机系统的 Cygwin 环境。 </p>
<pre>$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/verdana/.ssh/id_rsa): /home/verdana/.ssh/id_rsa_jack
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/verdana/.ssh/id_rsa_jack.
Your public key has been saved in /home/verdana/.ssh/id_rsa_jack.pub.
The key fingerprint is:
84:bb:e0:a1:be:75:2b:49:15:09:bd:01:39:ce:7b:e1 verdana@verdana-pc</pre>
<pre>$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/verdana/.ssh/id_rsa): /home/verdana/.ssh/id_rsa_vicki
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/verdana/.ssh/id_rsa_vicki.
Your public key has been saved in /home/verdana/.ssh/id_rsa_vicki.pub.
The key fingerprint is:
ea:74:e3:1d:c4:5e:c8:ee:54:f9:ac:f0:55:60:d1:62 verdana@verdana-pc</pre>
</p>
<p>2. <strong>将公钥上传至远程服务器</strong><br />
使用 scp，ftp/sftp &#8230; 或者您喜欢的方式将生成的公钥（*.pub）上传到远程服务器需要自动登陆的账户主目录的 .ssh 目录中，并导入至 authorized_keys 文件中。下面以 host-jack 的 root 账户为例： </p>
<pre>$ scp /home/verdana/.ssh/id_rsa_jack root@host-jack:~/.ssh</pre>
<p>如果 .ssh 目录不存在，或者 authorized_keys 文件不存在，请自行 ssh 至对应主机创建目录和文件，或者使用 ssh 的远程命令功能创建，如果已经存在，则跳过这个步骤。示例： </p>
<pre>$ ssh root@host-jack 'mkdir ~/.ssh; touch ~/.ssh/authorized_keys'
root@host-jack's password:</pre>
<p>导入至 authorized_keys 文件。 </p>
<pre>$ ssh root@host-jack 'cat ~/.ssh/id_rsa_jack.pub &gt;&gt; ~/.ssh/authorized_keys'
root@host-jack's password:</pre>
<p>完成后，id_ras_jack.pub 这个文件就不需要了，可以删除或保留。
</p>
<p>3. <strong>设置客户端</strong><br />
本地我使用的是 Cygwin，刚刚生成的私钥 id_rsa_jack 和 id_rsa_vicki 已保存在了 /home/verdana/.ssh 目录中。此时你便可以使用下面的命令来自动登陆远程主机了。</p>
<pre>
$ ssh -i ~/.ssh/id_rsa_jack root@host-jack
$ ssh -i ~/.ssh/id_rsa_vicki root@host-vicki
</pre>
<p>使用 ssh -i 来指定认证的私钥文件。是不是命令很长？当然了，这么长的命令，自动登陆变得没有意义了。<br />
你可以修改 .bashrc 文件，使用 alias 为上面的命令指定一个别名命令。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">alias</span> ssh-jack <span style="color: #ff0000;">'ssh -i ~/.ssh/id_rsa_jack root@host-jack'</span></pre></td></tr></table></div>

<p>或者配置 ssh_config 为每台远程主机分别指定不同的认证文件。创建文件 /home/verdana/.ssh/config，内容如下：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">Host host-jack
IdentityFile ~<span style="color: #000000; font-weight: bold;">/</span>.ssh<span style="color: #000000; font-weight: bold;">/</span>id_rsa_jack
&nbsp;
Host host-vicki
IdentityFile ~<span style="color: #000000; font-weight: bold;">/</span>.ssh<span style="color: #000000; font-weight: bold;">/</span>id_rsa_vicki</pre></td></tr></table></div>

<p>其它 ssh_config 的配置命令，请参考 &#8220;man ssh_config&#8221;。差不多就是这样了~ <img src='http://www.phpvim.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpvim.net/ubuntu/setup-ssh-auto-login-for-multi-server.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Promise</title>
		<link>http://www.phpvim.net/music/promise.html</link>
		<comments>http://www.phpvim.net/music/promise.html#comments</comments>
		<pubDate>Tue, 02 Feb 2010 19:34:40 +0000</pubDate>
		<dc:creator>Verdana Mu</dc:creator>
				<category><![CDATA[Music]]></category>
		<category><![CDATA[Game]]></category>

		<guid isPermaLink="false">http://www.phpvim.net/?p=521</guid>
		<description><![CDATA[Silent Hill 2: Restless Dreams
Akira Yamaoka
Theme of Laura
Promise
]]></description>
			<content:encoded><![CDATA[<p><strong>Silent Hill 2: Restless Dreams</strong><br />
<em>Akira Yamaoka</em></p>
<p>Theme of Laura</p>
<p>Promise</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpvim.net/music/promise.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Waiting For You ~LIVE AT Heaven&#8217;s Night~ (unreleased tunes)</title>
		<link>http://www.phpvim.net/music/waiting-for-you-live-at-heavens-night-unreleased-tunes.html</link>
		<comments>http://www.phpvim.net/music/waiting-for-you-live-at-heavens-night-unreleased-tunes.html#comments</comments>
		<pubDate>Tue, 02 Feb 2010 19:06:59 +0000</pubDate>
		<dc:creator>Verdana Mu</dc:creator>
				<category><![CDATA[Music]]></category>
		<category><![CDATA[Game]]></category>

		<guid isPermaLink="false">http://www.phpvim.net/?p=519</guid>
		<description><![CDATA[Silent Hill 4: The Room
Akira Yamaoka
Waiting For You ~LIVE AT Heaven&#8217;s Night~ (unreleased tunes)

Your gentle voice I hear
Your words echo inside me
You said &#8220;You long for me, that you love me&#8221;
And I want to see you too, feels just like I&#8217;m falling
Is there nothing I can do, wonder if you hear my calling
I&#8217;m here and [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Silent Hill 4: The Room</strong><br />
<em>Akira Yamaoka</em></p>
<p>Waiting For You ~LIVE AT Heaven&#8217;s Night~ (unreleased tunes)</p>
<p><span id="more-519"></span></p>
<blockquote><p>Your gentle voice I hear<br />
Your words echo inside me<br />
You said &#8220;You long for me, that you love me&#8221;<br />
And I want to see you too, feels just like I&#8217;m falling<br />
Is there nothing I can do, wonder if you hear my calling</p>
<p>I&#8217;m here and waiting for you<br />
Where are you, I can&#8217;t find you<br />
I&#8217;m here and waiting for you<br />
I&#8217;ll wait forever for you</p>
<p>Mom&#8217;s gone to Heaven now<br />
Why won&#8217;t she come back down<br />
Does she have someone she loves more than me<br />
I thought I could love you better, we were always together<br />
If we took some time apart you would finally know my heart</p>
<p>I&#8217;m here and waiting for you<br />
Where are you, I can&#8217;t find you<br />
I&#8217;m here and waiting for you<br />
I&#8217;ll wait forever for you</p>
<p>^^Akira&#8217;s guitar solo^^</p>
<p>I fell in Love with you and now you&#8217;re gone<br />
There&#8217;s nothing left within my lonely room without you</p>
<p>I&#8217;m here and waiting for you<br />
Where are you, I can&#8217;t find you<br />
I&#8217;m here and waiting for you<br />
I&#8217;ll wait forever for you</p></blockquote>
<blockquote><p>你的温柔的声音<br />
你的话语回荡在我内心.<br />
你说:&#8221;你渴望我,你爱我&#8221;<br />
并且,我也想见你,感觉就像我正在陷落<br />
不知是不是除了让你听到我的呼唤,其他的我无能为力</p>
<p>我在这里等你<br />
你在哪 我找不到你<br />
我在这里等你<br />
我将永远等你</p>
<p>如今妈妈去了天堂<br />
为什么她不会再回来了<br />
是不是她有了比我更爱的人<br />
我想我不能更爱你 我们总在一起<br />
如果我们分开一段时间,你终将明白我的心</p>
<p>我在这里等你<br />
你在哪 我找不到你<br />
我在这里等你<br />
我将永远等你</p>
<p>我爱上了你可是现在你走了<br />
除了失去你的我得寂寞的房间什么都没有留下</p>
<p>我在这里等你<br />
你在哪 我找不到你<br />
我在这里等你<br />
我将永远等你</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.phpvim.net/music/waiting-for-you-live-at-heavens-night-unreleased-tunes.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>使用 Shell 上传代码</title>
		<link>http://www.phpvim.net/ubuntu/upload-with-shell-script.html</link>
		<comments>http://www.phpvim.net/ubuntu/upload-with-shell-script.html#comments</comments>
		<pubDate>Tue, 12 Jan 2010 18:05:06 +0000</pubDate>
		<dc:creator>Verdana Mu</dc:creator>
				<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Cygwin]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Shell]]></category>

		<guid isPermaLink="false">http://www.phpvim.net/?p=516</guid>
		<description><![CDATA[自从法现 SSH 可以执行远端命令后，ftp 软件也渐渐很少用了。
每次更新服务器代码，都要打包、上传、登录到服务器修改文件权限、更新 Cache 等等，又慢又容易出错，所以做成脚本，一次帮我搞定，自己就点上一根烟坐在电脑面前发呆，要么就玩会儿《植物大战僵尸》啥的，悠闲！
PS: Ant 以及 Phing 用户，你们可以无视了&#8230; 我只是喜欢玩 Shell 而已。


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/sh
&#160;
HOME='/cygdrive/d/public_html/myproject'
&#160;
## 先打包本地代码
## 排除如下文件： *.svn, *.bat, upload.sh, cache
## 如果需要 exclude 的文件很多，可以使用参数 --exclude-from=FILE
## 将文件一行行写入 FILE 中
cd $HOME
tar jcf tmp.tar.bz2 *   \
    --exclude=*.bat     \
    --exclude=*.bz2     \
    --exclude=*.gz [...]]]></description>
			<content:encoded><![CDATA[<p>自从法现 SSH 可以执行远端命令后，ftp 软件也渐渐很少用了。</p>
<p>每次更新服务器代码，都要打包、上传、登录到服务器修改文件权限、更新 Cache 等等，又慢又容易出错，所以做成脚本，一次帮我搞定，自己就点上一根烟坐在电脑面前发呆，要么就玩会儿《植物大战僵尸》啥的，悠闲！</p>
<p>PS: <a href="http://ant.apache.org" target="_blank">Ant</a> 以及 <a href="http://phing.info" target="_blank">Phing</a> 用户，你们可以无视了&#8230; 我只是喜欢玩 Shell 而已。</p>
<p><span id="more-516"></span></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
&nbsp;
<span style="color: #007800;">HOME</span>=<span style="color: #ff0000;">'/cygdrive/d/public_html/myproject'</span>
&nbsp;
<span style="color: #666666; font-style: italic;">## 先打包本地代码</span>
<span style="color: #666666; font-style: italic;">## 排除如下文件： *.svn, *.bat, upload.sh, cache</span>
<span style="color: #666666; font-style: italic;">## 如果需要 exclude 的文件很多，可以使用参数 --exclude-from=FILE</span>
<span style="color: #666666; font-style: italic;">## 将文件一行行写入 FILE 中</span>
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #007800;">$HOME</span>
<span style="color: #c20cb9; font-weight: bold;">tar</span> jcf tmp.tar.bz2 <span style="color: #000000; font-weight: bold;">*</span>   \
    <span style="color: #660033;">--exclude</span>=<span style="color: #000000; font-weight: bold;">*</span>.bat     \
    <span style="color: #660033;">--exclude</span>=<span style="color: #000000; font-weight: bold;">*</span>.bz2     \
    <span style="color: #660033;">--exclude</span>=<span style="color: #000000; font-weight: bold;">*</span>.gz      \
    <span style="color: #660033;">--exclude</span>=.svn      \
    <span style="color: #660033;">--exclude</span>=cache     \
    <span style="color: #660033;">--exclude</span>=upload.sh \
&nbsp;
<span style="color: #666666; font-style: italic;">## 通过 SCP 上传文件</span>
<span style="color: #c20cb9; font-weight: bold;">scp</span> tmp.tar.bz2 user<span style="color: #000000; font-weight: bold;">@</span>your.host.com:<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>public_html<span style="color: #000000; font-weight: bold;">/</span>myproject<span style="color: #000000; font-weight: bold;">/</span>tmp.tar.bz2
&nbsp;
<span style="color: #666666; font-style: italic;">## 执行远程 ssh 命令</span>
<span style="color: #666666; font-style: italic;">## 这里执行了另外一个脚本 load.sh</span>
<span style="color: #c20cb9; font-weight: bold;">ssh</span> user<span style="color: #000000; font-weight: bold;">@</span>your.host.com
	<span style="color: #ff0000;">&quot;
	cd /home/public_html/myproject
	tar jxf tmp.tar.bz2
	chown -R web:web *
	chmod -R 755 *
	sh load.sh
	rm -f tmp.tar.bz2
	&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">## 删除本地文件</span>
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span> tmp.tar.bz2
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Everything is done.&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># 星期一 一月 11, 2010 by Verdana</span>
<span style="color: #666666; font-style: italic;"># vim: set expandtab tabstop=4 shiftwidth=4:</span></pre></td></tr></table></div>

<p>SSH 我配置成了自动登录，可以参考<a href="http://www.phpvim.net/ubuntu/auto-login-using-putty.html">这里</a>。<br />
 <img src='http://www.phpvim.net/wp-includes/images/smilies/icon_razz.gif' alt=':razz:' class='wp-smiley' />  </p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpvim.net/ubuntu/upload-with-shell-script.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>在 Cygwin 中编译 MySQL 客户端</title>
		<link>http://www.phpvim.net/windows/build-mysql-client-on-cygwin.html</link>
		<comments>http://www.phpvim.net/windows/build-mysql-client-on-cygwin.html#comments</comments>
		<pubDate>Wed, 30 Dec 2009 12:26:15 +0000</pubDate>
		<dc:creator>Verdana Mu</dc:creator>
				<category><![CDATA[Windows]]></category>
		<category><![CDATA[Cygwin]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Shell]]></category>

		<guid isPermaLink="false">http://www.phpvim.net/?p=514</guid>
		<description><![CDATA[MinTTY 是一个小巧但却很实用的 Cygwin 终端机，但有个严重的问题就是无法调用交互性的 Windows 原生程序，比如说 mysql.exe，当你在 MinTTY 中输入如下的命令：

1
$ mysql -uroot -p

本来 mysql.exe 会提示输入密码，但在 MinTTY 中程序会直接挂起，不再响应，实际上即使在 -p 参数后面跟上密码，也是一样的。
某些程序，比如 python，会提供参数 -i，使自身在终端中进入交互模式，可惜并非所有的程序都有这样的参数。
解决的办法，使用 Cygwin 版本的 MySQL 客户端，但 Cygwin 并没有提供，所以就只有自己动手编译一个！

在 http://dev.mysql.com/downloads 下载源码包并解压。

1
2
3
$ wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.0-m2.tar.gz/from/......
$ tar zxvf mysql-5.5.0-m2.tar.gz
$ cd mysql-5.5.0-m2

在动手编译之前，先打开 Cygwin 安装程序安装 readline，用来替代 MySQL 自带的。MySQL 源码包捆绑的 readline 在 Cygwin中编译会报错。
准备好以后，开始编译过程：

1
2
3
$ ./configure --without-server --without-readline CFLAGS=-O2 CXXFLAGS=-O2
$ make
$ make install

Cygwin 的编译速度是很慢的，和原生 *nix 系统完全没法比，所以如果不是闲到发慌，最好不要去编译“复杂”的 [...]]]></description>
			<content:encoded><![CDATA[<p>MinTTY 是一个小巧但却很实用的 Cygwin 终端机，但有个严重的问题就是无法调用交互性的 Windows 原生程序，比如说 mysql.exe，当你在 MinTTY 中输入如下的命令：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">$ mysql <span style="color: #660033;">-uroot</span> <span style="color: #660033;">-p</span></pre></td></tr></table></div>

<p>本来 mysql.exe 会提示输入密码，但在 MinTTY 中程序会直接挂起，不再响应，实际上即使在 -p 参数后面跟上密码，也是一样的。</p>
<p>某些程序，比如 python，会提供参数 -i，使自身在终端中进入交互模式，可惜并非所有的程序都有这样的参数。</p>
<p>解决的办法，使用 Cygwin 版本的 MySQL 客户端，但 Cygwin 并没有提供，所以就只有自己动手编译一个！</p>
<p><span id="more-514"></span></p>
<p>在 <a href="http://dev.mysql.com/downloads" target="_blank">http://dev.mysql.com/downloads</a> 下载源码包并解压。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>dev.mysql.com<span style="color: #000000; font-weight: bold;">/</span>get<span style="color: #000000; font-weight: bold;">/</span>Downloads<span style="color: #000000; font-weight: bold;">/</span>MySQL-<span style="color: #000000;">5.5</span><span style="color: #000000; font-weight: bold;">/</span>mysql-5.5.0-m2.tar.gz<span style="color: #000000; font-weight: bold;">/</span>from<span style="color: #000000; font-weight: bold;">/</span>......
$ <span style="color: #c20cb9; font-weight: bold;">tar</span> zxvf mysql-5.5.0-m2.tar.gz
$ <span style="color: #7a0874; font-weight: bold;">cd</span> mysql-5.5.0-m2</pre></td></tr></table></div>

<p>在动手编译之前，先打开 Cygwin 安装程序安装 readline，用来替代 MySQL 自带的。MySQL 源码包捆绑的 readline 在 Cygwin中编译会报错。</p>
<p>准备好以后，开始编译过程：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">$ .<span style="color: #000000; font-weight: bold;">/</span>configure <span style="color: #660033;">--without-server</span> <span style="color: #660033;">--without-readline</span> <span style="color: #007800;">CFLAGS</span>=-O2 <span style="color: #007800;">CXXFLAGS</span>=-O2
$ <span style="color: #c20cb9; font-weight: bold;">make</span>
$ <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></pre></td></tr></table></div>

<p>Cygwin 的编译速度是很慢的，和原生 *nix 系统完全没法比，所以如果不是闲到发慌，最好不要去编译“复杂”的 MySQL Server。</p>
<p>编译安装完 MySQL Client，打开 Windows 系统中的 MySQL Server，使用如下的命令测试一下：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">$ mysql -h127.0.0.1 <span style="color: #660033;">-uroot</span> <span style="color: #660033;">-p</span></pre></td></tr></table></div>

<p>为什么加上 -h127.0.0.1 呢？默认的情况下，不带 -h 参数或者使用 -h localhost，MySQL 都会使用 Unix socket file 连接服务器，即使你在命令中指定了端口也会被忽略的，所以肯定连接不上的，提示找不到 /tmp/mysql.sock。使用 IP 或者主机名后，MySQL 就会使用 TCP/IP 模式连接服务器的 3306 端口，这样就什么没问题了。</p>
<p>为了方便，在配置文件中强制客户端使用 TCP/IP 连接模式。</p>
<p>复制 mysql-5.5.0-m2/support-files 中的配置文件样板到 /etc/my.cnf，EG：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">cp</span> support-files<span style="color: #000000; font-weight: bold;">/</span>my-medium.cnf <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>my.cnf</pre></td></tr></table></div>

<p>在 [client] 中加入 protocol=TCP，EG：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="mysql" style="font-family:monospace;"><span style="color: #808080; font-style: italic;"># The following options will be passed to all MySQL clients</span>
<span style="color: #FF00FF;">&#91;</span>client<span style="color: #FF00FF;">&#93;</span>
<span style="color: #808080; font-style: italic;">#password   = your_password</span>
port        <span style="color: #CC0099;">=</span> <span style="color: #008080;">3306</span>
socket      <span style="color: #CC0099;">=</span> <span style="color: #CC0099;">/</span>tmp<span style="color: #CC0099;">/</span>mysql.sock
protocol    <span style="color: #CC0099;">=</span> TCP
&nbsp;
<span style="color: #808080; font-style: italic;">## 指定客户端连接的默认编码，注意是 utf8，不是 utf-8</span>
<span style="color: #808080; font-style: italic;">## 可根据需要自行修改</span>
<span style="color: #990099; font-weight: bold;">default</span><span style="color: #CC0099;">-</span>character<span style="color: #CC0099;">-</span><span style="color: #990099; font-weight: bold;">set</span> <span style="color: #CC0099;">=</span> utf8</pre></td></tr></table></div>

<p>之后就可以使用 mysql -uroot -p 直接连接 Windows 中的 MySQL Server 了。<br />
 <img src='http://www.phpvim.net/wp-includes/images/smilies/icon_razz.gif' alt=':razz:' class='wp-smiley' />  </p>
<p><strong>令人纠结的乱码问题</strong><br />
顺便提一下，MySQL 中大部分人都是使用的 UTF-8 编码，我也是。为了规避乱码，需要在 Cygwin/MinTTY 中把字符集设置为 UTF-8，不过让人极度不爽的是，这样的话，中文 Windows 的程序，就会乱码（比如 ping, tracert，nslookup&#8230;.），因为中文 Windows 环境使用的是 GBK 字符集，没办法，要么换成 E 文 Windows，要么忍着。 <img src='http://www.phpvim.net/wp-includes/images/smilies/icon_cry.gif' alt=':cry:' class='wp-smiley' />  </p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpvim.net/windows/build-mysql-client-on-cygwin.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>使用 Shell 更新 PHP5</title>
		<link>http://www.phpvim.net/journal/update-php5-with-shell.html</link>
		<comments>http://www.phpvim.net/journal/update-php5-with-shell.html#comments</comments>
		<pubDate>Mon, 28 Dec 2009 18:00:52 +0000</pubDate>
		<dc:creator>Verdana Mu</dc:creator>
				<category><![CDATA[Journal]]></category>
		<category><![CDATA[Cygwin]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Shell]]></category>

		<guid isPermaLink="false">http://www.phpvim.net/?p=507</guid>
		<description><![CDATA[我很迷恋 Shell，很喜欢看着字符在黑色的 Console 界面中跳跃着，奇怪的是，我居然没有因此成为一个 Linux/Unix 程序员，而只是个写 CGI 程序的倒霉蛋。大家都是怎么称呼 “PHP 程序员”的？对了——草根~ 嗯，在土里埋的太久，说不定哪天就烂掉了咯！    
可能是被 Windows 惯坏了，实在不想换个 OS，还好有 Cygwin，MinGW &#8230; 之类的东西， 适当的时候，可以拿出来装下 B，自我安慰一下~
我总喜欢从 windows.php.net 下载最新的 snapshot，不是我想体验最新的功能，只是强迫症的关系-,-。我机器上的所有软件，程序都是最新的，绝大部分都还挂着 beta 标签，甚至有一些是直接从 SVN，Git 上面拖下来的 trunk 版本，想想真是变态。如果你每天都爬上这些网站，人肉检查一下是不是有新的版本发布，以此满足一下自己变态的心理，那真是要疯掉了。

能让机器干的事情，就不要手工去做，是吧！下面这段代码会自动去 check 最新的 snapshot，解压到你想要的目录。 然后呢？建个 cron job 挂上去，就可以去找新的乐子了~
代码中下载的是，None thead safe VC9 版本，注意替换成自己能用的版本。需要强制更新的话，加上 “&#8211;force” 参数。
最后一行使用 icacls 重置了 php5-nts 目录下文件的权限（注意路径的写法，icacls 是 windows 自己的程序），因为 cygwin 会把 NTFS [...]]]></description>
			<content:encoded><![CDATA[<p>我很迷恋 Shell，很喜欢看着字符在黑色的 Console 界面中跳跃着，奇怪的是，我居然没有因此成为一个 Linux/Unix 程序员，而只是个写 CGI 程序的倒霉蛋。大家都是怎么称呼 “PHP 程序员”的？对了——草根~ 嗯，在土里埋的太久，说不定哪天就烂掉了咯！  <img src='http://www.phpvim.net/wp-includes/images/smilies/icon_twisted.gif' alt=':twisted:' class='wp-smiley' />  </p>
<p>可能是被 Windows 惯坏了，实在不想换个 OS，还好有 Cygwin，MinGW &#8230; 之类的东西， 适当的时候，可以拿出来装下 B，自我安慰一下~</p>
<p>我总喜欢从 <a href="http://windows.php.net">windows.php.net</a> 下载最新的 snapshot，不是我想体验最新的功能，只是强迫症的关系-,-。我机器上的所有软件，程序都是最新的，绝大部分都还挂着 beta 标签，甚至有一些是直接从 SVN，Git 上面拖下来的 trunk 版本，想想真是变态。如果你每天都爬上这些网站，人肉检查一下是不是有新的版本发布，以此满足一下自己变态的心理，那真是要疯掉了。</p>
<p><span id="more-507"></span></p>
<p>能让机器干的事情，就不要手工去做，是吧！下面这段代码会自动去 check 最新的 snapshot，解压到你想要的目录。 然后呢？建个 cron job 挂上去，就可以去找新的乐子了~</p>
<p>代码中下载的是，None thead safe VC9 版本，注意替换成自己能用的版本。需要强制更新的话，加上 “&#8211;force” 参数。</p>
<p>最后一行使用 icacls 重置了 php5-nts 目录下文件的权限（注意路径的写法，icacls 是 windows 自己的程序），因为 cygwin 会把 NTFS 的权限搞的巨恶心。<br />
PS: 非 CGI/FCGI 安装模式，记得关掉 Web Server。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #007800;">INSTALL_PATH</span>=<span style="color: #ff0000;">&quot;/cygdrive/d/php5-nts&quot;</span>
<span style="color: #007800;">BUILD_TIME_FILE</span>=<span style="color: #ff0000;">&quot;/cygdrive/d/php5-nts/build-time&quot;</span>
<span style="color: #007800;">PACKAGE_URL</span>=<span style="color: #ff0000;">&quot;http://windows.php.net/downloads/snaps/php-5.3-nts-win32-VC9-x86-latest.zip&quot;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> uprint <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${1:0:1}</span>&quot;</span> = <span style="color: #ff0000;">&quot;-&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> $<span style="color: #000000;">1</span> <span style="color: #ff0000;">&quot;# $2&quot;</span>
    <span style="color: #000000; font-weight: bold;">else</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;# $1&quot;</span>
    <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">## If unzip available?</span>
<span style="color: #007800;">UNZIP</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">which</span> <span style="color: #c20cb9; font-weight: bold;">unzip</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null<span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #007800;">$UNZIP</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    uprint <span style="color: #ff0000;">&quot;Could not find unzip, please install.&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #666666; font-style: italic;">## Test if build-time file exists, if not, create it</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$BUILD_TIME_FILE</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    uprint <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Build time file does not exists, created ... &quot;</span>
    <span style="color: #c20cb9; font-weight: bold;">touch</span> <span style="color: #007800;">$BUILD_TIME_FILE</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;\e[32m[OK]\e[0m&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #666666; font-style: italic;">## Get current build time</span>
<span style="color: #007800;">CURRENT_BUILD_TIME</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #007800;">$BUILD_TIME_FILE</span><span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
<span style="color: #666666; font-style: italic;">## Get latest build time</span>
<span style="color: #007800;">LATEST_BUILD_TIME</span>=<span style="color: #000000; font-weight: bold;">`</span>curl <span style="color: #660033;">--silent</span> http:<span style="color: #000000; font-weight: bold;">//</span>windows.php.net<span style="color: #000000; font-weight: bold;">/</span>snapshots<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight: bold;">|</span> \
        <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">&quot;php-5.3-nts-VC9-x86&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> \
        <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">&quot;VC9 x86 Non Thread Safe (&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> \
        <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-o</span> <span style="color: #ff0000;">&quot;(.*)&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> \
        <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s/[()]//g'</span><span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
<span style="color: #666666; font-style: italic;">## Any update?</span>
<span style="color: #007800;">package</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">basename</span> <span style="color: #007800;">$PACKAGE_URL</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$CURRENT_BUILD_TIME</span>&quot;</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #ff0000;">&quot;<span style="color: #007800;">$LATEST_BUILD_TIME</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    uprint <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;New version available, build time: \e[36m<span style="color: #007800;">$LATEST_BUILD_TIME</span>\e[0m&quot;</span>
<span style="color: #000000; font-weight: bold;">else</span> 
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #ff0000;">&quot;--force&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
        uprint <span style="color: #ff0000;">&quot;You are using the latest snapshot version.&quot;</span>
        <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span>
    <span style="color: #000000; font-weight: bold;">else</span> 
        uprint <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;\e[31mForce to update local php version.\e[0m&quot;</span>
    <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #666666; font-style: italic;">## Delete if file already exists</span>
<span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #007800;">$package</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #007800;">$?</span> <span style="color: #660033;">-eq</span> <span style="color: #000000;">0</span>; <span style="color: #000000; font-weight: bold;">then</span>
    uprint <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Performing: rm -f \<span style="color: #780078;">`ls $package\`</span> ... &quot;</span>
    <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #007800;">$package</span><span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;\e[32m[OK]\e[0m&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #666666; font-style: italic;">## Get latest php5 binary package</span>
uprint <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Downloading latest php binary package ... &quot;</span>
<span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #660033;">-q</span> <span style="color: #007800;">$PACKAGE_URL</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;\e[32m[OK]\e[0m&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">## Extracting</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$package</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #666666; font-style: italic;"># kill php processes</span>
    <span style="color: #000000; font-weight: bold;">for</span> php_pid <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">ps</span> <span style="color: #660033;">-as</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> php <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $1}'</span><span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #000000; font-weight: bold;">do</span> 
        <span style="color: #c20cb9; font-weight: bold;">kill</span> <span style="color: #660033;">-9</span> <span style="color: #007800;">$php_pid</span>
    <span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
    uprint <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Extracting ... &quot;</span>
    <span style="color: #c20cb9; font-weight: bold;">unzip</span> <span style="color: #660033;">-o</span> <span style="color: #007800;">$package</span> <span style="color: #660033;">-x</span> <span style="color: #660033;">-d</span> <span style="color: #007800;">$INSTALL_PATH</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;\e[32m[OK]\e[0m&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$LATEST_BUILD_TIME</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #007800;">$BUILD_TIME_FILE</span>
&nbsp;
    uprint <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Cleaning up ... &quot;</span>
    <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$package</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;\e[32m[OK]\e[0m&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #666666; font-style: italic;">## Fixed cygwin permissions</span>
icacls D:<span style="color: #000000; font-weight: bold;">/</span>php5-nts <span style="color: #000000; font-weight: bold;">/</span>reset <span style="color: #000000; font-weight: bold;">/</span>T <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
&nbsp;
<span style="color: #666666; font-style: italic;"># vim: set expandtab tabstop=4 shiftwidth=4:</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.phpvim.net/journal/update-php5-with-shell.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>检测 Cygwin 最快的镜像站点</title>
		<link>http://www.phpvim.net/journal/test-fastest-cygwin-mirror.html</link>
		<comments>http://www.phpvim.net/journal/test-fastest-cygwin-mirror.html#comments</comments>
		<pubDate>Sat, 26 Dec 2009 21:32:00 +0000</pubDate>
		<dc:creator>Verdana Mu</dc:creator>
				<category><![CDATA[Journal]]></category>
		<category><![CDATA[Cygwin]]></category>
		<category><![CDATA[Shell]]></category>

		<guid isPermaLink="false">http://www.phpvim.net/?p=503</guid>
		<description><![CDATA[
这是一个 shell 脚本，所以首先你需要安装一个基本的 Cygwin 环境，当然还有 curl。
原理很简单，先从 cygwin.com 下载最新的 mirrors.lst 镜像列表，简单处理一下后，利用 curl 以此检测每个站点的连接速度，并将结果记录下来，最后再排个序，显示出最快的几个站点。   
在使用的过程中，我发现检测到的最快的 mirror，实际上使用速度并不一定是最快的，这可能和服务器有关系，毕竟 curl 检测的时间只是读取 mirror 首页的时间。不过每个 mirror 一般都有两组服务器——http &#038; ftp，如果其中一个速度不怎么样，那么可以选择另外一个试试看。


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/sh
&#160;
# cygwin-mirrors.sh
# 该脚本用于查找 Cygwin 的最快镜像
&#160;
timeout=5           # 超时时间
mirrors_count=5     # 显示最快的几个镜像
PROG=`basename $0`  # 程序名称
&#160;
## 显示 usage
_usage&#40;&#41; &#123;
   [...]]]></description>
			<content:encoded><![CDATA[<div class="inline right"><a href="http://www.phpvim.net/wp-content/uploads/2009/12/cygwin-mirrors-sh.png" onclick="return hs.expand(this);" class="highslide-image"><img src="http://www.phpvim.net/wp-content/uploads/2009/12/cygwin-mirrors-sh-300x172.png" alt="检测 Cygwin 的最快镜像站" title="Click to enlarge" class="sided" /></a></div>
<p>这是一个 shell 脚本，所以首先你需要安装一个基本的 Cygwin 环境，当然还有 curl。</p>
<p>原理很简单，先从 cygwin.com 下载最新的 mirrors.lst 镜像列表，简单处理一下后，利用 curl 以此检测每个站点的连接速度，并将结果记录下来，最后再排个序，显示出最快的几个站点。 <img src='http://www.phpvim.net/wp-includes/images/smilies/icon_redface.gif' alt=':oops:' class='wp-smiley' />  </p>
<p>在使用的过程中，我发现检测到的最快的 mirror，实际上使用速度并不一定是最快的，这可能和服务器有关系，毕竟 curl 检测的时间只是读取 mirror 首页的时间。不过每个 mirror 一般都有两组服务器——http &#038; ftp，如果其中一个速度不怎么样，那么可以选择另外一个试试看。</p>
<p><span id="more-503"></span></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># cygwin-mirrors.sh</span>
<span style="color: #666666; font-style: italic;"># 该脚本用于查找 Cygwin 的最快镜像</span>
&nbsp;
<span style="color: #007800;">timeout</span>=<span style="color: #000000;">5</span>           <span style="color: #666666; font-style: italic;"># 超时时间</span>
<span style="color: #007800;">mirrors_count</span>=<span style="color: #000000;">5</span>     <span style="color: #666666; font-style: italic;"># 显示最快的几个镜像</span>
<span style="color: #007800;">PROG</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">basename</span> $<span style="color: #000000;">0</span><span style="color: #000000; font-weight: bold;">`</span>  <span style="color: #666666; font-style: italic;"># 程序名称</span>
&nbsp;
<span style="color: #666666; font-style: italic;">## 显示 usage</span>
_usage<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Usage: <span style="color: #007800;">${PROG}</span> [-t &lt;timeout&gt;] [-p &lt;mirrors_count&gt;] [-h]&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">exit</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">## 检查参数并赋值</span>
_assign<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;$1&quot;</span> == <span style="color: #ff0000;">&quot;timeout&quot;</span> <span style="color: #660033;">-o</span> <span style="color: #ff0000;">&quot;$1&quot;</span> == <span style="color: #ff0000;">&quot;mirrors_count&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;$2&quot;</span> =~ ^<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span>:digit:<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>+$ <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
            <span style="color: #7a0874; font-weight: bold;">let</span> $<span style="color: #000000;">1</span>=$<span style="color: #000000;">2</span>
        <span style="color: #000000; font-weight: bold;">else</span>
            <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;$1 should be a number&quot;</span>
            <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
        <span style="color: #000000; font-weight: bold;">fi</span>
    <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">## 处理参数</span>
<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #7a0874; font-weight: bold;">getopts</span> <span style="color: #ff0000;">&quot;:t:p:h-:&quot;</span> optval
<span style="color: #000000; font-weight: bold;">do</span>
    <span style="color: #000000; font-weight: bold;">case</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$optval</span>&quot;</span> <span style="color: #000000; font-weight: bold;">in</span>
        t<span style="color: #7a0874; font-weight: bold;">&#41;</span>   _assign timeout <span style="color: #800000;">${OPTARG}</span> <span style="color: #000000; font-weight: bold;">;;</span>
        p<span style="color: #7a0874; font-weight: bold;">&#41;</span>   _assign mirrors_count <span style="color: #800000;">${OPTARG}</span> <span style="color: #000000; font-weight: bold;">;;</span>
        h<span style="color: #7a0874; font-weight: bold;">&#41;</span>   _usage <span style="color: #000000; font-weight: bold;">;;</span>
        <span style="color: #ff0000;">&quot;-&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Unknown option: '--<span style="color: #007800;">${OPTARG}</span>'&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">2</span>;            _usage <span style="color: #000000; font-weight: bold;">;;</span>
        <span style="color: #ff0000;">&quot;:&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Option '-<span style="color: #007800;">${OPTARG}</span>' requires an argument&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">2</span>; _usage <span style="color: #000000; font-weight: bold;">;;</span>
        <span style="color: #ff0000;">&quot;?&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Unknown option: '-<span style="color: #007800;">${OPTARG}</span>'&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">2</span>;             _usage <span style="color: #000000; font-weight: bold;">;;</span>
        <span style="color: #666666; font-style: italic;">## Should not occur</span>
        <span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>   <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Unknown error while processing options&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">2</span>;   _usage <span style="color: #000000; font-weight: bold;">;;</span>
    <span style="color: #000000; font-weight: bold;">esac</span>
<span style="color: #000000; font-weight: bold;">done</span>
<span style="color: #7a0874; font-weight: bold;">shift</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">expr</span> <span style="color: #800000;">${OPTIND}</span> - <span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">## 检查用户是否安装了 curl</span>
<span style="color: #007800;">CURL</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">which</span> curl <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null<span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$CURL</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Need to install the curl package.&quot;</span>; <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">## 读取镜像站点</span>
<span style="color: #007800;">mirrors</span>=<span style="color: #000000; font-weight: bold;">`</span>curl <span style="color: #660033;">--silent</span> http:<span style="color: #000000; font-weight: bold;">//</span>cygwin.com<span style="color: #000000; font-weight: bold;">/</span>mirrors.lst <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">cut</span> <span style="color: #660033;">-d</span><span style="color: #ff0000;">';'</span> -f1<span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
<span style="color: #666666; font-style: italic;">## 使用 CURL 依次检测时间</span>
<span style="color: #007800;">results</span>=<span style="color: #ff0000;">''</span>
<span style="color: #000000; font-weight: bold;">for</span> mirror <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #007800;">$mirrors</span>; <span style="color: #000000; font-weight: bold;">do</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Checking <span style="color: #007800;">${mirror}</span> ... &quot;</span>
    <span style="color: #007800;"><span style="color: #000000; font-weight: bold;">time</span></span>=<span style="color: #000000; font-weight: bold;">`</span>curl <span style="color: #660033;">-m</span> <span style="color: #007800;">$timeout</span> <span style="color: #660033;">-s</span> <span style="color: #660033;">-o</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null <span style="color: #660033;">-w</span> <span style="color: #000000; font-weight: bold;">%</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>time_total<span style="color: #7a0874; font-weight: bold;">&#125;</span> <span style="color: #007800;">$mirror</span><span style="color: #000000; font-weight: bold;">`</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$time</span>&quot;</span> = <span style="color: #ff0000;">&quot;0.000&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;\e[31mfail\e[0m&quot;</span>
    <span style="color: #000000; font-weight: bold;">else</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;\e[32m<span style="color: #007800;">$time</span>\e[0m&quot;</span>
        <span style="color: #007800;">results</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${results}</span>\e[32m<span style="color: #007800;">${time}</span>\e[0m - <span style="color: #007800;">${mirror}</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
    <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>检测结果:&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-e</span> <span style="color: #007800;">$results</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sort</span> <span style="color: #660033;">-n</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'1d'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">head</span> -<span style="color: #007800;">$mirrors_count</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># vim: set expandtab tabstop=4 shiftwidth=4:</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.phpvim.net/journal/test-fastest-cygwin-mirror.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>误删 site-packages 从来导致 YUM 无法使用的修复方法</title>
		<link>http://www.phpvim.net/journal/centos-repair-yum-service.html</link>
		<comments>http://www.phpvim.net/journal/centos-repair-yum-service.html#comments</comments>
		<pubDate>Thu, 26 Nov 2009 10:39:48 +0000</pubDate>
		<dc:creator>Verdana Mu</dc:creator>
				<category><![CDATA[Journal]]></category>
		<category><![CDATA[Centos]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Yum]]></category>

		<guid isPermaLink="false">http://www.phpvim.net/?p=499</guid>
		<description><![CDATA[在客户的服务器上面折腾 trac ，但 PySqlite2 一直编译出错，于是想删掉 PySqlite2 通过其它方式安装。
很自然的想输入如下命令：
#> rm -rf /usr/lib/python2.4/site-packages/PySqlite2
天太冷，没想到手一抖，变成了：
#> rm -rf /usr/lib/python2.4/site-packages/ PySqlite2
于是悲剧就这样发生了，site-packages 瞬间消失&#8230;  
Centos 中很多重要服务都会依赖 Python，这个白痴的手误虽然不至于摧毁整个系统，但某些服务显然是不能用了，比如 Yum。

尝试输入 Yum 命令，显示如下错误：

There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:

No module named yum

Please install a package which provides this module, or
verify that the module [...]]]></description>
			<content:encoded><![CDATA[<p>在客户的服务器上面折腾 trac ，但 PySqlite2 一直编译出错，于是想删掉 PySqlite2 通过其它方式安装。</p>
<p>很自然的想输入如下命令：</p>
<pre>#> rm -rf /usr/lib/python2.4/site-packages/PySqlite2</pre>
<p>天太冷，没想到手一抖，变成了：</p>
<pre>#> rm -rf /usr/lib/python2.4/site-packages/ PySqlite2</pre>
<p>于是悲剧就这样发生了，site-packages 瞬间消失&#8230; <img src='http://www.phpvim.net/wp-includes/images/smilies/icon_cry.gif' alt=':cry:' class='wp-smiley' /> </p>
<p>Centos 中很多重要服务都会依赖 Python，这个白痴的手误虽然不至于摧毁整个系统，但某些服务显然是不能用了，比如 Yum。</p>
<p><span id="more-499"></span></p>
<p>尝试输入 Yum 命令，显示如下错误：</p>
<pre>
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:

No module named yum

Please install a package which provides this module, or
verify that the module is installed correctly.

It's possible that the above module doesn't match the
current version of Python, which is:
2.4.3 (#1, Sep  3 2009, 15:37:12)
    [GCC 4.1.2 20080704 (Red Hat 4.1.2-46)]

    If you cannot solve this problem yourself, please go to
    the yum faq at:

http://wiki.linux.duke.edu/YumFaq
</pre>
<p>那么首先要做的是修复 Yum 服务，Yum 修复后，就可以更方便的重装一些被损坏的 package。</p>
<p>嗯，幸运的是，rpm 命令并没有受到影响！</p>
<p>访问 Centos 官网：<a href="http://mirror.centos.org/centos-5/5.4/os/i386/CentOS/">http://mirror.centos.org/centos-5/5.4/os/i386/CentOS/</a>（32位系统，64位请移步到 <a href="http://mirror.centos.org/centos-5/5.4/os/x86_64/CentOS/">&#8230;/os/x86_64/CentOS/</a>），下载对应版本的相关 rpm 包，重新安装即可。</p>
<p>注意 Centos 版本号，如果不知道，可以通过如下命令得到：</p>
<pre>
#> cat /etc/issue
CentOS release 5.4 (Final)
Kernel \r on an \m
</pre>
<p>一番尝试之后，发现有 N 个 package 需要重新安装，这里就不写尝试过程，直接把结果做成了 shell script，运行即可。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #007800;">URL</span>=http:<span style="color: #000000; font-weight: bold;">//</span>mirror.centos.org<span style="color: #000000; font-weight: bold;">/</span>centos-<span style="color: #000000;">5</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">5.4</span><span style="color: #000000; font-weight: bold;">/</span>os<span style="color: #000000; font-weight: bold;">/</span>i386<span style="color: #000000; font-weight: bold;">/</span>CentOS<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #000000; font-weight: bold;">for</span> package <span style="color: #000000; font-weight: bold;">in</span> \
        python-2.4.3-27.el5.i386.rpm \
        python-devel-2.4.3-27.el5.i386.rpm \
        python-elementtree-1.2.6-5.i386.rpm \
        python-iniparse-0.2.3-4.el5.noarch.rpm \
        python-setuptools-0.6c5-2.el5.noarch.rpm \
        python-sqlite-1.1.7-1.2.1.i386.rpm \
        python-urlgrabber-3.1.0-5.el5.noarch.rpm \
        rpm-python-4.4.2.3-18.el5.i386.rpm \
        yum-3.2.22-20.el5.centos.noarch.rpm \
        yum-metadata-parser-1.1.2-3.el5.centos.i386.rpm \
<span style="color: #000000; font-weight: bold;">do</span> 
    rpm <span style="color: #660033;">-Uvh</span> <span style="color: #660033;">--replacepkgs</span> <span style="color: #007800;">$URL</span><span style="color: #007800;">$package</span>
<span style="color: #000000; font-weight: bold;">done</span></pre></td></tr></table></div>

<p>注意 rpm 命令，必须要追加 &#8211;replacepkgs 参数，强制其重新安装，否则 rpm 会报告说 package 已安装。</p>
<p>如果仍然无法运行 Yum，则运行 Python，import yum，查询下缺少什么东西。</p>
<pre>
#> python
Python 2.4.3 (#1, Sep  3 2009, 15:37:12)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import yum
</pre>
<p>如果仍有 package 缺失，import yum，会提示相关的错误，查找对应的 rpm，装上即可，重复此过程，直到 yum 正常。</p>
<p>Yum 修复完毕之后，运行：</p>
<pre>
yum update
</pre>
<p>更新一下刚刚重新安装上去的 rpm。</p>
<p>除了 Yum，很可能还有其它的服务受到牵连（比如 sqlite 和 php 等），索性把所有和 Python 有关系的 package 都重装一下。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #007800;">packages</span>=<span style="color: #000000; font-weight: bold;">`</span>yum list installed <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> python <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $1}'</span><span style="color: #000000; font-weight: bold;">`</span>
yum reinstall <span style="color: #007800;">$packages</span></pre></td></tr></table></div>

<p>嗯，差不多就是这样了，继续装 trac &#8230; 这玩意真难装。<br />
 <img src='http://www.phpvim.net/wp-includes/images/smilies/icon_mrgreen.gif' alt=':mrgreen:' class='wp-smiley' />  </p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpvim.net/journal/centos-repair-yum-service.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>[PHP] configure: warning: lemon versions supported for regeneration of libsqlite parsers: 1.0 (found: none)</title>
		<link>http://www.phpvim.net/php/php-configure-warning-lemon-versions-supported-for-regeneration-of-libsqlite-parsers-1-0-found-none.html</link>
		<comments>http://www.phpvim.net/php/php-configure-warning-lemon-versions-supported-for-regeneration-of-libsqlite-parsers-1-0-found-none.html#comments</comments>
		<pubDate>Sat, 31 Oct 2009 13:34:10 +0000</pubDate>
		<dc:creator>Verdana Mu</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Cygwin]]></category>

		<guid isPermaLink="false">http://www.phpvim.net/?p=493</guid>
		<description><![CDATA[在 cygwin 中编译 PHP 时遇到下面的问题：

1
2
3
checking for lemon... no
configure: warning: lemon versions supported for regeneration of \
 libsqlite parsers: 1.0 &#40;found: none&#41;.

解决方法：

1
2
3
wget http://www.sqlite.org/cvstrac/getfile/sqlite/tool/lemon.c
gcc -o lemon lemon.c
mv lemon /usr/local/bin

重新运行 ./configure 后，问题解决。
]]></description>
			<content:encoded><![CDATA[<p>在 cygwin 中编译 PHP 时遇到下面的问题：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">checking <span style="color: #000000; font-weight: bold;">for</span> lemon... no
configure: warning: lemon versions supported <span style="color: #000000; font-weight: bold;">for</span> regeneration of \
 libsqlite parsers: <span style="color: #000000;">1.0</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>found: none<span style="color: #7a0874; font-weight: bold;">&#41;</span>.</pre></td></tr></table></div>

<p>解决方法：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>www.sqlite.org<span style="color: #000000; font-weight: bold;">/</span>cvstrac<span style="color: #000000; font-weight: bold;">/</span>getfile<span style="color: #000000; font-weight: bold;">/</span>sqlite<span style="color: #000000; font-weight: bold;">/</span>tool<span style="color: #000000; font-weight: bold;">/</span>lemon.c
<span style="color: #c20cb9; font-weight: bold;">gcc</span> <span style="color: #660033;">-o</span> lemon lemon.c
<span style="color: #c20cb9; font-weight: bold;">mv</span> lemon <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin</pre></td></tr></table></div>

<p>重新运行 ./configure 后，问题解决。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpvim.net/php/php-configure-warning-lemon-versions-supported-for-regeneration-of-libsqlite-parsers-1-0-found-none.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>影驰 8800GT 的花屏原因</title>
		<link>http://www.phpvim.net/journal/8800gt-screen-mess.html</link>
		<comments>http://www.phpvim.net/journal/8800gt-screen-mess.html#comments</comments>
		<pubDate>Mon, 08 Jun 2009 18:03:08 +0000</pubDate>
		<dc:creator>Verdana Mu</dc:creator>
				<category><![CDATA[Journal]]></category>

		<guid isPermaLink="false">http://www.phpvim.net/?p=478</guid>
		<description><![CDATA[2年前 G92 核心推出后，关于 8800GT 的问题就不断，这个问题就是——花屏，原因众说纷纭，却没有定论，而最终 NV 跳出来说 G92 没质量问题，有问题是因为用户 OC 所致，只要将频率调整为公版默认频率即可。OC 是导致花屏的主要原因，当然也不是唯一的原因。
去年4月份的时候，我购进了我的第一块 8800GT——影驰的 8800GT 游戏盒子，之所以说“第一块”，是因为这块显卡在服役不到 1年的时间就寿终正寝了。当时花屏了几次，然后在我正在爽 《COD5》时，屏幕暗下&#8230;&#8230;没有任何 OC 行为，温度也不高，因为当时是11月份，屋子里面冷的都要结冰了，我只能认为这是显卡本身的质量问题。返修回来以后，用了不到1个小时，再次黑屏，无法点亮系统。影驰的代理商也没有2次维修，而是给我调换了一块新的 8800GT，看做工似乎和第一块不是一批货，拿到新卡大约1个多月以后，天气开始慢慢变热，而我的花屏噩梦也终于降临了！

开始是《魔兽世界》花屏，横向、纵向线条甚至是满屏幕杂色雪花点，并且频繁出现 NV 显示器驱动重启的状况，WOW 几乎是隔几分钟就重启一次或者是被迫关闭。WOW 算是好的，开《鬼泣》、《COD5》这样的游戏，几乎1，2分钟内就会花屏，有时候甚至直接蓝屏死机，最终发展到连 2D 情况下，比如看网页或者待机的时候，都会花屏，真是把人逼疯啊！
查询了 N 多的资料发现，造成 8800GT 花屏的原因大约如下：
显卡供电不足
散热问题，或 OC 导致显存过热
内存兼容性问题
驱动兼容性问题
金手指氧化，PCI-E 插槽有异物接触不良
可是这些我都做了详细的排查，很遗憾，这些都不是造成我这块 8800GT 花屏的原因，但花屏肯定是卡本身的原因，因为我拿到别人的机器上面也会出现花屏，而花屏的时候，温度都不算太高，一般都是大约 60 多度左右的时候，就开始花了，这个温度显然又很正常。我甚至打开了将所有的配件全部拆开，清理掉了所有的灰尘，但问题丝毫没有改善。虽然不是灰尘的原因，但是最终却因此解决了花瓶的问题，因为我心不在焉的清理 CPU 飞尘的时候，一把把所有的硅胶都摸到的了手上，只好跑去买了新的硅胶，重新给涂上。几天以后当我再次面对着花屏无可奈何叹气的时候，目光落在了那没用完的硅胶上面，我突然想到这块显卡是调换回来的，鬼知道在仓库里面呆了多久？GPU 上面的硅胶会不会有问题呢？ 果然！拆开显卡以后发现，硅胶已经快干涸了，而硅胶干涸变质的话，显然对散热有很大影响，将老的硅胶仔细的清理干净后，涂上了新的硅胶。可是开机打开游戏后，温度却只升不降，直接飚上 7,80 度，基本上换了硅胶以后，不管待机还是开游戏，温度都比未换之前要高出一些，可是换了硅胶后，却再也没有花屏了。
PS: 此卡已报废，暂时弄了个 9600GT 先用着了，╮(╯▽╰)╭
]]></description>
			<content:encoded><![CDATA[<p>2年前 G92 核心推出后，关于 8800GT 的问题就不断，这个问题就是——花屏，原因众说纷纭，却没有定论，而最终 NV 跳出来说 G92 没质量问题，有问题是因为用户 OC 所致，只要将频率调整为公版默认频率即可。OC 是导致花屏的主要原因，当然也不是唯一的原因。</p>
<p>去年4月份的时候，我购进了我的第一块 8800GT——影驰的 8800GT 游戏盒子，之所以说“第一块”，是因为这块显卡在服役不到 1年的时间就寿终正寝了。当时花屏了几次，然后在我正在爽 《COD5》时，屏幕暗下&#8230;&#8230;没有任何 OC 行为，温度也不高，因为当时是11月份，屋子里面冷的都要结冰了，我只能认为这是显卡本身的质量问题。返修回来以后，用了不到1个小时，再次黑屏，无法点亮系统。影驰的代理商也没有2次维修，而是给我调换了一块新的 8800GT，看做工似乎和第一块不是一批货，拿到新卡大约1个多月以后，天气开始慢慢变热，而我的花屏噩梦也终于降临了！</p>
<p><span id="more-478"></span></p>
<p>开始是《魔兽世界》花屏，横向、纵向线条甚至是满屏幕杂色雪花点，并且频繁出现 NV 显示器驱动重启的状况，WOW 几乎是隔几分钟就重启一次或者是被迫关闭。WOW 算是好的，开《鬼泣》、《COD5》这样的游戏，几乎1，2分钟内就会花屏，有时候甚至直接蓝屏死机，最终发展到连 2D 情况下，比如看网页或者待机的时候，都会花屏，真是把人逼疯啊！</p>
<p>查询了 N 多的资料发现，造成 8800GT 花屏的原因大约如下：</p>
<p><strong>显卡供电不足</strong><br />
<strong>散热问题，或 OC 导致显存过热</strong><br />
<strong>内存兼容性问题</strong><br />
<strong>驱动兼容性问题</strong><br />
<strong>金手指氧化，PCI-E 插槽有异物接触不良</strong></p>
<p>可是这些我都做了详细的排查，很遗憾，这些都不是造成我这块 8800GT 花屏的原因，但花屏肯定是卡本身的原因，因为我拿到别人的机器上面也会出现花屏，而花屏的时候，温度都不算太高，一般都是大约 60 多度左右的时候，就开始花了，这个温度显然又很正常。我甚至打开了将所有的配件全部拆开，清理掉了所有的灰尘，但问题丝毫没有改善。虽然不是灰尘的原因，但是最终却因此解决了花瓶的问题，因为我心不在焉的清理 CPU 飞尘的时候，一把把所有的硅胶都摸到的了手上，只好跑去买了新的硅胶，重新给涂上。几天以后当我再次面对着花屏无可奈何叹气的时候，目光落在了那没用完的硅胶上面，我突然想到这块显卡是调换回来的，鬼知道在仓库里面呆了多久？GPU 上面的硅胶会不会有问题呢？ 果然！拆开显卡以后发现，<strong>硅胶已经快干涸了</strong>，而硅胶干涸变质的话，显然对散热有很大影响，将老的硅胶仔细的清理干净后，涂上了新的硅胶。可是开机打开游戏后，温度却只升不降，直接飚上 7,80 度，基本上换了硅胶以后，不管待机还是开游戏，温度都比未换之前要高出一些，可是换了硅胶后，却再也没有花屏了。</p>
<p>PS: 此卡已报废，暂时弄了个 9600GT 先用着了，╮(╯▽╰)╭</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpvim.net/journal/8800gt-screen-mess.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
