<?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>Big toy for boy! &#187; spawn-fcgi</title>
	<atom:link href="http://bigtoy4boy.com/blog/tag/spawn-fcgi/feed/" rel="self" type="application/rss+xml" />
	<link>http://bigtoy4boy.com/blog</link>
	<description>一个有关一些个人兴趣爱好的博客</description>
	<lastBuildDate>Wed, 04 Aug 2010 08:47:43 +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>Nginx中使用spawn-fcgi来启动php-cgi的脚本</title>
		<link>http://bigtoy4boy.com/blog/2009/04/spawn-fcgi-starter-script-with-nignx-and-phpcgi/</link>
		<comments>http://bigtoy4boy.com/blog/2009/04/spawn-fcgi-starter-script-with-nignx-and-phpcgi/#comments</comments>
		<pubDate>Thu, 02 Apr 2009 05:49:55 +0000</pubDate>
		<dc:creator>羽高</dc:creator>
				<category><![CDATA[互联网技术]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[php-cgi]]></category>
		<category><![CDATA[spawn-fcgi]]></category>

		<guid isPermaLink="false">http://www.bigtoy4boy.com/blog/?p=168</guid>
		<description><![CDATA[spawn-fcgi更新到1.6.0版本了，默认是不需要使用参数-C来设定开启php-cgi的数量了，沿用内置php-cgi的规则，使用env环境变量PHP_FCGI_CHILDREN来控制php-cgi的数量。我写了一个脚本，用于开启、关闭spawn-fcgi，大家可以直接使用。   &#160; #! /bin/bash &#160; # This program write by yorgo(yorgo at ruisoft.com) on 2009/04/02 # Last modified 2009/04/03 # version 1.1 # use this script to start or stop spawn-fcgi &#160; address=&#34;127.0.0.1&#34; port=&#34;9000&#34; pidpath=&#34;/tmp/spawn_phpcgi_${port}.pid&#34; user=&#34;apache&#34; group=&#34;apache&#34; phpcgi=&#34;/usr/local/php-cgi/bin/php-cgi&#34; PHP_FCGI_CHILDREN=16 PHP_FCGI_MAX_REQUESTS=1000 &#160; startspawn&#40;&#41; &#123; env - PHP_FCGI_CHILDREN=${PHP_FCGI_CHILDREN} PHP_FCGI_MAX_REQUESTS=${PHP_FCGI_MAX_REQUESTS} /usr/local/php-cgi/bin/spawn-fcgi -a ${address} -p ${port} -u ${user} [...]]]></description>
			<content:encoded><![CDATA[<p>spawn-fcgi更新到1.6.0版本了，默认是不需要使用参数-C来设定开启php-cgi的数量了，沿用内置php-cgi的规则，使用env环境变量PHP_FCGI_CHILDREN来控制php-cgi的数量。我写了一个脚本，用于开启、关闭spawn-fcgi，大家可以直接使用。</p>
<p> </p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">&nbsp;
<span style="color: #666666; font-style: italic;">#! /bin/bash</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># This program write by yorgo(yorgo at ruisoft.com) on 2009/04/02</span>
<span style="color: #666666; font-style: italic;"># Last modified 2009/04/03</span>
<span style="color: #666666; font-style: italic;"># version 1.1</span>
<span style="color: #666666; font-style: italic;"># use this script to start or stop spawn-fcgi</span>
&nbsp;
<span style="color: #007800;">address</span>=<span style="color: #ff0000;">&quot;127.0.0.1&quot;</span>
<span style="color: #007800;">port</span>=<span style="color: #ff0000;">&quot;9000&quot;</span>
<span style="color: #007800;">pidpath</span>=<span style="color: #ff0000;">&quot;/tmp/spawn_phpcgi_<span style="color: #007800;">${port}</span>.pid&quot;</span>
<span style="color: #007800;">user</span>=<span style="color: #ff0000;">&quot;apache&quot;</span>
<span style="color: #007800;">group</span>=<span style="color: #ff0000;">&quot;apache&quot;</span>
<span style="color: #007800;">phpcgi</span>=<span style="color: #ff0000;">&quot;/usr/local/php-cgi/bin/php-cgi&quot;</span>
<span style="color: #007800;">PHP_FCGI_CHILDREN</span>=<span style="color: #000000;">16</span>
<span style="color: #007800;">PHP_FCGI_MAX_REQUESTS</span>=<span style="color: #000000;">1000</span>
&nbsp;
startspawn<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: #c20cb9; font-weight: bold;">env</span> - <span style="color: #007800;">PHP_FCGI_CHILDREN</span>=<span style="color: #800000;">${PHP_FCGI_CHILDREN}</span> <span style="color: #007800;">PHP_FCGI_MAX_REQUESTS</span>=<span style="color: #800000;">${PHP_FCGI_MAX_REQUESTS}</span> <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>php-cgi<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>spawn-fcgi <span style="color: #660033;">-a</span> <span style="color: #800000;">${address}</span> <span style="color: #660033;">-p</span> <span style="color: #800000;">${port}</span> <span style="color: #660033;">-u</span> <span style="color: #800000;">${user}</span> <span style="color: #660033;">-g</span> <span style="color: #800000;">${group}</span> <span style="color: #660033;">-f</span> <span style="color: #800000;">${phpcgi}</span> <span style="color: #660033;">-P</span> <span style="color: #800000;">${pidpath}</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;success start.&quot;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<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;start&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: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$pidpath</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
	<span style="color: #000000; font-weight: bold;">then</span>
		startspawn
	<span style="color: #000000; font-weight: bold;">else</span>
		<span style="color: #007800;">pidcount</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">ps</span> <span style="color: #660033;">-ef</span> <span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #800000;">${phpcgi}</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">wc</span> -l<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;">$pidcount</span>&quot;</span> <span style="color: #660033;">-gt</span> <span style="color: #ff0000;">&quot;1&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: #ff0000;">&quot;service is already running.&quot;</span>
		<span style="color: #000000; font-weight: bold;">else</span>
			<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span> <span style="color: #800000;">${pidpath}</span>
			startspawn
		<span style="color: #000000; font-weight: bold;">fi</span>
	<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">elif</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;$1&quot;</span> == <span style="color: #ff0000;">&quot;stop&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #000000; font-weight: bold;">then</span>
	<span style="color: #007800;">pid</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #800000;">${pidpath}</span><span style="color: #000000; font-weight: bold;">`</span>
	<span style="color: #c20cb9; font-weight: bold;">kill</span> <span style="color: #800000;">${pid}</span>
	<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span> <span style="color: #800000;">${pidpath}</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;success stop.&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;spawnmanager.sh [start|stop]&quot;</span>
	<span style="color: #7a0874; font-weight: bold;">exit</span>
<span style="color: #000000; font-weight: bold;">fi</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://bigtoy4boy.com/blog/2009/04/spawn-fcgi-starter-script-with-nignx-and-phpcgi/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
