<?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>Dongsheng&#039;s thoughts &#187; nginx</title>
	<atom:link href="http://log.dongsheng.org/tag/nginx/feed/" rel="self" type="application/rss+xml" />
	<link>http://log.dongsheng.org</link>
	<description></description>
	<lastBuildDate>Thu, 19 Jan 2012 08:40:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>编写 Nginx 启动脚本</title>
		<link>http://log.dongsheng.org/2008/12/07/nginx-boot-script/</link>
		<comments>http://log.dongsheng.org/2008/12/07/nginx-boot-script/#comments</comments>
		<pubDate>Sun, 07 Dec 2008 09:10:45 +0000</pubDate>
		<dc:creator>Dongsheng Cai</dc:creator>
				<category><![CDATA[OS]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[nginx]]></category>

		<guid isPermaLink="false">http://log.dongsheng.org/?p=25</guid>
		<description><![CDATA[今天试了一下直接使用 php-cgi 启用 fastcgi 的脚本竟然又可以使用了，真奇怪。 写了一个自动启动脚本，放到这里做个备份： #!/sbin/runscript # Copyright 1999-2004 Gentoo Foundation # Distributed under the terms of the GNU General Public License, v2 or # later # $Header:$ NGINX_EXEC=/usr/sbin/nginx PHP_EXEC=/usr/bin/php-cgi depend() { need logger net } start () { ebegin "Starting FCGI Service" spawn-fcgi -a 127.0.0.1 -p 9000 -C 5 -f /usr/bin/php-cgi eend $? [...]]]></description>
			<content:encoded><![CDATA[<p>今天试了一下直接使用 php-cgi 启用 fastcgi 的脚本竟然又可以使用了，真奇怪。<br />
写了一个自动启动脚本，放到这里做个备份：</p>
<pre>
#!/sbin/runscript
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License, v2 or
# later
# $Header:$

NGINX_EXEC=/usr/sbin/nginx
PHP_EXEC=/usr/bin/php-cgi

depend() {
need logger net
}

start () {
ebegin "Starting FCGI Service"
spawn-fcgi -a 127.0.0.1 -p 9000 -C 5 -f /usr/bin/php-cgi
eend $?
ebegin "Starting Nginx"
start-stop-daemon --start --exec ${NGINX_EXEC}
eend $?
}

stop() {
ebegin "Stopping FCGI Service"
killall php-cgi
eend $?
ebegin "Stopping Nginx"
killall nginx
start-stop-daemon --stop --quiet --pidfile /var/run/nginx.pid
--exec $NGINX_EXEC
eend $?
}
</pre>
<p>然后把这个文件保存为 /etc/init.d/httpd 并加上执行权限。<br />
然后运行 rc-config add httpd default</p>
]]></content:encoded>
			<wfw:commentRss>http://log.dongsheng.org/2008/12/07/nginx-boot-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>在 Gentoo 上安装 Nginx + php</title>
		<link>http://log.dongsheng.org/2008/12/06/nginx-php-gentoo/</link>
		<comments>http://log.dongsheng.org/2008/12/06/nginx-php-gentoo/#comments</comments>
		<pubDate>Sat, 06 Dec 2008 09:06:29 +0000</pubDate>
		<dc:creator>Dongsheng Cai</dc:creator>
				<category><![CDATA[OS]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[fastcgi]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://log.dongsheng.org/?p=23</guid>
		<description><![CDATA[从源码安装 Nginx ./configure --prefix=/usr --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx_error.log --http-log-path=/var/log/nginx_access.log --pid-path=/var/run/nginx.pid --http-client-body-temp-path=/var/tmp/nginx_client_body.tmp --http-proxy-temp-path=/var/tmp/nginx_proxy.tmp --http-fastcgi-temp-path=/var/tmp/nginx_fastcgi.tmp --with-http_stub_status_module --with-http_ssl_module --with-openssl=/usr/src/openssl （启用了监控和ssl模块，重新设置文件路径） make make install 注意，&#8211;with-openssl 指向的是 openssl 的完整源码树。 Nginx 的配置 在 server 段中加入 root 指令，指向网站根目录，然后把 location / 段改为： location / { stub_status on; access_log off; } 这样就能在首页显示状态信息了，在这里用作测试。 从源码安装 PHP 5.2.7 ./configure --prefix=/usr --with-config-file-path=/etc/php --with-curl=shared --with-curlwrappers --enable-fastcgi --enable-force-cgi-redirect --with-openssl=shared --with-mysql=shared --with-mysqli=shared --enable-zip=shared [...]]]></description>
			<content:encoded><![CDATA[<h4>从源码安装 Nginx</h4>
<pre>./configure --prefix=/usr --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx_error.log --http-log-path=/var/log/nginx_access.log --pid-path=/var/run/nginx.pid --http-client-body-temp-path=/var/tmp/nginx_client_body.tmp --http-proxy-temp-path=/var/tmp/nginx_proxy.tmp  --http-fastcgi-temp-path=/var/tmp/nginx_fastcgi.tmp --with-http_stub_status_module --with-http_ssl_module --with-openssl=/usr/src/openssl</pre>
<p>（启用了监控和ssl模块，重新设置文件路径）<br />
<code>make<br />
make install</code><br />
注意，&#8211;with-openssl 指向的是 openssl 的完整源码树。</p>
<h4>Nginx 的配置</h4>
<p>在 server 段中加入 root 指令，指向网站根目录，然后把 location / 段改为：</p>
<pre>location / {
  stub_status on;
  access_log off;
}</pre>
<p>这样就能在首页显示状态信息了，在这里用作测试。</p>
<h4>从源码安装 PHP 5.2.7</h4>
<pre>./configure --prefix=/usr --with-config-file-path=/etc/php --with-curl=shared --with-curlwrappers --enable-fastcgi --enable-force-cgi-redirect --with-openssl=shared --with-mysql=shared --with-mysqli=shared --enable-zip=shared --with-xmlrpc=shared --enable-mbstring --enable-pdo=shared --with-pdo-sqlite=shared --with-sqlite=shared --with-gd=shared --with-zlib
make
make install
cp php.ini-dist /etc/php/php.ini</pre>
<p>在这种情况下，模块会编译进 PHP 而不是作为模块动态加载，如果想要创建模块需要设置 shared 选项，比如我要把 PDO 作为模块加载：</p>
<pre>./configure --enable-pdo=shared --with-pdo-sqlite=shared --with-sqlite=shared</pre>
<p>如果是 apache 的话要加上  &#8211;with-apxs2 项以创建模块。</p>
<h4>设置 FASTCGI</h4>
<p>我尝试用 <a href="http://blog.kovyrin.net/2006/05/30/nginx-php-fastcgi-howto/">php-cgi 直接创建 FCGI 服务</a>，但无法成功，只好使用 lighttpd 的 spawn-fcgi 程序创建 FCGI 服务（这里偷懒用 emerge 装的 lighttpd）：</p>
<pre>spawn-fcgi -a 127.0.0.1 -p 9000 -C 5 -f /usr/bin/php-cgi</pre>
<p>最后修改 nginx 的配置文件使之调用 php FCGI 服务：</p>
<pre>location / {
 index index.php index.htm index.html;
}
location ~ .php$ {
 fastcgi_pass 127.0.0.1:9000;
 fastcgi_index index.php;
 include fastcgi_params;
 fastcgi_param SCRIPT_FILENAME /var/www$fastcgi_script_name;
}</pre>
<p>创建一个 phpinfo 页面测试一下吧！</p>
<h4>参考</h4>
<p><a href="http://wiki.codemongers.com/NginxInstallOptions">Nginx 编译参数说明</a><br />
<a href="http://php.mirrors.ilisys.com.au/manual/en/configure.php">PHP 编译参数说明</a><br />
<a href="http://blog.s135.com/post/366.htm">Nginx 0.7.x + PHP 5.2.6（FastCGI）搭建胜过Apache十倍的Web服务器（第4版）</a><br />
<a href="http://blog.kovyrin.net/2006/05/30/nginx-php-fastcgi-howto/">Nginx With PHP As FastCGI Howto</a></p>
]]></content:encoded>
			<wfw:commentRss>http://log.dongsheng.org/2008/12/06/nginx-php-gentoo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

