<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet href='http://feed.leafduo.com/styles/feedsky1.xsl' type='text/xsl' ?><!--这是一个由Feedsy提供技术支持的Feed，为了提高读者阅读的体验，以及满足用户美化自己Feed的需要，我们设计了多种精美的Feed模板，提供给大家选择，所有最终呈现出来的样式，皆由用户自愿选择使用，未经许可，任何团体和个人，请不要擅自修改样式或者盗用，这是对于用户选择权的尊重。--><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:fs="http://www.feedsky.com/namespace/feed" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><atom:link href="http://feed.leafduo.com" type="application/rss+xml" rel="self"></atom:link><fs:self_link href="http://feed.feedsky.com/LeafDuo" type="application/rss+xml"></fs:self_link><lastBuildDate>Sat, 06 Aug 2011 07:34:29 GMT</lastBuildDate><title>Leaf Duo</title><description>All About My Life and Information Technology</description><link>http://blog.leafduo.com</link><sy:updatePeriod>hourly</sy:updatePeriod><sy:updateFrequency>1</sy:updateFrequency><language>en</language><pubDate>Sat, 06 Aug 2011 07:34:29 GMT</pubDate><item><title>iOS dev: 将 Xcode 中的 CODE SIGN IDENTITY 分离出 VCS</title><link>http://blog.leafduo.com/29/ios-dev-take-code-sign-identity-out-of-vcs/</link><content:encoded>&lt;p&gt;做 iOS 开发的时候每个人都有不同的开发者证书/私钥，只有通过这个私钥进行代码签名之后 app 才能在 iPhone 上运行起来。项目中用来确定使用哪个私钥签名的配置文件是 &lt;code&gt;project.pbxproj&lt;/code&gt;，由于它也记录了项目地很多其它信息，所以它往往会出现在版本控制系统中，这样就造成只有一个人能够成功地签名。好在我们可以通过 &lt;code&gt;.xcconfig&lt;/code&gt; 文件来将这个配置抽离出来。&lt;/p&gt;
&lt;p&gt;首先新建一个文件(Cmd+N)，在 Other 中选择 Configuration Settings File，新建一个配置文件 &lt;code&gt;CodeSign.xcconfig&lt;/code&gt;。在这个文件中添加一行：&lt;br /&gt;
&lt;code&gt;CODE_SIGN_IDENTITY = iPhone Developer: 人甲 路 (XXXXXXXXXX)&lt;/code&gt;，其中证书的名称可以在 Keychain Access 里面找到。&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://picasaweb.google.com/lh/photo/lkf9kEWgThZpL63-LH9fjA?feat=embedwebsite&quot;&gt;&lt;img src=&quot;https://lh6.googleusercontent.com/-ZoEoKlecJX0/Tjzrvfr0SlI/AAAAAAAACds/CsBs8CiqWg8/s640/Screen%252520Shot%2525202011-08-06%252520at%2525203.22.07%252520PM.png&quot; height=&quot;426&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;之后删除原来 &lt;code&gt;project.pbxproj&lt;/code&gt; 里面的签名，直接在 build settings 里面删除就好，注意 project 和 target 的都要删掉（都选中之后 Cmd+delete）。&lt;/p&gt;
&lt;p&gt;最后在 Project 的 info 中，看到 Configuration 一栏，在 Based on Configuration File，选择我们创建的文件 CodeSign。&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://picasaweb.google.com/lh/photo/esruPhlQSDvSS3PxLhYrIg?feat=embedwebsite&quot;&gt;&lt;img src=&quot;https://lh4.googleusercontent.com/-u_Oi-idbkYs/TjztLkNdUyI/AAAAAAAACec/lNHZI9rKsU0/s640/Screen%252520Shot%2525202011-08-06%252520at%2525203.15.22%252520PM.png&quot; height=&quot;196&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;最后在 build settings 里面应该是这个样子：（项目和目标那一栏都是空的）&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://picasaweb.google.com/lh/photo/MLqZmfyGH8p2CLvHkYQ-Dg?feat=embedwebsite&quot;&gt;&lt;img src=&quot;https://lh3.googleusercontent.com/-o1g7_aMfQ6w/Tjzswj-QZpI/AAAAAAAACeE/VujRXPlMgTw/s640/Screen%252520Shot%2525202011-08-06%252520at%2525203.16.09%252520PM.png&quot; height=&quot;61&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;最后注意不要把 &lt;code&gt;CodeSign.xcconfig&lt;/code&gt; check in 进去。&lt;/p&gt;
&lt;p&gt;参考：&lt;a href=&quot;http://respectthecode.co/2011/06/11/xcode-4-and-xcconfig-files/&quot;&gt;http://respectthecode.co/2011/06/11/xcode-4-and-xcconfig-files/&lt;/a&gt;&lt;/p&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/543889104/LeafDuo/feedsky/s.gif?r=http://blog.leafduo.com/29/ios-dev-take-code-sign-identity-out-of-vcs/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</content:encoded><wfw:commentRss>http://blog.leafduo.com/29/ios-dev-take-code-sign-identity-out-of-vcs/feed/</wfw:commentRss><slash:comments>0</slash:comments><description>做 iOS 开发的时候每个人都有不同的开发者证书/私钥，只有通过这个私钥进行代码签名之后 app 才能在 iPhone 上运行起来。项目中用来确定使用哪个私钥签名的配置文件是 project.pbxproj，由于它也记录了项目地很多其它信息，所以它往往会出现在版本控制系统中，这样就造成只有一个人能够成功地签名。好在我们可以通过 .xcconfig 文件来将这个配置抽离出来。 首先新建一个文件(Cmd+N)，在 Other 中选择 Configuration Settings File，新建一个配置文件 CodeSign.xcconfig。在这个文件中添加一行： CODE_SIGN_IDENTITY = iPhone Developer: 人甲 路 (XXXXXXXXXX)，其中证书的名称可以在 Keychain Access 里面找到。 之后删除原来 project.pbxproj 里面的签名，直接在 build settings 里面删除就好，注意 project 和 target 的都要删掉（都选中之后 Cmd+delete）。 最后在 Project &amp;#8230; &lt;a href=&quot;http://blog.leafduo.com/29/ios-dev-take-code-sign-identity-out-of-vcs/&quot;&gt;Continue reading &lt;span class=&quot;meta-nav&quot;&gt;&amp;#8594;&lt;/span&gt;&lt;/a&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/543889104/LeafDuo/feedsky/s.gif?r=http://blog.leafduo.com/29/ios-dev-take-code-sign-identity-out-of-vcs/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</description><category>Information Technology</category><category>iPhone</category><category>iOS</category><category>code sign</category><category>Xcode</category><pubDate>Sat, 06 Aug 2011 15:34:29 +0800</pubDate><author>Leaf Duo</author><comments>http://blog.leafduo.com/29/ios-dev-take-code-sign-identity-out-of-vcs/#comments</comments><guid isPermaLink="false">http://blog.leafduo.com/?p=285</guid><dc:creator>Leaf Duo</dc:creator><fs:srclink>http://blog.leafduo.com/29/ios-dev-take-code-sign-identity-out-of-vcs/</fs:srclink><fs:srcfeed>http://blog.leafduo.com/feed</fs:srcfeed><fs:itemid>feedsky/LeafDuo/~7828943/543889104/4904878</fs:itemid></item><item><title>Lion 对加密卷的支持</title><link>http://blog.leafduo.com/48/lion-encrypted-volume-support/</link><content:encoded>&lt;p&gt;今天想给硬盘数据做备份，毕竟硬盘已经用了两年了，不用查 SMART 信息也知道他已经老了，虽然诸如代码之类的都有很多备份，但是还是有些文档、照片需要备份。&lt;/p&gt;
&lt;p&gt;又阴差阳错得到一块老旧移动硬盘，灰常好啊。开工吧。&lt;/p&gt;
&lt;p&gt;拿来的时候是 NTFS，第一件事情就是改成 HFS+，拿 Disk Utility 格式化的时候发现多出了加密的选项，不用多说，先试试。不得不说这个 Lion 的 GM 版本还不够到正式版的水平，这个输入密码的输入框如果输入超过十位的密码就会 crash，这个完全不能忍受啊，尝试了半天发现先在别的地方输入好然后复制过来就可以了。（好吧，我不得不说我写文章想截图的时候这个 bug 又神秘的消失了）&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://picasaweb.google.com/lh/photo/jeCgDHO8qJqbYuM4Guqctg?feat=embedwebsite&quot;&gt;&lt;img src=&quot;https://lh4.googleusercontent.com/-ryRM1jL_il0/TiMs7wbtP1I/AAAAAAAACcY/SSqM8_GCDko/s640/diskutil.png&quot; height=&quot;528&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;这样格式化好了之后每次插入移动硬盘的时候都会提示你输入密码才能访问，像是做备份这种应用就会安全很多。&lt;/p&gt;
&lt;p&gt;之后我就发现加密卷的密码无法修改，我猜测这种加密是用密码加密一个密钥，再用密钥加密数据的，应该可以修改密码，现在无法修改的原因应该是 Apple 还没想好在哪里放这个功能，也或许 Apple 不会给这个功能提供 GUI，那我们转战 CLI 吧，Disk Utility 对应的命令行工具是 diskutil，里面提供了很多 GUI 中没有的功能。鼓捣一会之后发现 diskutil 有个叫做 CoreStorage 的模块，进一步发现 &lt;code&gt;diskutil coreStorage changeVolumePassphrase&lt;/code&gt; 可以修改 CoreStorage 卷的密码，其中所需的卷 UUID 可以通过 &lt;code&gt;diskutil coreStorage list&lt;/code&gt; 获得。&lt;/p&gt;
&lt;p&gt;可以看得出，CoreStorage 又是苹果推的一种新技术，看 diskutil 里面的用语（PV、LV）推测是类似 LVM 的东西，Mac 以前似乎没有类似 LVM 的技术（AFAIK），网上搜索也搜索不到 CoreStorage 的相关信息，Lion 的 Developer Library 里面也是没有，最后还是在手册（man diskutil）里找到了一些信息。看完之后的感觉就是 CoreStorage 就是一个 LVM，Apple 终于有了 LVM。 &lt;img src='http://blog.leafduo.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /&gt;  不过看起来许多功能还没有开发出来接口，比如 LVM 的一些最基本的功能⋯⋯ &lt;img src='http://blog.leafduo.com/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /&gt; &lt;/p&gt;
&lt;p&gt;看来 Lion 不光是在界面上模仿 iOS（我对这点颇有不满），在底层也下了不少功夫，CoreStorage 就是在看不见的地方默默发挥作用的一个好同志啊。底层的 UNIX 配合 用户友好的界面，是 Mac 的制胜法宝，只有这样才能留住如此多的开发者和一些相当挑剔的用户（比如设计师）。底层的 BSD 也给苹果减少了许多开发的困难，可以到处抄来抄去，可以派几个人推动一下某个项目的开发（比如 LLVM），看被抄的人不爽了还过去帮助修改（比如各种 BSD）。相比之下，再大的微软也不能把所有事情做好，至少给自己增加了许多开发难度。&lt;/p&gt;
&lt;p&gt;另外，苹果你抄个 ZFS 过来吧，ZFS 多适合你现在的各种用途啊，又没有 Linux 的许可证问题，抓紧啊，I want a better filesystem!&lt;/p&gt;
&lt;p&gt;PS：最后贴上 diskutil 手册的一部分，如果你有兴趣的话。&lt;/p&gt;
&lt;p&gt;&lt;script src=&quot;https://gist.github.com/1087869.js?file=gistfile1.txt&quot;&gt;&lt;/script&gt;&lt;/p&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/543889105/LeafDuo/feedsky/s.gif?r=http://blog.leafduo.com/48/lion-encrypted-volume-support/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</content:encoded><wfw:commentRss>http://blog.leafduo.com/48/lion-encrypted-volume-support/feed/</wfw:commentRss><slash:comments>0</slash:comments><description>今天想给硬盘数据做备份，毕竟硬盘已经用了两年了，不用查 SMART 信息也知道他已经老了，虽然诸如代码之类的都有很多备份，但是还是有些文档、照片需要备份。 又阴差阳错得到一块老旧移动硬盘，灰常好啊。开工吧。 拿来的时候是 NTFS，第一件事情就是改成 HFS+，拿 Disk Utility 格式化的时候发现多出了加密的选项，不用多说，先试试。不得不说这个 Lion 的 GM 版本还不够到正式版的水平，这个输入密码的输入框如果输入超过十位的密码就会 crash，这个完全不能忍受啊，尝试了半天发现先在别的地方输入好然后复制过来就可以了。（好吧，我不得不说我写文章想截图的时候这个 bug 又神秘的消失了） 这样格式化好了之后每次插入移动硬盘的时候都会提示你输入密码才能访问，像是做备份这种应用就会安全很多。 之后我就发现加密卷的密码无法修改，我猜测这种加密是用密码加密一个密钥，再用密钥加密数据的，应该可以修改密码，现在无法修改的原因应该是 Apple 还没想好在哪里放这个功能，也或许 Apple 不会给这个功能提供 GUI，那我们转战 CLI 吧，Disk Utility 对应的命令行工具是 diskutil，里面提供了很多 GUI 中没有的功能。鼓捣一会之后发现 diskutil 有个叫做 CoreStorage 的模块，进一步发现 diskutil coreStorage changeVolumePassphrase 可以修改 CoreStorage &amp;#8230; &lt;a href=&quot;http://blog.leafduo.com/48/lion-encrypted-volume-support/&quot;&gt;Continue reading &lt;span class=&quot;meta-nav&quot;&gt;&amp;#8594;&lt;/span&gt;&lt;/a&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/543889105/LeafDuo/feedsky/s.gif?r=http://blog.leafduo.com/48/lion-encrypted-volume-support/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</description><category>CoreStorage</category><category>Information Technology</category><category>diskutil</category><category>Mac</category><category>Lion</category><pubDate>Mon, 18 Jul 2011 02:44:48 +0800</pubDate><author>Leaf Duo</author><comments>http://blog.leafduo.com/48/lion-encrypted-volume-support/#comments</comments><guid isPermaLink="false">http://blog.leafduo.com/?p=283</guid><dc:creator>Leaf Duo</dc:creator><fs:srclink>http://blog.leafduo.com/48/lion-encrypted-volume-support/</fs:srclink><fs:srcfeed>http://blog.leafduo.com/feed</fs:srcfeed><fs:itemid>feedsky/LeafDuo/~7828943/543889105/4904878</fs:itemid></item><item><title>VMWare Fusion 装 Gentoo⋯⋯</title><link>http://blog.leafduo.com/06/installing-gentoo-on-vmware-fusion/</link><content:encoded>&lt;p&gt;发现其它发行版真的没法胜任开发工作，而我又不喜欢自己编译，Ubuntu 里面的 nginx 缺少我需要用的模块，真伤心，本来想在虚拟机里弄一个不用编译的发行版来着，看样子还是得 Gentoo 出马。&lt;/p&gt;
&lt;p&gt;VMWare Fusion 又傲娇了，又是驱动问题，偷懒用 genkernel 就好了，可谁让我这么勤奋呢？&lt;/p&gt;
&lt;p&gt;lspci 告诉我们，VMWare 有个设备叫 00:10.0 SCSI storage controller: LSI Logic / Symbios Logic 53c1030 PCI-X Fusion-MPT Dual Ultra320 SCSI (rev 01)，查到对应的内核选项是 &lt;a href=&quot;http://cateee.net/lkddb/web-lkddb/FUSION.html&quot;&gt;CONFIG_FUSION&lt;/a&gt;，记得选上。这样就解决了启动的时候找不到分区的问题⋯⋯&lt;/p&gt;
&lt;p&gt;还有一个问题是，启动到一半说 Freeing unused kernel memory，然后就死掉了，是新引入的 OpenRC 的问题，解决办法在&lt;a href=&quot;http://dev.gentoo.org/~a3li/openrc.txt&quot;&gt;这里&lt;/a&gt;。&lt;/p&gt;
&lt;p&gt;Happy coding!&lt;/p&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/543889106/LeafDuo/feedsky/s.gif?r=http://blog.leafduo.com/06/installing-gentoo-on-vmware-fusion/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</content:encoded><wfw:commentRss>http://blog.leafduo.com/06/installing-gentoo-on-vmware-fusion/feed/</wfw:commentRss><slash:comments>0</slash:comments><description>发现其它发行版真的没法胜任开发工作，而我又不喜欢自己编译，Ubuntu 里面的 nginx 缺少我需要用的模块，真伤心，本来想在虚拟机里弄一个不用编译的发行版来着，看样子还是得 Gentoo 出马。 VMWare Fusion 又傲娇了，又是驱动问题，偷懒用 genkernel 就好了，可谁让我这么勤奋呢？ lspci 告诉我们，VMWare 有个设备叫 00:10.0 SCSI storage controller: LSI Logic / Symbios Logic 53c1030 PCI-X Fusion-MPT Dual Ultra320 SCSI (rev 01)，查到对应的内核选项是 CONFIG_FUSION，记得选上。这样就解决了启动的时候找不到分区的问题⋯⋯ 还有一个问题是，启动到一半说 Freeing unused kernel memory，然后就死掉了，是新引入的 OpenRC 的问题，解决办法在这里。 Happy &amp;#8230; &lt;a href=&quot;http://blog.leafduo.com/06/installing-gentoo-on-vmware-fusion/&quot;&gt;Continue reading &lt;span class=&quot;meta-nav&quot;&gt;&amp;#8594;&lt;/span&gt;&lt;/a&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/543889106/LeafDuo/feedsky/s.gif?r=http://blog.leafduo.com/06/installing-gentoo-on-vmware-fusion/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</description><category>Uncategorized</category><pubDate>Sat, 25 Jun 2011 15:26:06 +0800</pubDate><author>Leaf Duo</author><comments>http://blog.leafduo.com/06/installing-gentoo-on-vmware-fusion/#comments</comments><guid isPermaLink="false">http://blog.leafduo.com/?p=282</guid><dc:creator>Leaf Duo</dc:creator><fs:srclink>http://blog.leafduo.com/06/installing-gentoo-on-vmware-fusion/</fs:srclink><fs:srcfeed>http://blog.leafduo.com/feed</fs:srcfeed><fs:itemid>feedsky/LeafDuo/~7828943/543889106/4904878</fs:itemid></item><item><title>Installing Gentoo Linux on DELL R710</title><link>http://blog.leafduo.com/10/installing-gentoo-linux-on-dell-r710/</link><content:encoded>&lt;p&gt;公司买了一台 R710，第一次自己装服务器上的 Linux，虽说区别不是很大，但是还是很值得纪录一下的哦。&lt;/p&gt;
&lt;p&gt;服务器跟 PC 最大的区别大概就是硬件了吧，涉及到驱动的基本上就只有 RAID 控制器了吧？编译内核的时候那个纠结啊……那个启动不起来啊……真是……&lt;/p&gt;
&lt;p&gt;首先是得照着一个指南做，就是&lt;a href=&quot;http://www.gentoo.org/doc/en/gentoo-x86+raid+lvm2-quickinstall.xml&quot;&gt;这个指南&lt;/a&gt;啦，比较适合以前装过 Gentoo 的人看。这个指南是装软件 RAID 和 LVM2，我们做的是硬件 RAID，所以里面软件 RAID 相关的东西就不用安装了，比如 dm-mod 之类的就不用装了。我还是习惯把 /boot 放在 LVM 里面，其实自己有的时候也觉得没啥必要，有点犯贱的意思……如果你也希望把 /boot 放在 LVM 里面，可以参考 Gentoo Wiki 的&lt;a href=&quot;http://www.gentoo-wiki.info/HOWTO_Install_Gentoo_on_an_LVM2_root_partition&quot;&gt;这篇文章&lt;/a&gt;，不过里面的内容略微有点过时了，比如内核参数 dolvm2，现在写成 dolvm 了。一开始安装的时候忘了做 initrd，查了半天才发现，还是不细心啊。&lt;/p&gt;
&lt;p&gt;剩下的大概就是编译内核了，先随手把什么声卡驱动什么的去掉，然后重点是 RAID 驱动，一开始天真地以为 RAID 控制器的驱动是 LSI Logic MegaRAID SAS RAID Module 之类的，结果就是直接启动不起来了。后来认真起来，按照 lspci 的结果去网上找内核模块，发现应该是 &lt;a href=&quot;http://cateee.net/lkddb/web-lkddb/FUSION.html&quot;&gt;CONFIG_FUSION&lt;/a&gt; 这个选项，之后就能顺利地启动了。&lt;/p&gt;
&lt;p&gt;配置好一些基本的东西之后，还有一些硬件相关的小工具，最重要的还是 RAID 控制器的监控工具，网上找了很多，不过大多数都没法用，&lt;a href=&quot;http://hwraid.le-vert.net/wiki/LSIFusionMPT&quot;&gt;这一页&lt;/a&gt;有两个工具，都比较好用，&lt;a href=&quot;http://hwraid.le-vert.net/&quot;&gt;HWRaid&lt;/a&gt; 这个站似乎也很强大。里面提到的 lsiutil 是 LSI 官方提供的，Gentoo 源里那个似乎年久失修了，LSI 的官网上能够&lt;a href=&quot;http://www.lsi.com/DistributionSystem/User/AssetMgr.aspx?asset=51101&quot;&gt;找到&lt;/a&gt;，不过不是很好找，下载下来是二进制。还有些能改前面板 LCD 的小工具什么的，我觉得没多大用，就算了（想改的话 BIOS 里面就有）。&lt;/p&gt;
&lt;p&gt;有点后悔买了一个比较弱的 RAID 控制器，不过一切还要等有了负载再说，哈哈。&lt;/p&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/543889107/LeafDuo/feedsky/s.gif?r=http://blog.leafduo.com/10/installing-gentoo-linux-on-dell-r710/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</content:encoded><wfw:commentRss>http://blog.leafduo.com/10/installing-gentoo-linux-on-dell-r710/feed/</wfw:commentRss><slash:comments>0</slash:comments><description>公司买了一台 R710，第一次自己装服务器上的 Linux，虽说区别不是很大，但是还是很值得纪录一下的哦。 服务器跟 PC 最大的区别大概就是硬件了吧，涉及到驱动的基本上就只有 RAID 控制器了吧？编译内核的时候那个纠结啊……那个启动不起来啊……真是…… 首先是得照着一个指南做，就是这个指南啦，比较适合以前装过 Gentoo 的人看。这个指南是装软件 RAID 和 LVM2，我们做的是硬件 RAID，所以里面软件 RAID 相关的东西就不用安装了，比如 dm-mod 之类的就不用装了。我还是习惯把 /boot 放在 LVM 里面，其实自己有的时候也觉得没啥必要，有点犯贱的意思……如果你也希望把 /boot 放在 LVM 里面，可以参考 Gentoo Wiki 的这篇文章，不过里面的内容略微有点过时了，比如内核参数 dolvm2，现在写成 dolvm 了。一开始安装的时候忘了做 initrd，查了半天才发现，还是不细心啊。 剩下的大概就是编译内核了，先随手把什么声卡驱动什么的去掉，然后重点是 RAID 驱动，一开始天真地以为 RAID 控制器的驱动是 LSI &amp;#8230; &lt;a href=&quot;http://blog.leafduo.com/10/installing-gentoo-linux-on-dell-r710/&quot;&gt;Continue reading &lt;span class=&quot;meta-nav&quot;&gt;&amp;#8594;&lt;/span&gt;&lt;/a&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/543889107/LeafDuo/feedsky/s.gif?r=http://blog.leafduo.com/10/installing-gentoo-linux-on-dell-r710/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</description><category>lvm</category><category>Linux</category><category>Information Technology</category><category>RAID</category><category>Gentoo</category><category>DELL</category><pubDate>Sun, 29 May 2011 23:42:10 +0800</pubDate><author>Leaf Duo</author><comments>http://blog.leafduo.com/10/installing-gentoo-linux-on-dell-r710/#comments</comments><guid isPermaLink="false">http://blog.leafduo.com/?p=277</guid><dc:creator>Leaf Duo</dc:creator><fs:srclink>http://blog.leafduo.com/10/installing-gentoo-linux-on-dell-r710/</fs:srclink><fs:srcfeed>http://blog.leafduo.com/feed</fs:srcfeed><fs:itemid>feedsky/LeafDuo/~7828943/543889107/4904878</fs:itemid></item><item><title>Python 判断一个变量是否是字符串</title><link>http://blog.leafduo.com/31/python-tell-if-a-variable-is-a-string/</link><content:encoded>&lt;p&gt;忏悔啊，就写了一个类还出了 bug⋯⋯&lt;/p&gt;
&lt;p&gt;写了单元测试还出了 bug⋯⋯&lt;/p&gt;
&lt;p&gt;&lt;code&gt;type(data) == type(&quot;&quot;)&lt;/code&gt; 这种办法是不行的，因为 &quot;&quot; 是 str 类型，如果 data 是 unicode 的话这种判断就不成立了，而应该采用这种办法：&lt;code&gt;isinstance(data, basestring)&lt;/code&gt;，其中 basestring 是 str 和 unicode 两个类的父类。&lt;/p&gt;
&lt;p&gt;期待 python 3k⋯⋯&lt;/p&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/543889108/LeafDuo/feedsky/s.gif?r=http://blog.leafduo.com/31/python-tell-if-a-variable-is-a-string/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</content:encoded><wfw:commentRss>http://blog.leafduo.com/31/python-tell-if-a-variable-is-a-string/feed/</wfw:commentRss><slash:comments>0</slash:comments><description>忏悔啊，就写了一个类还出了 bug⋯⋯ 写了单元测试还出了 bug⋯⋯ type(data) == type(&quot;&quot;) 这种办法是不行的，因为 &quot;&quot; 是 str 类型，如果 data 是 unicode 的话这种判断就不成立了，而应该采用这种办法：isinstance(data, basestring)，其中 basestring 是 str 和 unicode 两个类的父类。 期待 python 3k⋯⋯&lt;img src=&quot;http://www1.feedsky.com/t1/543889108/LeafDuo/feedsky/s.gif?r=http://blog.leafduo.com/31/python-tell-if-a-variable-is-a-string/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</description><category>Uncategorized</category><category>python</category><category>bug</category><pubDate>Thu, 10 Mar 2011 23:00:31 +0800</pubDate><author>Leaf Duo</author><comments>http://blog.leafduo.com/31/python-tell-if-a-variable-is-a-string/#comments</comments><guid isPermaLink="false">http://blog.leafduo.com/?p=270</guid><dc:creator>Leaf Duo</dc:creator><fs:srclink>http://blog.leafduo.com/31/python-tell-if-a-variable-is-a-string/</fs:srclink><fs:srcfeed>http://blog.leafduo.com/feed</fs:srcfeed><fs:itemid>feedsky/LeafDuo/~7828943/543889108/4904878</fs:itemid></item><item><title>A Password Generator</title><link>http://blog.leafduo.com/52/a-password-generator/</link><content:encoded>&lt;p&gt;一个简易的密码生成器，python 写的，遵循 2 句 BSD 许可证，应该很好懂，参数什么的可以自己调调。&lt;/p&gt;
&lt;p&gt;PS：其实我写完了才发现有个叫 &lt;code&gt;pwgen&lt;/code&gt; 的东西，&lt;code&gt;pwgen -cns 16&lt;/code&gt; 似乎也不错。&lt;/p&gt;
&lt;p&gt;参考：&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;https://blog.delphij.net/2010/12/post-598.html&quot;&gt;https://blog.delphij.net/2010/12/post-598.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;phpmyadmin 生成密码的代码：&lt;a href=&quot;https://github.com/Reen/phpmyadmin/blob/master/js/server_privileges.js#L80&quot;&gt;https://github.com/Reen/phpmyadmin/blob/master/js/server_privileges.js#L80&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;python&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;#!/usr/bin/env python2.6&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# Copyright 2011 Kou Zuyang. All rights reserved.&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;#&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# Redistribution and use in source and binary forms, with or without modification, are&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# permitted provided that the following conditions are met:&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;#&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;#    1. Redistributions of source code must retain the above copyright notice, this list of&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;#       conditions and the following disclaimer.&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;#&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;#    2. Redistributions in binary form must reproduce the above copyright notice, this list&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;#       of conditions and the following disclaimer in the documentation and/or other materials&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;#       provided with the distribution.&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;#&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# THIS SOFTWARE IS PROVIDED BY Kou Zuyang ``AS IS'' AND ANY EXPRESS OR IMPLIED&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL &amp;lt;COPYRIGHT HOLDER&amp;gt; OR&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;#&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# The views and conclusions contained in the software and documentation are those of the&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# authors and should not be interpreted as representing official policies, either expressed&lt;/span&gt;
&lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;# or implied, of Kou Zuyang.&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;import&lt;/span&gt; &lt;span style=&quot;color: #dc143c;&quot;&gt;random&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;;&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;def&lt;/span&gt; generate_password&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;:
    alphabet = &lt;span style=&quot;color: #483d8b;&quot;&gt;'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNPOPQRSTUVWXYZ'&lt;/span&gt;
    number = &lt;span style=&quot;color: #483d8b;&quot;&gt;'1234567890'&lt;/span&gt;
    special = &lt;span style=&quot;color: #483d8b;&quot;&gt;'!@#$%^&amp;amp;amp;*()-=_+[]{};:,./&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\~&lt;/span&gt;`?'&lt;/span&gt;
    charset = alphabet &lt;span style=&quot;color: #66cc66;&quot;&gt;*&lt;/span&gt; &lt;span style=&quot;color: #ff4500;&quot;&gt;3&lt;/span&gt; + number &lt;span style=&quot;color: #66cc66;&quot;&gt;*&lt;/span&gt; &lt;span style=&quot;color: #ff4500;&quot;&gt;7&lt;/span&gt; + special &lt;span style=&quot;color: #66cc66;&quot;&gt;*&lt;/span&gt; &lt;span style=&quot;color: #ff4500;&quot;&gt;2&lt;/span&gt;
    &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;print&lt;/span&gt; &lt;span style=&quot;color: #483d8b;&quot;&gt;''&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;join&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #dc143c;&quot;&gt;random&lt;/span&gt;.&lt;span style=&quot;color: black;&quot;&gt;choice&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;charset&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;for&lt;/span&gt; x &lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;in&lt;/span&gt; &lt;span style=&quot;color: #008000;&quot;&gt;xrange&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff4500;&quot;&gt;16&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #ff7700;font-weight:bold;&quot;&gt;if&lt;/span&gt; __name__ == &lt;span style=&quot;color: #483d8b;&quot;&gt;&amp;quot;__main__&amp;quot;&lt;/span&gt;:
    generate_password&lt;span style=&quot;color: black;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/543889109/LeafDuo/feedsky/s.gif?r=http://blog.leafduo.com/52/a-password-generator/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</content:encoded><wfw:commentRss>http://blog.leafduo.com/52/a-password-generator/feed/</wfw:commentRss><slash:comments>0</slash:comments><description>一个简易的密码生成器，python 写的，遵循 2 句 BSD 许可证，应该很好懂，参数什么的可以自己调调。 PS：其实我写完了才发现有个叫 pwgen 的东西，pwgen -cns 16 似乎也不错。 参考： https://blog.delphij.net/2010/12/post-598.html phpmyadmin 生成密码的代码：https://github.com/Reen/phpmyadmin/blob/master/js/server_privileges.js#L80 #!/usr/bin/env python2.6 &amp;#160; # Copyright 2011 Kou Zuyang. All rights reserved. # # Redistribution and use in source and binary forms, with or without &amp;#8230; &lt;a href=&quot;http://blog.leafduo.com/52/a-password-generator/&quot;&gt;Continue reading &lt;span class=&quot;meta-nav&quot;&gt;&amp;#8594;&lt;/span&gt;&lt;/a&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/543889109/LeafDuo/feedsky/s.gif?r=http://blog.leafduo.com/52/a-password-generator/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</description><category>pwgen</category><category>python</category><category>Information Technology</category><category>password</category><pubDate>Sat, 12 Feb 2011 17:16:52 +0800</pubDate><author>Leaf Duo</author><comments>http://blog.leafduo.com/52/a-password-generator/#comments</comments><guid isPermaLink="false">http://blog.leafduo.com/?p=269</guid><dc:creator>Leaf Duo</dc:creator><fs:srclink>http://blog.leafduo.com/52/a-password-generator/</fs:srclink><fs:srcfeed>http://blog.leafduo.com/feed</fs:srcfeed><fs:itemid>feedsky/LeafDuo/~7828943/543889109/4904878</fs:itemid></item><item><title>Get Nagios to Work with Nginx (Gentoo)</title><link>http://blog.leafduo.com/43/get-nagios-to-work-with-nginx/</link><content:encoded>&lt;p&gt;今天装 &lt;a href=&quot;http://www.nagios.org/&quot;&gt;Nagios&lt;/a&gt;，开源监控软件。&lt;/p&gt;
