Arch Linux是个好玩意儿。

Arch Linux是个好玩意儿。
一个轻量级发行版。
滚动更新对于我这个升级控来说很好用。
BSD风格的启动框架,对于我这个FreeBSD的粉丝来说用起来很舒服。
pacman对包依赖解决的也很好。
在/etc/rc.conf文件里就可以解决掉很多配置项。
软件仓库163有镜像。

ArchLinux哲学

  • 轻便灵活,符合KISS原则。
    • 采用BSD风格的启动脚本,集中管理,易懂易改。
    • 统一的目录架构,避免一般软件分属/bin,/usr/local/bin等多个目录的弊病,将所有的包集中在/bin,/lib,/usr/man,/usr/share/man中。
    • 精简的打包方式,删去部分说明,但保留了man page,从而使包装后的二进制包比一般的Linux小(例如:安装基础包和X视窗,仅需约100MB)。
    • 软件初次安装后,仅为默认配置。可能需要包手册,才能了解后续配置。

http协议版本号导致的问题

一台小内存(主要是想说在小内存的机器上使用apache2作为后端关闭keep-alive比php-fpm稳定的多)机器上使用nginx作为前端,apache2作为后端。

今天在部署一个网站(基于slim framework)的时候访问提示如下错误:

内容编码错误
无法显示您尝试查看的页面,因为它使用了无效或者不支持的压缩格式。

网上搜了一些结果大部分都是碰到gzip头空白的问题。
搜索了一下代码并无相关gzip操作的代码。

遂继续搜索header操作的代码,发现一个Slim_Http_Response类里的属性$httpVersion默认是1.1,而nginx不支持1.1的后端服务。
于是就会提示错误。

相关链接:http://wiki.nginx.org/HttpProxyModule

It is an HTTP/1.0 proxy without the ability for keep-alive requests yet. (As a result, backend connections are created and destroyed on every request.) Nginx talks HTTP/1.1 to the browser and HTTP/1.0 to the backend server. As such it handles keep-alive to the browser.

在VirtualHost里设置RewriteCond中%{REQUEST_FILENAME}无效的问题

问题发生在将.htaccess里的rewrite规则转移到VirtualHost里之后。
原因是%{REQUEST_FILENAME}依然指向相对路径。

RewriteCond %{REQUEST_FILENAME}
改为:
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME}
问题解决。

Rewrite的调试可以开启RewriteLog来跟踪:
http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewritelog

参考文章:
http://lufei-99999.blog.163.com/blog/static/748495420115845922988/

Supervisord & monit

用monit监控系统关键进程
monit是一款功能强大的系统状态、进程、文件、目录和设备的监控软件,用于*nix平台, 它可以自动重启那些已经挂掉的程序,非常适合监控系统关键的进程和资源,如:nginx、apache、mysql和cpu占有率等。
http://feilong.me/2011/02/monitor-core-processes-with-monit

Supervisord是用Python实现的一款非常实用的进程管理工具,类似于monit(关于monit见我的博客:用monit监控系统关键进程),monit和supervisord的一个比较大的差异是supervisord管理的进程必须由supervisord来启动,monit可以管理已经在运行的程序。
http://feilong.me/2011/03/monitor-processes-with-supervisord

php5-fpm SIGBUS

child 19142 exited on signal 7 (SIGBUS) after 304.356752 seconds from start

做了两个设置:
php5-fpm : emergency_restart_threshold 设置一个合适的值
php.ini : cgi.fix_pathinfo = 0

参考文章:http://blog.51osos.com/opensource/nginx-emergency-restart-threshold-sigsegv/

Proxy auto config

土鳖了,今天才发现还有这个玩意儿:

http://en.wikipedia.org/wiki/Proxy_auto-config

这下方便多了,不用每次都往”No Proxy For”里添加条目了(-_-!)。。

我的PAC (Proxy_auto-config) 文件:

function isBlockedHost(host)
{
if (shExpMatch(host, “*google.*”) ||
shExpMatch(host, “*ggpht.*”) ||
shExpMatch(host, “*alexa.com*”) ||
shExpMatch(host, “*blogspot.com*”) ||
shExpMatch(host, “*facebook.com*”) ||
shExpMatch(host, “*twitter.com*”) ||
shExpMatch(host, “*youtube.com*”) ||
shExpMatch(host, “*appspot.com*”) ||
shExpMatch(host, “*fc2.com”) ) {
return true;
}
return false;
}

// browser’s API
function FindProxyForURL(url, host)
{
var direct = “DIRECT”;
var socksProxy = “SOCKS5 127.0.0.1:9999”; // 注意这里需要指定为SOCKS5,才会进行remote dns resolve

if (isBlockedHost(host))
{
return socksProxy;
}

return direct;
}

参考文章:
http://blog.solrex.org/articles/remote-dns-lookup.html
http://fanqiangchinagfw.blogspot.com/2010/08/dnsfirefox-dns-resolving.html