<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[观夏Note]]></title> 
<link>//gm.angeldm.com/index.php</link> 
<description><![CDATA[新技术番]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[观夏Note]]></copyright>
<item>
<link>//gm.angeldm.com/post//</link>
<title><![CDATA[Nginx开机自动启动]]></title> 
<author>果面 &lt;admin@yourname.com&gt;</author>
<category><![CDATA[网络应用]]></category>
<pubDate>Sat, 30 Nov 2013 13:51:05 +0000</pubDate> 
<guid>//gm.angeldm.com/post//</guid> 
<description>
<![CDATA[ 
	把以下脚本保存为nginx文件放入/etc/init.d/nginx，然后修改权限:<br/><div class="code"><br/>chmod 755 nginx<br/></div><br/><br/>就可以通过常规命令控制Nginx状态:<br/><div class="code"><br/>#启动nginx<br/>/etc/init.d/nginx start<br/><br/>#停止nginx<br/>/etc/init.d/nginx stop<br/><br/>#重启nginx<br/>/etc/init.d/nginx restart<br/><br/>#仅重新读取配置<br/>/etc/init.d/nginx reload<br/></div><br/><br/><br/>如果需要开机自动启动nginx服务，保存好 /etc/init.d/nginx文件后，执行以下命令:<br/><br/><div class="code"><br/>chkconfig --add nginx<br/>chkconfig --level 2345 nginx on<br/></div><br/><br/>脚本内容<br/><div class="code"><br/>#! /bin/sh<br/># Default-Start:&nbsp;&nbsp;&nbsp;&nbsp; 2 3 4 5<br/># Default-Stop:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0 1 6<br/># Short-Description: starts the nginx web server<br/># chkconfig: - 85 15<br/># Description: Nginx Web Server<br/><br/>PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin<br/># If have Luajit Module<br/># export LD_LIBRARY_PATH=/path/to/luajit/lib/:$LD_LIBRARY_PATH<br/>DESC=&quot;nginx daemon&quot;<br/>NAME=nginx<br/>DAEMON=/etc/nginx/$NAME<br/>CONFIGFILE=/etc/nginx/conf/$NAME.conf<br/>PIDFILE=/etc/nginx/logs/$NAME.pid<br/>SCRIPTNAME=/etc/init.d/$NAME<br/><br/>set -e<br/>&#91; -x &quot;$DAEMON&quot; &#93; &#124;&#124; exit 0<br/><br/>do_start() &#123;<br/> $DAEMON -c $CONFIGFILE &#124;&#124; echo -n &quot;nginx already running&quot;<br/>&#125;<br/><br/>do_stop() &#123;<br/> kill -INT `cat $PIDFILE` &#124;&#124; echo -n &quot;nginx not running&quot;<br/>&#125;<br/><br/>do_reload() &#123;<br/> kill -HUP `cat $PIDFILE` &#124;&#124; echo -n &quot;nginx can&#039;t reload&quot;<br/>&#125;<br/><br/>case &quot;$1&quot; in<br/> start)<br/> echo -n &quot;Starting $DESC: $NAME&quot;<br/> do_start<br/> echo &quot;.&quot;<br/> ;;<br/> stop)<br/> echo -n &quot;Stopping $DESC: $NAME&quot;<br/> do_stop<br/> echo &quot;.&quot;<br/> ;;<br/> reload&#124;graceful)<br/> echo -n &quot;Reloading $DESC configuration...&quot;<br/> do_reload<br/> echo &quot;.&quot;<br/> ;;<br/> restart)<br/> echo -n &quot;Restarting $DESC: $NAME&quot;<br/> do_stop<br/> do_start<br/> echo &quot;.&quot;<br/> ;;<br/> *)<br/> echo &quot;Usage: $SCRIPTNAME &#123;start&#124;stop&#124;reload&#124;restart&#125;&quot; &gt;&amp;2<br/> exit 3<br/> ;;<br/>esac<br/><br/>exit 0<br/></div><br/><br/>其中<br/><br/><div class="code"><br/>PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin<br/>DESC=&quot;nginx daemon&quot;<br/>NAME=nginx<br/>DAEMON=/etc/nginx/$NAME<br/>CONFIGFILE=/etc/nginx/conf/$NAME.conf<br/>PIDFILE=/etc/nginx/logs/$NAME.pid<br/>SCRIPTNAME=/etc/init.d/$NAME<br/></div><br/><br/>按照实际情况配置路径。
]]>
</description>
</item><item>
<link>//gm.angeldm.com/read.php?&amp;guid=0#topreply</link>
<title><![CDATA[[评论] Nginx开机自动启动]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>//gm.angeldm.com/read.php?&amp;guid=0#topreply</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>