&lt;p&gt;照例第一步：&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;bash&quot; style=&quot;font-family:monospace;&quot;&gt;emerge net-analyzer&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;nagios&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;这个包是个 meta 包，里面似乎有一个内核和一些插件，以后再研究，先搭起来再说。&lt;/p&gt;
&lt;p&gt;跑起 Nagios：&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;bash&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;etc&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;init.d&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;nagios start
rc-update add nagios default&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;安装完成之后它会告诉你，要是 Apache 或者 Lighttpd 的话我会给你配好，不是的话自己看着办吧，于是我就自己来了。:-(&lt;/p&gt;
&lt;p&gt;首先安装 spawn-fcgi 和 fcgiwrap，第一个是管理 fcgi 进程的，第二个是把 CGI 包装成 fcgi 的。fcgiwrap 这兄弟目前被 ~x86 mask 了，先 unmask。&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;bash&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;echo&lt;/span&gt; www-misc&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;fcgiwrap ~x86 &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;etc&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;portage&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;package.keywords&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;然后安装：&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;bash&quot; style=&quot;font-family:monospace;&quot;&gt;emerge www-servers&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;spawn-fcgi www-misc&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;fcgiwrap&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;跑起 spawn-fcgi：&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;bash&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;sudo&lt;/span&gt; spawn-fcgi &lt;span style=&quot;color: #660033;&quot;&gt;-a&lt;/span&gt; 127.0.0.1 &lt;span style=&quot;color: #660033;&quot;&gt;-p&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;22222&lt;/span&gt; &lt;span style=&quot;color: #660033;&quot;&gt;-P&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;var&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;run&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;fcgiwrap.pid &lt;span style=&quot;color: #660033;&quot;&gt;-u&lt;/span&gt; nagios &lt;span style=&quot;color: #660033;&quot;&gt;-g&lt;/span&gt; nagios &lt;span style=&quot;color: #660033;&quot;&gt;--&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;usr&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;sbin&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;fcgiwrap&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;-a 是主机，-p 是端口（用 unix domain 也行），-P 是 pid 文件，-u 是用户，-g 是组，-- 后面是要运行的命令，用户名和组一定要对，主机和端口要跟 nginx 对上。这条命令是起 CGI 部分的，Nagios 也用了 PHP，PHP 请通过 fcgi 自行跑起来 &lt;img src='http://blog.leafduo.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /&gt; ，php-fpm 或者 spawn-fcgi 均可，参考 WordPress 之类就行。&lt;/p&gt;
&lt;p&gt;下面是 nginx 的配置，主要是抄的别人的，主体参考&lt;a href=&quot;http://yemaosheng.com/?p=899&quot;&gt;这里&lt;/a&gt;，另外也参考&lt;a href=&quot;http://www.matejunkie.com/howto-let-nginx-serve-the-nagios-web-interface/&quot;&gt;这里&lt;/a&gt;。尤其是&lt;code&gt;fastcgi_param  AUTH_USER          $remote_user; fastcgi_param  REMOTE_USER        $remote_user;&lt;/code&gt; 两句，前一篇没有，害惨我了，nagios 一直说认证不通过……&lt;/p&gt;
&lt;p&gt;自己发挥改改就好撒。&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;bash&quot; style=&quot;font-family:monospace;&quot;&gt;location &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt; &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#123;&lt;/span&gt;
        auth_basic &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Restricted&amp;quot;&lt;/span&gt;;
        auth_basic_user_file &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;PATH&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;TO&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;HTPASSWD;
&amp;nbsp;
        root &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;usr&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;share&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;nagios&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;htdocs;
&amp;nbsp;
        location ~ \.php$ &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#123;&lt;/span&gt;
                fastcgi_pass   YOUR_PHP_UPSTREAM;
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME  &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;usr&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;share&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;nagios&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;htdocs&lt;span style=&quot;color: #007800;&quot;&gt;$fastcgi_script_name&lt;/span&gt;;
                include fastcgi_params;
        &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
        location &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;nagios&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt; &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#123;&lt;/span&gt;
                location &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;nagios&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;images&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt; &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#123;&lt;/span&gt;
                        &lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;gzip&lt;/span&gt; off;
                &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#125;&lt;/span&gt;
                expires 30d;
                &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;alias&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;usr&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;share&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;nagios&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;htdocs&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;;
        &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
        location &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;docs&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt; &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#123;&lt;/span&gt;
                root &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;usr&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;share&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;nagios&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;htdocs&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;;
                index index.html;
        &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
        location ~ \.cgi &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#123;&lt;/span&gt;
                fastcgi_pass 127.0.0.1:&lt;span style=&quot;color: #000000;&quot;&gt;22222&lt;/span&gt;;
                fastcgi_index index.cgi;
                fastcgi_param SCRIPT_FILENAME &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;usr&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;lib&lt;span style=&quot;color: #007800;&quot;&gt;$fastcgi_script_name&lt;/span&gt;;
                include fastcgi_params;
                fastcgi_param  AUTH_USER          &lt;span style=&quot;color: #007800;&quot;&gt;$remote_user&lt;/span&gt;;
                fastcgi_param  REMOTE_USER        &lt;span style=&quot;color: #007800;&quot;&gt;$remote_user&lt;/span&gt;;
        &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;关于里面提到的 htpasswd，是 &lt;a href=&quot;http://en.wikipedia.org/wiki/Basic_access_authentication&quot;&gt;basic auth&lt;/a&gt; 用的，咋生成看&lt;a href=&quot;http://wiki.nginx.org/HttpAuthBasicModule&quot;&gt;文档&lt;/a&gt;吧。&lt;/p&gt;
&lt;p&gt;Restart Nginx &amp;#038; enjoy!&lt;/p&gt;
&lt;p&gt;参考：&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;http://yemaosheng.com/?p=899&quot;&gt;http://yemaosheng.com/?p=899&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.matejunkie.com/howto-let-nginx-serve-the-nagios-web-interface/&quot;&gt;http://www.matejunkie.com/howto-let-nginx-serve-the-nagios-web-interface/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://wiki.nginx.org/HttpAuthBasicModule&quot;&gt;http://wiki.nginx.org/HttpAuthBasicModule&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/543889110/LeafDuo/feedsky/s.gif?r=http://blog.leafduo.com/43/get-nagios-to-work-with-nginx/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</content:encoded><wfw:commentRss>http://blog.leafduo.com/43/get-nagios-to-work-with-nginx/feed/</wfw:commentRss><slash:comments>2</slash:comments><description>今天装 Nagios，开源监控软件。 照例第一步： emerge net-analyzer/nagios 这个包是个 meta 包，里面似乎有一个内核和一些插件，以后再研究，先搭起来再说。 跑起 Nagios： /etc/init.d/nagios start rc-update add nagios default 安装完成之后它会告诉你，要是 Apache 或者 Lighttpd 的话我会给你配好，不是的话自己看着办吧，于是我就自己来了。:-( 首先安装 spawn-fcgi 和 fcgiwrap，第一个是管理 fcgi 进程的，第二个是把 CGI 包装成 fcgi 的。fcgiwrap 这兄弟目前被 ~x86 mask 了，先 unmask。 echo www-misc/fcgiwrap ~x86 &amp;#62;&amp;#62; &amp;#8230; &lt;a href=&quot;http://blog.leafduo.com/43/get-nagios-to-work-with-nginx/&quot;&gt;Continue reading &lt;span class=&quot;meta-nav&quot;&gt;&amp;#8594;&lt;/span&gt;&lt;/a&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/543889110/LeafDuo/feedsky/s.gif?r=http://blog.leafduo.com/43/get-nagios-to-work-with-nginx/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</description><category>Linux</category><category>fcgi</category><category>spawn-fcgi</category><category>Information Technology</category><category>Gentoo</category><category>Nginx</category><category>fcgiwrap</category><category>Nagios</category><pubDate>Sat, 12 Feb 2011 02:25:43 +0800</pubDate><author>Leaf Duo</author><comments>http://blog.leafduo.com/43/get-nagios-to-work-with-nginx/#comments</comments><guid isPermaLink="false">http://blog.leafduo.com/?p=267</guid><dc:creator>Leaf Duo</dc:creator><fs:srclink>http://blog.leafduo.com/43/get-nagios-to-work-with-nginx/</fs:srclink><fs:srcfeed>http://blog.leafduo.com/feed</fs:srcfeed><fs:itemid>feedsky/LeafDuo/~7828943/543889110/4904878</fs:itemid></item><item><title>禁止 ssh 密码登陆</title><link>http://blog.leafduo.com/26/forbid-ssh-login-via-password/</link><content:encoded>&lt;p&gt;&lt;code&gt;/etc/ssh/sshd_config&lt;/code&gt; 里面&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;bash&quot; style=&quot;font-family:monospace;&quot;&gt;PasswordAuthentication no
UsePAM no&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;为啥这样不要问我……去看看 &lt;code&gt;/etc/ssh/sshd_config&lt;/code&gt; 里面的注释或者 &lt;code&gt;man sshd&lt;/code&gt; 之类的吧，因为我也说不非常清楚，哈哈哈哈。&lt;/p&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/543889111/LeafDuo/feedsky/s.gif?r=http://blog.leafduo.com/26/forbid-ssh-login-via-password/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</content:encoded><wfw:commentRss>http://blog.leafduo.com/26/forbid-ssh-login-via-password/feed/</wfw:commentRss><slash:comments>0</slash:comments><description>/etc/ssh/sshd_config 里面 PasswordAuthentication no UsePAM no 为啥这样不要问我……去看看 /etc/ssh/sshd_config 里面的注释或者 man sshd 之类的吧，因为我也说不非常清楚，哈哈哈哈。&lt;img src=&quot;http://www1.feedsky.com/t1/543889111/LeafDuo/feedsky/s.gif?r=http://blog.leafduo.com/26/forbid-ssh-login-via-password/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</description><category>Linux</category><category>ssh</category><category>Information Technology</category><pubDate>Thu, 10 Feb 2011 21:53:26 +0800</pubDate><author>Leaf Duo</author><comments>http://blog.leafduo.com/26/forbid-ssh-login-via-password/#comments</comments><guid isPermaLink="false">http://blog.leafduo.com/?p=266</guid><dc:creator>Leaf Duo</dc:creator><fs:srclink>http://blog.leafduo.com/26/forbid-ssh-login-via-password/</fs:srclink><fs:srcfeed>http://blog.leafduo.com/feed</fs:srcfeed><fs:itemid>feedsky/LeafDuo/~7828943/543889111/4904878</fs:itemid></item><item><title>解决 WordPress 自动升级中遇到的一个验证问题</title><link>http://blog.leafduo.com/05/solution-to-wordpress-auto-update-auth-problem/</link><content:encoded>&lt;p&gt;WordPress 要升级 3.0.5，我懒，所以自动升级，点开自动升级的页面，输入验证方式，发现木有 sftp 的选项，印象中原来是有的，去查了一下，发现不是 WordPress 的问题，而是 PHP 没有装载 ssh 的模块，于是装上。&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;bash&quot; style=&quot;font-family:monospace;&quot;&gt;emerge dev-php5&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;pecl-ssh2&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;然后升级页面就神奇地出现了 SSH2 的选项，于是开心地填上用户名密码，一个回车，告诉你用户名或密码错误……我说不可能啊，于是去查系统日志，日志里竟然一个字都没写……明显就不是密码错了嘛。&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://picasaweb.google.com/lh/photo/xkySpdVTZ8xpIVrPLffVhA?feat=embedwebsite&quot;&gt;&lt;img src=&quot;https://lh6.googleusercontent.com/_7Y_7M0vQVWs/TVLi45Y4HfI/AAAAAAAACZY/v4afyZn-oHM/s800/Screen%20shot%202011-02-10%20at%202.09.08%20AM.png&quot; height=&quot;383&quot; width=&quot;534&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;啥问题呢，不清楚，咋办呢，查 WordPress 的源码吧。发现 &lt;a href=&quot;http://phpxref.ftwr.co.uk/wordpress/nav.html?wp-admin/includes/file.php.source.html#l850&quot;&gt;wp-admin/includes/file.php&lt;/a&gt; 里有个函数叫 &lt;a href=&quot;http://phpxref.ftwr.co.uk/wordpress/nav.html?wp-admin/includes/file.php.source.html#l850&quot;&gt;&lt;code&gt;get_filesystem_method()&lt;/code&gt;&lt;/a&gt;，它的注释告诉我 WordPress 升级写文件有这么几种方式：Direct, SSH2, FTP PHP Extension, FTP Sockets，优先级依次递减，于是发现还有 Direct 这么一种神奇的方式，快速解决问题： &lt;code&gt;chown -R nobody:nobody /path/to/WordPress&lt;/code&gt;。（我用 php-fpm 运行的，php 的 user 是 nobody）&lt;/p&gt;
&lt;p&gt;不能把问题放着不管是不？去看看是啥问题，在 WordPress 源码里搜 &quot;Username/Password incorrect for&quot;，发现几个文件里都有，分别对应几种连接方式：direct、ssh2、ftpext、ftpsockets。当然我们要看 SSH2 是不？于是这个文件是 &lt;a href=&quot;http://phpxref.ftwr.co.uk/wordpress/nav.html?wp-admin/includes/class-wp-filesystem-ssh2.php.source.html#l103&quot;&gt;wp-admin/includes/class-wp-filesystem-ssh2.php&lt;/a&gt;，里面那个 &lt;a href=&quot;http://phpxref.ftwr.co.uk/wordpress/nav.html?wp-admin/includes/class-wp-filesystem-ssh2.php.source.html#l103&quot;&gt;&lt;code&gt;connect()&lt;/code&gt;&lt;/a&gt; 函数是我感兴趣的，里面有这么一句：&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;php&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;!&lt;/span&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$this&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #004000;&quot;&gt;keys&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;
  &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;!&lt;/span&gt; &lt;span style=&quot;color: #339933;&quot;&gt;@&lt;/span&gt;&lt;span style=&quot;color: #990000;&quot;&gt;ssh2_auth_password&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000088;&quot;&gt;$this&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #004000;&quot;&gt;link&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$this&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #004000;&quot;&gt;options&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;'username'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$this&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #004000;&quot;&gt;options&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;'password'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #009900;&quot;&gt;&amp;#123;&lt;/span&gt;
    &lt;span style=&quot;color: #000088;&quot;&gt;$this&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #004000;&quot;&gt;errors&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #004000;&quot;&gt;add&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;'auth'&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #990000;&quot;&gt;sprintf&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;__&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;'Username/Password incorrect for %s'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;,&lt;/span&gt; &lt;span style=&quot;color: #000088;&quot;&gt;$this&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #004000;&quot;&gt;options&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;'username'&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#93;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
    &lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #009900; font-weight: bold;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: #339933;&quot;&gt;;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;也就是说没有使用 key 的时候，用密码验证，&lt;a href=&quot;http://php.net/manual/en/function.ssh2-auth-password.php&quot;&gt;&lt;code&gt;ssh2_auth_password()&lt;/code&gt;&lt;/a&gt; 失败的话就说是用户名或密码错。（PHP 达人告诉我前面的 @ 是啥？）&lt;/p&gt;
&lt;p&gt;查这个函数的&lt;a href=&quot;http://php.net/manual/en/function.ssh2-auth-password.php&quot;&gt;原型&lt;/a&gt;，人家只说失败的时候返回 false，谁说一定是密码错误了，你妹的……&lt;/p&gt;
&lt;p&gt;不过在这个文件里还有新发现，在&lt;a href=&quot;http://phpxref.ftwr.co.uk/wordpress/nav.html?wp-admin/includes/class-wp-filesystem-ssh2.php.source.html#l1&quot;&gt;这个类的注释&lt;/a&gt;里，发现了&lt;a href=&quot;http://kevin.vanzonneveld.net/techblog/article/make_ssh_connections_with_php/&quot;&gt;一篇 pecl-ssh2 的安装指南&lt;/a&gt;，在里面发现了问题：On the serverside, 'PasswordAuthentication yes' must be enabled in the sshd_config. 一查我的配置，果然给弄成 no 了……&lt;/p&gt;
&lt;p&gt;欣喜若狂地改成 yes，然后重启 sshd，&lt;code&gt;/etc/init.d/sshd restart&lt;/code&gt;，竟然没法重启……尝试 reload，&lt;code&gt;/etc/init.d/sshd reload&lt;/code&gt;，说 sshd 没运行（No /usr/sbin/sshd found running; none killed.），又开始扯淡了！！！&lt;/p&gt;
&lt;p&gt;遵循不知道谁的教导，重新 emerge 一遍 openssh。&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;bash&quot; style=&quot;font-family:monospace;&quot;&gt;emerge net-misc&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;openssh&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;然后&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;bash&quot; style=&quot;font-family:monospace;&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;etc&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;init.d&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;sshd restart&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;就能重启了……&lt;/p&gt;
&lt;p&gt;之后回到 WordPress 输上密码，发现能登录上了，变成 PHP 错误了……仔细一看，我的账户也没有改 WordPress 代码的权限啊……&lt;/p&gt;
&lt;p&gt;折腾一圈白干了，专门弄个账户还不如改权限（&lt;code&gt;chown -R nobody:nobody&lt;/code&gt;）呢。&lt;/p&gt;
&lt;p&gt;&lt;del datetime=&quot;2011-02-09T18:03:26+00:00&quot;&gt;不过过程中还发现了新的问题，sshd_config 里面 PasswordAuthentication no 之后还是能从别的主机用密码登陆（不过 php 这个 ssh2 的库登陆不了了），很神奇吧……以后再看是什么问题吧。&lt;/del&gt;&lt;/p&gt;
&lt;p&gt;大概找到是啥问题了，下篇发出来吧。&lt;/p&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/543889112/LeafDuo/feedsky/s.gif?r=http://blog.leafduo.com/05/solution-to-wordpress-auto-update-auth-problem/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</content:encoded><wfw:commentRss>http://blog.leafduo.com/05/solution-to-wordpress-auto-update-auth-problem/feed/</wfw:commentRss><slash:comments>2</slash:comments><description>WordPress 要升级 3.0.5，我懒，所以自动升级，点开自动升级的页面，输入验证方式，发现木有 sftp 的选项，印象中原来是有的，去查了一下，发现不是 WordPress 的问题，而是 PHP 没有装载 ssh 的模块，于是装上。 emerge dev-php5/pecl-ssh2 然后升级页面就神奇地出现了 SSH2 的选项，于是开心地填上用户名密码，一个回车，告诉你用户名或密码错误……我说不可能啊，于是去查系统日志，日志里竟然一个字都没写……明显就不是密码错了嘛。 啥问题呢，不清楚，咋办呢，查 WordPress 的源码吧。发现 wp-admin/includes/file.php 里有个函数叫 get_filesystem_method()，它的注释告诉我 WordPress 升级写文件有这么几种方式：Direct, SSH2, FTP PHP Extension, FTP Sockets，优先级依次递减，于是发现还有 Direct 这么一种神奇的方式，快速解决问题： chown -R nobody:nobody /path/to/WordPress。（我用 php-fpm 运行的，php 的 user &amp;#8230; &lt;a href=&quot;http://blog.leafduo.com/05/solution-to-wordpress-auto-update-auth-problem/&quot;&gt;Continue reading &lt;span class=&quot;meta-nav&quot;&gt;&amp;#8594;&lt;/span&gt;&lt;/a&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/543889112/LeafDuo/feedsky/s.gif?r=http://blog.leafduo.com/05/solution-to-wordpress-auto-update-auth-problem/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</description><category>wordpress</category><category>Linux</category><category>ssh</category><category>PHP</category><category>Information Technology</category><category>Gentoo</category><category>OpenSSH</category><pubDate>Thu, 10 Feb 2011 02:50:05 +0800</pubDate><author>Leaf Duo</author><comments>http://blog.leafduo.com/05/solution-to-wordpress-auto-update-auth-problem/#comments</comments><guid isPermaLink="false">http://blog.leafduo.com/?p=263</guid><dc:creator>Leaf Duo</dc:creator><fs:srclink>http://blog.leafduo.com/05/solution-to-wordpress-auto-update-auth-problem/</fs:srclink><fs:srcfeed>http://blog.leafduo.com/feed</fs:srcfeed><fs:itemid>feedsky/LeafDuo/~7828943/543889112/4904878</fs:itemid></item><item><title>Gentoo/Nginx with IPv6 (Tunnel) Support</title><link>http://blog.leafduo.com/51/gentoonginx-with-ipv6-tunnel-support/</link><content:encoded>&lt;p&gt;弄了一个 &lt;a href=&quot;http://he.net/&quot;&gt;he.net&lt;/a&gt; 的 &lt;a href=&quot;http://tunnelbroker.net/&quot;&gt;IPv6 隧道&lt;/a&gt;，给服务器用。（你说你 &lt;a href=&quot;http://www.linode.com/&quot;&gt;Linode&lt;/a&gt; 为啥不提供原生 IPv6，为啥？）&lt;/p&gt;
&lt;p&gt;一会就申请完了，你就获得 4 个 IP，服务器的 IPv4、IPv6，客户端的 IPv4、IPv6，你需要这些 IP 来做一些配置。&lt;/p&gt;
&lt;p&gt;首先是配好 Gentoo，&lt;a href=&quot;http://www.linode.com/wiki/index.php/IPv6#Gentoo&quot;&gt;LInode 的 wiki&lt;/a&gt; 写的很清楚，注意 interface 的名字似乎不能太短，一开始我起的叫 he，出了奇怪的错误……改成 hetun 就好了……&lt;/p&gt;
&lt;p&gt;注意 Linode 的 eth0 是用的 DHCP，别乱改。&lt;/p&gt;
&lt;p&gt;接下来是 Nginx，因为编译的时候已经带上 USE=&quot;ipv6&quot; 了，所以就不需要重新编译了，改一下 Listen 语句就行。我原先都是用的 Listen 0.0.0.0:80，要使 IPv6 有效的话要改成 [::]:80，于是尝试性地改了一个域名的配置。&lt;/p&gt;
&lt;p&gt;重启 Nginx，报错，说 80 端口已经被 bind 了，我说不可能啊，lsof -i tcp:80 也是空的。想了想隐约知道是怎么回事了，于是把所有的配置文件都从 Listen 0.0.0.0:80 改成 Listen [::]:80，重启，OK 了。&lt;/p&gt;
&lt;p&gt;想来是因为 Nginx 把 0.0.0.0:80 和 [::]:80 认成了两个端口，于是 bind 了两遍，这不就冲突了嘛……都改成 Listen [::]:80 就好了。&lt;/p&gt;
&lt;p&gt;参考文献：&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;http://kovyrin.net/2010/01/16/enabling-ipv6-support-in-nginx/&quot;&gt;http://kovyrin.net/2010/01/16/enabling-ipv6-support-in-nginx/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;tunnelbroker.net 给的配置命令&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.linode.com/wiki/index.php/IPv6#Gentoo&quot;&gt;http://www.linode.com/wiki/index.php/IPv6#Gentoo&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/543889113/LeafDuo/feedsky/s.gif?r=http://blog.leafduo.com/51/gentoonginx-with-ipv6-tunnel-support/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</content:encoded><wfw:commentRss>http://blog.leafduo.com/51/gentoonginx-with-ipv6-tunnel-support/feed/</wfw:commentRss><slash:comments>0</slash:comments><description>弄了一个 he.net 的 IPv6 隧道，给服务器用。（你说你 Linode 为啥不提供原生 IPv6，为啥？） 一会就申请完了，你就获得 4 个 IP，服务器的 IPv4、IPv6，客户端的 IPv4、IPv6，你需要这些 IP 来做一些配置。 首先是配好 Gentoo，LInode 的 wiki 写的很清楚，注意 interface 的名字似乎不能太短，一开始我起的叫 he，出了奇怪的错误……改成 hetun 就好了…… 注意 Linode 的 eth0 是用的 DHCP，别乱改。 接下来是 Nginx，因为编译的时候已经带上 USE=&quot;ipv6&quot; 了，所以就不需要重新编译了，改一下 Listen 语句就行。我原先都是用的 Listen 0.0.0.0:80，要使 &amp;#8230; &lt;a href=&quot;http://blog.leafduo.com/51/gentoonginx-with-ipv6-tunnel-support/&quot;&gt;Continue reading &lt;span class=&quot;meta-nav&quot;&gt;&amp;#8594;&lt;/span&gt;&lt;/a&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/543889113/LeafDuo/feedsky/s.gif?r=http://blog.leafduo.com/51/gentoonginx-with-ipv6-tunnel-support/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;</description><category>Linux</category><category>ipv6</category><category>Information Technology</category><category>Gentoo</category><category>Nginx</category><category>tunnel</category><pubDate>Sun, 06 Feb 2011 18:47:51 +0800</pubDate><author>Leaf Duo</author><comments>http://blog.leafduo.com/51/gentoonginx-with-ipv6-tunnel-support/#comments</comments><guid isPermaLink="false">http://blog.leafduo.com/?p=262</guid><dc:creator>Leaf Duo</dc:creator><fs:srclink>http://blog.leafduo.com/51/gentoonginx-with-ipv6-tunnel-support/</fs:srclink><fs:srcfeed>http://blog.leafduo.com/feed</fs:srcfeed><fs:itemid>feedsky/LeafDuo/~7828943/543889113/4904878</fs:itemid></item></channel></rss>
