<?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/"
	xmlns:georss="http://www.georss.org/georss">

<channel>
	<title>Here comes the Sun &#187; fastcgi</title>
	<atom:link href="http://sunng.info/blog/tag/fastcgi/feed/" rel="self" type="application/rss+xml" />
	<link>http://sunng.info/blog</link>
	<description>Life ramblings</description>
	<lastBuildDate>Tue, 07 Sep 2010 13:05:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>在RHEL4上搭建Python/Lighttpd/FastCGI环境</title>
		<link>http://sunng.info/blog/2009/11/%e5%9c%a8rhel4%e4%b8%8a%e6%90%ad%e5%bb%bapythonlighttpdfastcgi%e7%8e%af%e5%a2%83/</link>
		<comments>http://sunng.info/blog/2009/11/%e5%9c%a8rhel4%e4%b8%8a%e6%90%ad%e5%bb%bapythonlighttpdfastcgi%e7%8e%af%e5%a2%83/#comments</comments>
		<pubDate>Fri, 27 Nov 2009 10:28:50 +0000</pubDate>
		<dc:creator>Sunng</dc:creator>
				<category><![CDATA[手艺]]></category>
		<category><![CDATA[fastcgi]]></category>
		<category><![CDATA[lighttpd]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.classicning.com/blog/?p=346</guid>
		<description><![CDATA[在一台赤裸裸的RHEL4上部署web.py程序，一切从几乎是从零开始。以下操作均以root用户操作。 1. 安装MySQL数据库 下载安装MySQL wget http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.41-linux-i686-glibc23.tar.gz/from/http://mirror.services.wisc.edu/mysql/ 解压，按照INSTALL文件说明进行安装，不多赘述 2. 安装Python环境 下载Python源码 wget http://www.python.org/ftp/python/2.6.4/Python-2.6.4.tar.bz2 解压，编译安装，不需要特殊操作。 下载Easy_install wget http://pypi.python.org/packages/2.6/s/setuptools/setuptools-0.6c11-py2.6.egg 安装 sh setuptools-0.6c11-py2.6.egg 安装相关Packages easy_install DBUtils easy_install flup easy_install web.py 安装mysql-python mysql-python包不能用easy_install安装，手动下载 wget http://downloads.sourceforge.net/project/mysql-python/mysql-python-test/1.2.3b1/MySQL-python-1.2.3b1.tar.gz?use_mirror=softlayer 加压，编辑site.cfg 指定mysql_config的路径，注意是新安装的mysql路径 mysql_config=/usr/local/mysql/bin/mysql_config 编译、安装 python setup.py build python setup.py install 声明libmysqlclient路径 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mysql/lib 3. 安装服务器环境 下载安装fastcgi头文件 wget http://www.fastcgi.com/dist/fcgi.tar.gz 解压，默认编译安装 下载安装PCRE wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.00.tar.bz2 解压，默认编译安装 下载lighttpd wget [...]]]></description>
			<content:encoded><![CDATA[<p>在一台赤裸裸的RHEL4上部署web.py程序，一切从几乎是从零开始。以下操作均以root用户操作。</p>
<h2>1. 安装MySQL数据库</h2>
<p><strong>下载安装MySQL</strong><br />
<em>wget http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.41-linux-i686-glibc23.tar.gz/from/http://mirror.services.wisc.edu/mysql/</em><br />
解压，按照INSTALL文件说明进行安装，不多赘述</p>
<h2>2. 安装Python环境</h2>
<h3>下载Python源码</h3>
<p><em>wget http://www.python.org/ftp/python/2.6.4/Python-2.6.4.tar.bz2</em><br />
解压，编译安装，不需要特殊操作。</p>
<h3>下载Easy_install</h3>
<p><em>wget http://pypi.python.org/packages/2.6/s/setuptools/setuptools-0.6c11-py2.6.egg</em><br />
安装<br />
<em>sh setuptools-0.6c11-py2.6.egg</em></p>
<h3>安装相关Packages</h3>
<p><em>easy_install DBUtils<br />
easy_install flup<br />
easy_install web.py</em></p>
<h3>安装mysql-python</h3>
<p>mysql-python包不能用easy_install安装，手动下载<br />
<em>wget http://downloads.sourceforge.net/project/mysql-python/mysql-python-test/1.2.3b1/MySQL-python-1.2.3b1.tar.gz?use_mirror=softlayer</em><br />
加压，编辑site.cfg<br />
指定mysql_config的路径，注意是新安装的mysql路径<br />
<em>mysql_config=/usr/local/mysql/bin/mysql_config</em><br />
编译、安装<br />
<em>python setup.py build<br />
python setup.py install</em><br />
声明libmysqlclient路径<br />
<em>export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mysql/lib</em></p>
<h2>3. 安装服务器环境</h2>
<h3>下载安装fastcgi头文件</h3>
<p><em>wget http://www.fastcgi.com/dist/fcgi.tar.gz</em><br />
解压，默认编译安装</p>
<h3>下载安装PCRE</h3>
<p><em>wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.00.tar.bz2</em><br />
解压，默认编译安装</p>
<h3>下载lighttpd</h3>
<p><em>wget http://download.lighttpd.net/lighttpd/releases-1.4.x/lighttpd-1.4.25.tar.bz2</em><br />
configure时指定<em>&#8211;prefix=/usr/local/lighttpd</em><br />
编译，安装</p>
<h2>4. 配置</h2>
<p>lighttpd fastcgi运行web.py程序请参考<br />
<a href="http://www.classicning.com/blog/2009/11/lighttpd%e9%80%9a%e8%bf%87fastcgi%e8%bf%90%e8%a1%8cweb-py%e7%a8%8b%e5%ba%8f/">http://www.classicning.com/blog/2009/11/lighttpd%e9%80%9a%e8%bf%87fastcgi%e8%bf%90%e8%a1%8cweb-py%e7%a8%8b%e5%ba%8f/</a></p>
<p>非常重要的几点注意：</p>
<ul>
<li>通过fastcgi运行的python脚本必须具有可执行权限，<em> chmod u+x web/main.py</em>；</li>
<li>重启fastcgi程序需要删除/tmp/fastcgi.socket*</li>
</ul>
<p>任何Python程序出错、权限错误都会导致lighttpd这样的报错：<br />
<em>2009-11-27 18:12:02: (mod_fastcgi.c.1108) child exited with status 13 /home/admin/web/main.py<br />
2009-11-27 18:12:02: (mod_fastcgi.c.1111) If you&#8217;re trying to run your app as a FastCGI backend, make sure you&#8217;re using the FastCGI-enabled version.<br />
If this is PHP on Gentoo, add &#8216;fastcgi&#8217; to the USE flags.<br />
2009-11-27 18:12:02: (mod_fastcgi.c.1399) [ERROR]: spawning fcgi failed.<br />
2009-11-27 18:12:02: (server.c.931) Configuration of plugins failed. Going down.</em></p>
<p>报错会提示fastcgi未正确安装，而实际上仅仅是程序错误或权限问题而已。</p>
]]></content:encoded>
			<wfw:commentRss>http://sunng.info/blog/2009/11/%e5%9c%a8rhel4%e4%b8%8a%e6%90%ad%e5%bb%bapythonlighttpdfastcgi%e7%8e%af%e5%a2%83/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	<georss:point>31.203057 121.6174866</georss:point>	</item>
		<item>
		<title>Lighttpd通过FastCGI运行web.py程序</title>
		<link>http://sunng.info/blog/2009/11/lighttpd%e9%80%9a%e8%bf%87fastcgi%e8%bf%90%e8%a1%8cweb-py%e7%a8%8b%e5%ba%8f/</link>
		<comments>http://sunng.info/blog/2009/11/lighttpd%e9%80%9a%e8%bf%87fastcgi%e8%bf%90%e8%a1%8cweb-py%e7%a8%8b%e5%ba%8f/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 09:31:07 +0000</pubDate>
		<dc:creator>Sunng</dc:creator>
				<category><![CDATA[手艺]]></category>
		<category><![CDATA[fastcgi]]></category>
		<category><![CDATA[lighttpd]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[web.py]]></category>

		<guid isPermaLink="false">http://www.classicning.com/blog/?p=304</guid>
		<description><![CDATA[web.py是个很小的python框架，特点就是小，连session都没有实现人家就发布了。前几天KungfuRails大会上他们吹牛说Sinatra可以写出世界上最小的Webapp，但是有web.py的化，那个最小至少要加上个“之一”。 Web.py在Lighttpd上通过fastcgi运行的配置，可以在web.py的网站上找到文档： http://webpy.org/cookbook/fastcgi-lighttpd 实际我用的时候把静态的index.html用作首页，稍改动一下： server.document-root = "/home/sun/projects/sdostatweb" server.modules += ( "mod_fastcgi" ) server.modules += ( "mod_rewrite" ) server.port = 4000 mimetype.assign = ( ".html" =&#62; "text/html" ) index-file.names = ( "index.html" ) fastcgi.server = ( "/sdostatweb.py" =&#62; (( "socket" =&#62; "/tmp/fastcgi.socket", "bin-path" =&#62; "/home/sun/projects/sdostatweb/sdostatweb.py", "max-procs" =&#62; 5, "bin-environment" =&#62; ( "REAL_SCRIPT_NAME" =&#62; "" ), "check-local" [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://webpy.org/" target="_blank">web.py</a>是个很小的python框架，特点就是小，连session都没有实现人家就发布了。前几天KungfuRails大会上他们吹牛说<a href="http://www.sinatrarb.com" target="_blank">Sinatra</a>可以写出世界上最小的Webapp，但是有web.py的化，那个最小至少要加上个“之一”。</p>
<p>Web.py在Lighttpd上通过fastcgi运行的配置，可以在web.py的网站上找到文档：<br />
<a href="http://webpy.org/cookbook/fastcgi-lighttpd">http://webpy.org/cookbook/fastcgi-lighttpd</a></p>
<p>实际我用的时候把静态的index.html用作首页，稍改动一下：</p>
<pre class="brush:plain">server.document-root = "/home/sun/projects/sdostatweb"

server.modules   += ( "mod_fastcgi" )
server.modules   += ( "mod_rewrite" )

server.port = 4000

mimetype.assign = (
    ".html" =&gt; "text/html"
)

index-file.names = ( "index.html" )

fastcgi.server = ( "/sdostatweb.py" =&gt;
(( "socket" =&gt; "/tmp/fastcgi.socket",
        "bin-path" =&gt; "/home/sun/projects/sdostatweb/sdostatweb.py",
        "max-procs" =&gt; 5,
        "bin-environment" =&gt; (
        "REAL_SCRIPT_NAME" =&gt; ""
    ),
        "check-local" =&gt; "disable"
    ))
)

url.rewrite-once = (
    "^/$" =&gt; "/static/index.html",
    "^/flotr/(.*)$" =&gt; "/static/flotr/$1",
    "^/static/(.*)$" =&gt; "/static/$1",
    "^/(.*)$" =&gt; "/sdostatweb.py/$1",

)</pre>
<p>另外用fastcgi的方式使用web.py，需要安装flup。</p>
<p>详细的事，可以看看新浪的Tim Yang的优化：<br />
<a href="http://timyang.net/python/python-webpy-lighttpd/">http://timyang.net/python/python-webpy-lighttpd/</a></p>
<p>我之前真不敢相信搜狐Mail是跑在web.py上。</p>
]]></content:encoded>
			<wfw:commentRss>http://sunng.info/blog/2009/11/lighttpd%e9%80%9a%e8%bf%87fastcgi%e8%bf%90%e8%a1%8cweb-py%e7%a8%8b%e5%ba%8f/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
