月度归档: 2011 年 11 月

  • 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.

  • 使用nautilus-share打开Windows Share提示:“Failed to retrieve share list from server”解决方法。

    Access it directly by ip address:

    nautilus smb://192.168.0.100

    参考:http://ubuntuforums.org/showthread.php?t=1815360

  • clearstatcache

    在进行stat()相关操作的时候先运行一下clearstatcache。
    受影响的函数: stat(), lstat(), file_exists(), is_writable(), is_readable(), is_executable(), is_file(), is_dir(), is_link(), filectime(), fileatime(), filemtime(), fileinode(), filegroup(), fileowner(), filesize(), filetype(), and fileperms()。

    http://php.net/manual/en/function.clearstatcache.php

  • 在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/

  • 张生方案总结

    Socks方案(Socks可以利用ssh tunnel来建立,不表)
    1、利用squid来进行转发:
    http://sudone.com/linux/squid_privoxy_tor.html

    2、利用redsocks(http://darkk.net.ru/redsocks/)来转发,相关链接:
    Setup iptables for RedSocks in OpenWRT : https://gist.github.com/1097210/796886ba50978ca2426d7bedafd61076858b2c64
    http://www.right.com.cn/forum/viewthread.php?action=printable&tid=40111
    http://bjin.posterous.com/redsocks-on-android
    http://shell909090.com/blog/ (这里有一些openwrt相关的东东)
    http://blog.zhuli.name/archives/6690
    http://www.wy182000.info/2011/08/05/socks%E4%BB%A3%E7%90%86%E7%9A%84%E9%80%8F%E6%98%8E%E5%8C%96%E5%92%8C%E5%8F%AF%E8%B7%AF%E7%94%B1/

    ==openwrt相关==
    http://shell909090.com/blog/2011/09/%E5%90%88%E7%94%A8%E4%B8%A4%E4%B8%AA%E8%B7%AF%E7%94%B1%E5%99%A8%E7%9A%84%E5%87%A0%E7%A7%8D%E6%96%B9%E6%A1%88/
    http://penglei.name/html/100.html (tomato配置VLAN)

    其他参考资料:

    Linux上iptables防火墙的基本应用教程
    http://www.vpser.net/security/linux-iptables.html
    单网卡Linux利用iptables做网关
    http://linux.chinaunix.net/techdoc/net/2007/05/08/957205.shtml
    Linux下使用单网卡实现nat共享上网
    http://zhangruirong.blog.51cto.com/2098188/386947
    Linux单网卡实现NAT路由
    http://gsion.blog.163.com/blog/static/123056504201162111957875/
    單網卡red hat 7.2 linux利用iptables作為簡單網關的配置
    http://fanqiang.chinaunix.net/a1/b1/20020815/060200294_b.html