<?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>raptium&#039;s &#187; linux</title>
	<atom:link href="http://archive.raptium.net/tag/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://archive.raptium.net</link>
	<description>raptium&#039;s another weblog</description>
	<lastBuildDate>Fri, 15 Jul 2011 07:51:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
	<atom:link rel='hub' href='http://archive.raptium.net/?pushpress=hub'/>
		<item>
		<title>[配置笔记]CentOS + nginx + PHP</title>
		<link>http://archive.raptium.net/2009/05/01/centos-nginx-php-config-howto/</link>
		<comments>http://archive.raptium.net/2009/05/01/centos-nginx-php-config-howto/#comments</comments>
		<pubDate>Fri, 01 May 2009 17:51:07 +0000</pubDate>
		<dc:creator>raptium</dc:creator>
				<category><![CDATA[瞎折腾]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.raptium.net/?p=345</guid>
		<description><![CDATA[之前的这篇文章似乎是挖了个坑一直没填，然而每每出现这种情况的时候，都会发现还偏偏总有人通过 Google 搜索过来……一定让不少人失望了，真是过意不去～于是这次重新写一篇，但愿能把坑填上…… 和上次略有不同，这次 Linux 发行版是用的 CentOS，因为最近一段时间来其实我接触最多的还是 RHEL，所以就不写 Ubuntu 了。MySQL 也不在本文叙述范围之内，我实际应用的时候是直接 yum install mysql-server 装的，没有什么好说的。 nginx 用了 0.7.x 开发版。php 当然是通过 fastcgi 运行，不过没有用从 lighttpd 里分离出来的 spawn-fcgi，而是用了 php-fpm 这个补丁。 编译安装 nginx 用 yum 安装依赖包 yum install gcc openssl-devel pcre-devel zlib-devel 下载最新版的 nginx，并解压缩。 cd /usr/local/src wget http://sysoev.ru/nginx/nginx-0.7.53.tar.gz tar zxvf nginx-0.7.53.tar.gz rm -rf nginx-0.7.53.tar.gz 编译选项，取自 nginx wiki，这个配置适合 RHEL/CentOS，已经带了几个常用的模块。 cd [...]]]></description>
			<content:encoded><![CDATA[<p><em>之前的<a href="/2008/11/27/ubuntu-nginx-mysql-php-config/">这篇文章</a>似乎是挖了个坑一直没填，然而每每出现这种情况的时候，都会发现还偏偏总有人通过 Google 搜索过来……一定让不少人失望了，真是过意不去～于是这次重新写一篇，但愿能把坑填上……</em></p>
<p>和上次略有不同，这次 Linux 发行版是用的 CentOS，因为最近一段时间来其实我接触最多的还是 RHEL，所以就不写 Ubuntu 了。MySQL 也不在本文叙述范围之内，我实际应用的时候是直接 yum install mysql-server 装的，没有什么好说的。</p>
<p>nginx 用了 0.7.x 开发版。php 当然是通过 fastcgi 运行，不过没有用从 lighttpd 里分离出来的 spawn-fcgi，而是用了 php-fpm 这个补丁。<br />
<span id="more-345"></span><br />
<strong>编译安装 nginx</strong></p>
<p>用 yum 安装依赖包</p>
<pre>yum install gcc openssl-devel pcre-devel zlib-devel</pre>
<p>下载最新版的 nginx，并解压缩。</p>
<pre>cd /usr/local/src
wget http://sysoev.ru/nginx/nginx-0.7.53.tar.gz
tar zxvf nginx-0.7.53.tar.gz
rm -rf nginx-0.7.53.tar.gz</pre>
<p>编译选项，取自 <a href="http://wiki.nginx.org/NginxInstallOptions">nginx wiki</a>，这个配置适合 RHEL/CentOS，已经带了几个常用的模块。</p>
<pre>cd /usr/local/src/nginx-0.7.53
./configure
  --prefix=/usr
  --sbin-path=/usr/sbin/nginx
  --conf-path=/etc/nginx/nginx.conf
  --error-log-path=/var/log/nginx/error.log
  --pid-path=/var/run/nginx/nginx.pid
  --lock-path=/var/lock/nginx.lock
  --user=nginx
  --group=nginx
  --with-http_ssl_module
  --with-http_flv_module
  --with-http_gzip_static_module
  --http-log-path=/var/log/nginx/access.log
  --http-client-body-temp-path=/var/tmp/nginx/client/
  --http-proxy-temp-path=/var/tmp/nginx/proxy/
  --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/
make
make install</pre>
<p>由于编译时指定了默认用户和组都为 nginx，所以还要创建一下。</p>
<pre>groupadd nginx
useradd -d /home/nginx -g nginx nginx</pre>
<p><strong>编译安装 PHP</strong></p>
<p>php-fpm 只有针对 PHP 5.2.8 的补丁，尚不支持最新的 5.2.9，所以只能下载较旧的版本了。</p>
<pre>cd /usr/local/src
wget http://hk.php.net/distributions/php-5.2.8.tar.bz2
tar jxvf php-5.2.8.tar.bz2
rm -f php-5.2.8.tar.bz2</pre>
<p>下载 php-fpm 补丁</p>
<pre>cd /usr/local/src
wget http://php-fpm.anight.org/downloads/head/php-5.2.8-fpm-0.5.10.diff.gz
gzip -cd php-5.2.8-fpm-0.5.10.diff.gz | patch -d php-5.2.8 -p1
</pre>
<p>配置安装 php</p>
<pre>cd /usr/local/src/php-5.2.8
./configure
  --enable-fastcgi
  --enable-fpm
  --with-mysql
  --with-mcrypt
  --with-zlib
make
make install</pre>
<p>这个参数至少可以运行 wordpress，如果要其他更加复杂的 php 应用，可能需要加入其他 extension。<br />
如果缺少依赖的话，试试这些</p>
<pre>yum install mysql-devel libmcrypt-devel zlib-devel libxml2-devel libtool-ltdl-devel</pre>
<p><strong>nginx 和 php-fpm 的设置</strong><br />
nginx 的配置文件位于 /ect/nginx/nginx.conf<br />
最好在 http {} 的 最后加入 include vhosts/*.conf;<br />
以后其他 virtual host 可以写在 vhosts 下面<br />
比如 一个 PHPMyAdmin 的配置可以这么写</p>
<pre>server {
    listen 80;
    server_name sql.example.net;

    location / {
        index index.php;
        root /var/host/phpMyAdmin;
    }

    location ~ .*.php5?$ {
        include fastcgi_params;
        root /var/host/phpMyAdmin;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_pass unix:/var/run/php_fcgi.sock;
        fastcgi_index index.php;
    }
}</pre>
<p>其中 unix:/var/run/php_fcgi.sock 要和 php-fpm 的配置相对应，php-fpm 的默认配置（/usr/local/etc/php-fpm.conf）也基本上够用了。要修改的大概只有这一段</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;value</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;listen_address&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>/var/run/php_fcgi.sock<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;value</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;listen_options&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;value</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;backlog&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>-1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;value</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;owner&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>nginx<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;value</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;group&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>nginx<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;value</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;mode&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>0666<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://archive.raptium.net/2009/05/01/centos-nginx-php-config-howto/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ARP 擒贼记</title>
		<link>http://archive.raptium.net/2009/02/23/who-stole-my-ip/</link>
		<comments>http://archive.raptium.net/2009/02/23/who-stole-my-ip/#comments</comments>
		<pubDate>Tue, 24 Feb 2009 02:52:51 +0000</pubDate>
		<dc:creator>raptium</dc:creator>
				<category><![CDATA[瞎折腾]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[nginx]]></category>

		<guid isPermaLink="false">http://www.raptium.com/?p=311</guid>
		<description><![CDATA[注意！本文涉及标题党 之前一直在做的一个 reverse proxy，在 RHEL 上用了 nginx 。基本功能是根据 cookie 做 load balance 和特定网页内容的替换。功能上是没有问题了吧，性能的话我觉得能满足公司需要，虽然看上去不是太好。 这个小项目一直是不顺利的，主要原因就是 nginx 得不到认可。基本上和每一个人说我用了什么的时候，都要先介绍 nginx。Net Craft 给的报告是不难看，好歹也算第四大应用广泛的 Web Server 了。前三是 Apache、IIS 和 GFE。Apache 做 reverse proxy 太慢，IIS 我不会用（也不知能不能做 reverse proxy），GFE 是人家的私人珍藏…… 那么用 nginx 还是有些道理的吧。 昨天，正当梁生还在质疑 nginx seems too young to be proven 的时候，我们的 server 开始变得不稳定。基本上就是好一阵坏一阵，不能用的时候错误很奇怪，不是连不到而是 connection refused。不但网页看不到，连 ssh 都连不到。连上的 ssh 也会在几分钟内断开。起先是以为网线接触不良，但是看 message.log 没有看到 [...]]]></description>
			<content:encoded><![CDATA[<p><em>注意！本文涉及标题党</em></p>
<p>之前一直在做的一个 reverse proxy，在 RHEL 上用了 nginx 。基本功能是根据 cookie 做 load balance 和特定网页内容的替换。功能上是没有问题了吧，性能的话我觉得能满足公司需要，虽然看上去不是太好。</p>
<p>这个小项目一直是不顺利的，主要原因就是 nginx 得不到认可。基本上和每一个人说我用了什么的时候，都要先介绍 nginx。Net Craft 给的报告是不难看，好歹也算第四大应用广泛的 Web Server 了。前三是 Apache、IIS 和 GFE。Apache 做 reverse proxy 太慢，IIS 我不会用（也不知能不能做 reverse proxy），GFE 是人家的私人珍藏…… 那么用 nginx 还是有些道理的吧。</p>
<p>昨天，正当梁生还在质疑 nginx seems too young to be proven 的时候，我们的 server 开始变得不稳定。基本上就是好一阵坏一阵，不能用的时候错误很奇怪，不是连不到而是 connection refused。不但网页看不到，连 ssh 都连不到。连上的 ssh 也会在几分钟内断开。起先是以为网线接触不良，但是看 message.log 没有看到 eth0 down 的迹象。于是只好带着疑问下班，哦，我真不愿意看到这种情况啊。梁生会不会得意的笑，哈，我说你这 server 不行吧，too young～</p>
<p>我知道这个问题和 nginx 是无关的，应该是网络问题。硬件是不大会有问题的，我一直以为这还是软件的问题。不知道为啥，遇到诡异的局域网问题，我就会自然的想到 ARP。百度上搜 ARP 的结果是恐怖的，Google 上要好些，曾几何时 ARP 劫持在中国大陆的泛滥，让很多人以为这是一个病毒的名字。我是觉得处处防范的企业内部出现病毒是不大可能的，而且现在的故障不像是 ARP 劫持，倒像是……哦，谁偷了我的 IP 啊～～</p>
<p>Keats 给我的信息是很有用的，就是不断地 ping 那个 IP，TTL 值竟然会变，一会儿 64 一会儿 128，64的时候能连上，128就connection refused。于是问题变得清晰起来，这分明是两台机器嘛，RHEL5 的默认 TTL 是 64 的，返回 128 估计就是给某台 Windows XP 抢了 IP。于是乎，arp -a 蹲点蹲了一阵，终于让我揪出了抢我 IP 的 MAC Address～ 交给 Keats，剩下的事情，就不是我们 Team 的啦，Technical Team 的同事们加油啊，你们有什么妙招根据 MAC 地址把那台机器的主人找出来吗……</p>
]]></content:encoded>
			<wfw:commentRss>http://archive.raptium.net/2009/02/23/who-stole-my-ip/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>init.d script for nginx, RedHat</title>
		<link>http://archive.raptium.net/2009/01/19/initd-script-for-nginx-redhat/</link>
		<comments>http://archive.raptium.net/2009/01/19/initd-script-for-nginx-redhat/#comments</comments>
		<pubDate>Mon, 19 Jan 2009 09:36:51 +0000</pubDate>
		<dc:creator>raptium</dc:creator>
				<category><![CDATA[瞎折腾]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[RedHat]]></category>

		<guid isPermaLink="false">http://www.raptium.com/?p=248</guid>
		<description><![CDATA[在RHEL 5.2上经过测试，debian/ubuntu系其实不需此脚本，因为apt源里装的已经自带了。不是我写的，我只是拿来改到能用为止…… 不过还真是找了挺久。网上流传的某些版本不如这个好～ start-stop-daemon 好像 RedHat 上也没有自带，那个就随便搜搜装一个吧。 #! /bin/sh &#160; ### BEGIN INIT INFO # Provides: nginx # Required-Start: $all # Required-Stop: $all # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: starts the nginx web server # Description: starts nginx using start-stop-daemon ### END INIT INFO &#160; &#160; PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DAEMON=/usr/local/nginx/sbin/nginx [...]]]></description>
			<content:encoded><![CDATA[<p>在RHEL 5.2上经过测试，debian/ubuntu系其实不需此脚本，因为apt源里装的已经自带了。不是我写的，我只是拿来改到能用为止…… 不过还真是找了挺久。网上流传的某些版本不如这个好～<br />
start-stop-daemon 好像 RedHat 上也没有自带，那个就随便搜搜装一个吧。</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#! /bin/sh</span>
&nbsp;
<span style="color: #666666; font-style: italic;">### BEGIN INIT INFO</span>
<span style="color: #666666; font-style: italic;"># Provides:          nginx</span>
<span style="color: #666666; font-style: italic;"># Required-Start:    $all</span>
<span style="color: #666666; font-style: italic;"># Required-Stop:     $all</span>
<span style="color: #666666; font-style: italic;"># Default-Start:     2 3 4 5</span>
<span style="color: #666666; font-style: italic;"># Default-Stop:      0 1 6</span>
<span style="color: #666666; font-style: italic;"># Short-Description: starts the nginx web server</span>
<span style="color: #666666; font-style: italic;"># Description:       starts nginx using start-stop-daemon</span>
<span style="color: #666666; font-style: italic;">### END INIT INFO</span>
&nbsp;
&nbsp;
<span style="color: #007800;">PATH</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>sbin:<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>bin:<span style="color: #000000; font-weight: bold;">/</span>sbin:<span style="color: #000000; font-weight: bold;">/</span>bin:<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin:<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin
<span style="color: #007800;">DAEMON</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>nginx<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>nginx
<span style="color: #007800;">NAME</span>=nginx
<span style="color: #007800;">DESC</span>=nginx
<span style="color: #007800;">PIDFILE</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>nginx<span style="color: #000000; font-weight: bold;">/</span>logs<span style="color: #000000; font-weight: bold;">/</span>nginx.pid
&nbsp;
<span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #660033;">-x</span> <span style="color: #007800;">$DAEMON</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Include nginx defaults if available</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>default<span style="color: #000000; font-weight: bold;">/</span>nginx <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;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>default<span style="color: #000000; font-weight: bold;">/</span>nginx
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">set</span> <span style="color: #660033;">-e</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #000000; font-weight: bold;">in</span>
  start<span style="color: #7a0874; font-weight: bold;">&#41;</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Starting <span style="color: #007800;">$DESC</span>: &quot;</span>
        start-stop-daemon <span style="color: #660033;">--start</span> <span style="color: #660033;">--quiet</span> <span style="color: #660033;">--pidfile</span> <span style="color: #007800;">$PIDFILE</span> 
          <span style="color: #660033;">--exec</span> <span style="color: #007800;">$DAEMON</span> <span style="color: #660033;">--</span> <span style="color: #007800;">$DAEMON_OPTS</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$NAME</span>.&quot;</span>
        <span style="color: #000000; font-weight: bold;">;;</span>
  stop<span style="color: #7a0874; font-weight: bold;">&#41;</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Stopping <span style="color: #007800;">$DESC</span>: &quot;</span>
        start-stop-daemon <span style="color: #660033;">--stop</span> <span style="color: #660033;">--quiet</span> <span style="color: #660033;">--pidfile</span> <span style="color: #007800;">$PIDFILE</span> 
          <span style="color: #660033;">--exec</span> <span style="color: #007800;">$DAEMON</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$NAME</span>.&quot;</span>
        <span style="color: #000000; font-weight: bold;">;;</span>
  restart<span style="color: #000000; font-weight: bold;">|</span>force-reload<span style="color: #7a0874; font-weight: bold;">&#41;</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Restarting <span style="color: #007800;">$DESC</span>: &quot;</span>
        start-stop-daemon <span style="color: #660033;">--stop</span> <span style="color: #660033;">--quiet</span> <span style="color: #660033;">--pidfile</span> <span style="color: #007800;">$PIDFILE</span> 
          <span style="color: #660033;">--exec</span> <span style="color: #007800;">$DAEMON</span>
        <span style="color: #c20cb9; font-weight: bold;">sleep</span> <span style="color: #000000;">1</span>
        start-stop-daemon <span style="color: #660033;">--start</span> <span style="color: #660033;">--quiet</span> <span style="color: #660033;">--pidfile</span> <span style="color: #007800;">$PIDFILE</span> 
          <span style="color: #660033;">--exec</span> <span style="color: #007800;">$DAEMON</span> <span style="color: #660033;">--</span> <span style="color: #007800;">$DAEMON_OPTS</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$NAME</span>.&quot;</span>
        <span style="color: #000000; font-weight: bold;">;;</span>
  reload<span style="color: #7a0874; font-weight: bold;">&#41;</span>
      <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Reloading <span style="color: #007800;">$DESC</span> configuration: &quot;</span>
      start-stop-daemon <span style="color: #660033;">--stop</span> <span style="color: #660033;">--signal</span> HUP <span style="color: #660033;">--quiet</span> <span style="color: #660033;">--pidfile</span> <span style="color: #007800;">$PIDFILE</span> 
        <span style="color: #660033;">--exec</span> <span style="color: #007800;">$DAEMON</span>
      <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$NAME</span>.&quot;</span>
      <span style="color: #000000; font-weight: bold;">;;</span>
  <span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
        <span style="color: #007800;">N</span>=<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">$NAME</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Usage: <span style="color: #007800;">$N</span> {start|stop|restart|reload|force-reload}&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">2</span>
        <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
        <span style="color: #000000; font-weight: bold;">;;</span>
<span style="color: #000000; font-weight: bold;">esac</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://archive.raptium.net/2009/01/19/initd-script-for-nginx-redhat/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[配置笔记]Ubuntu + nginx + MySQL + PHP</title>
		<link>http://archive.raptium.net/2008/11/27/ubuntu-nginx-mysql-php-config/</link>
		<comments>http://archive.raptium.net/2008/11/27/ubuntu-nginx-mysql-php-config/#comments</comments>
		<pubDate>Wed, 26 Nov 2008 16:49:08 +0000</pubDate>
		<dc:creator>raptium</dc:creator>
				<category><![CDATA[瞎折腾]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Web Application Development]]></category>

		<guid isPermaLink="false">http://www.raptium.cn/?p=210</guid>
		<description><![CDATA[本来想写个How-To的，但是突然觉得自己没有功力教会别人，所以就不做标题党了。配置笔记，基本上是记录给自己看得，能够给别人有所帮助就更好了～ 最近不断的看到有关 nginx 的消息，基本上都是正面的，看起来性能非常好。对于性能好的东西，我通常有一种莫名的恐惧，因为这些高级货一是要用到好的硬件上，二是配置复杂，如果还有三的话，那就是我通常不需要这么高的性能。然而这次稍稍看多了些 nginx 的介绍，其实它还是轻量级的，出道也不久，却能够被不少网站重用。俄罗斯人写的程序，作者自称英文较差，不过文档却也有了多国语言版，看来这东西真是受世界各国人民的喜爱啊～ 晚上不想玩WoW，就装了个虚拟机，搞了 nginx 玩玩，记录如下。 配置表 OS: Ubuntu Linux 8.10 Server Web Server: nginx 0.6.33 Database Server: MySQL （apt源里的版本） PHP: php-cgi （apt源里的版本） 装系统，不用多说。我是装在虚拟机里的，刚开始用的VirtualBox，不过装好后出现了问题。因为Ubuntu Server的默认内核把PAE编译进去了，但是VirtualBox并不支持虚拟CPU的PAE功能，于是装好后不能启动。网上有关解决方案是修复模式下装其他内核，我发现这样又遇到更多问题……于是放弃。改用VMWare，一切安好。 Ubuntu基本上就用默认安装了，在选要什么Package的时候，除了OpenSSH Server，其他可以都不用选。真要选LAMP也行，不过到时候还是要把Apache给关掉～ 系统装好后，老习惯 sudo apt-get update sudo apt-get upgrade Ubuntu 8.10 发布没多久，不需要下多少更新，几分钟搞定。 然后准备下载编译 nginx ，不过在此之前我们要把编译环境设好。 sudo apt-get install build-essential libpcre3-dev libssl-dev 最短命令就这样了，会自动加上一堆dependency的，都按y就行了。 之后是下载编译，nginx 似乎已经出到 0.7.x 了，不过这是第一次弄，我还是选择了stable的 0.6.33 [...]]]></description>
			<content:encoded><![CDATA[<p><em>本来想写个How-To的，但是突然觉得自己没有功力教会别人，所以就不做标题党了。配置笔记，基本上是记录给自己看得，能够给别人有所帮助就更好了～</em></p>
<p>最近不断的看到有关 nginx 的消息，基本上都是正面的，看起来性能非常好。对于性能好的东西，我通常有一种莫名的恐惧，因为这些高级货一是要用到好的硬件上，二是配置复杂，如果还有三的话，那就是我通常不需要这么高的性能。然而这次稍稍看多了些 nginx 的介绍，其实它还是轻量级的，出道也不久，却能够被不少网站重用。俄罗斯人写的程序，作者自称英文较差，不过文档却也有了多国语言版，看来这东西真是受世界各国人民的喜爱啊～</p>
<p>晚上不想玩WoW，就装了个虚拟机，搞了 nginx 玩玩，记录如下。<span id="more-210"></span></p>
<p>配置表</p>
<ul>
<li>OS: Ubuntu Linux 8.10 Server</li>
<li>Web Server: nginx 0.6.33</li>
<li>Database Server: MySQL （apt源里的版本）</li>
<li>PHP: php-cgi （apt源里的版本）</li>
</ul>
<p>装系统，不用多说。我是装在虚拟机里的，刚开始用的VirtualBox，不过装好后出现了问题。因为Ubuntu Server的默认内核把PAE编译进去了，但是VirtualBox并不支持虚拟CPU的PAE功能，于是装好后不能启动。网上有关解决方案是修复模式下装其他内核，我发现这样又遇到更多问题……于是放弃。改用VMWare，一切安好。</p>
<p>Ubuntu基本上就用默认安装了，在选要什么Package的时候，除了OpenSSH Server，其他可以都不用选。真要选LAMP也行，不过到时候还是要把Apache给关掉～</p>
<p>系统装好后，老习惯</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">sudo apt-get update
sudo apt-get upgrade</pre></div></div>

<p>Ubuntu 8.10 发布没多久，不需要下多少更新，几分钟搞定。<br />
然后准备下载编译 nginx ，不过在此之前我们要把编译环境设好。</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">sudo apt-get install build-essential libpcre3-dev libssl-dev</pre></div></div>

<p>最短命令就这样了，会自动加上一堆dependency的，都按y就行了。</p>
<p>之后是下载编译，nginx 似乎已经出到 0.7.x 了，不过这是第一次弄，我还是选择了stable的 0.6.33</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">wget http://sysoev.ru/nginx/nginx-0.6.33.tar.gz
tar zxvf nginx-0.6.33.tar.gz
cd nginx-0.6.33
./configure --sbin-path=/usr/local/sbin --with-http_ssl_module
make
sudo make install</pre></div></div>

<p>至此 nginx 安装完毕。如果现在运行 nginx 的话，应该可以看到简陋的欢迎页面了，不过先不急，搞定别的先～</p>
<p>安装 PHP，</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">sudo apt-get install php5-cgi</pre></div></div>

<p>因为在 nginx 上 PHP 必须以 FastCGI 的方式运行，所以就直接装这个包了。但是 nginx 有没有自己运行 CGI 的机制，所以还需要用到 spawn-fcgi 这个小程序。这是 lighttpd 里面带的，不过为了它我们并不需要装整个 lighttpd，自己编译一个 lighttpd 然后取出这个程序单独用就好了～</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">wget http://www.lighttpd.net/download/lighttpd-1.4.20.tar.gz
tar zxvf lighttpd-1.4.20
./configure
make
sudo cp src/spawn-fcgi /usr/local/bin/spawn-fcgi</pre></div></div>

<p><span style="text-decoration: line-through;">[明天继续update...]</span></p>
<p>我在公司的另一项任务中也用到了 nginx， 或许之后会另写文章记录配置过程。</p>
<p><strong>Reference</strong></p>
<ul>
<li><a href="http://articles.slicehost.com/2007/12/3/ubuntu-gutsy-installing-nginx-from-source">Ubuntu Gutsy &#8211; Installing Nginx from source</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://archive.raptium.net/2008/11/27/ubuntu-nginx-mysql-php-config/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Served from: archive.raptium.net @ 2012-02-06 00:20:31 by W3 Total Cache -->
