<?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>朱俊独立博客 &#187; Nginx配置</title>
	<atom:link href="http://www.zhujun.org/tag/nginx-conf/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.zhujun.org</link>
	<description>邪恶获得胜利的唯一条件，就是善良的人们保持沉默。</description>
	<lastBuildDate>Sun, 05 Feb 2012 06:34:33 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Nginx下绑定自己签发的免费SSL数字安全证书</title>
		<link>http://www.zhujun.org/web/nginx-selfsign-ssl-cert/</link>
		<comments>http://www.zhujun.org/web/nginx-selfsign-ssl-cert/#comments</comments>
		<pubDate>Mon, 08 Mar 2010 07:58:27 +0000</pubDate>
		<dc:creator>朱俊</dc:creator>
				<category><![CDATA[网络开发]]></category>
		<category><![CDATA[HTTPS]]></category>
		<category><![CDATA[Nginx配置]]></category>
		<category><![CDATA[SSL]]></category>

		<guid isPermaLink="false">http://www.zhujun.org/?p=131</guid>
		<description><![CDATA[讲述了Debian5系统，OpenSSL模块，Nginx做Web Server的环境下，自己签发免费的SSL数字证书，配置Nginx，使用HTTPS协议访问网站的步骤。]]></description>
			<content:encoded><![CDATA[<p>由于HTTP协议明文传输数据，使得嗅探无处不在，因此对某些网站如购物交易类、注册登陆类等，需要开启HTTPS协议来增加安全性，保证用户的密码不被盗取和嗅探。</p>
<p>HTTPS需要SSL数字安全证书的支持，一般找浏览器信任的CA机构签发数字证书都是要收费的，价格一般在13美元/年至50美元/年不等。（除了StartSSL和PositiveSSL）</p>
<p>如果证书只是给自己用的，防止在线管理时密码被窃听，则可以自行颁发免费的SSL数字安全证书。<br />
Debian5 + OpenSSL + Nginx环境步骤如下：<span id="more-131"></span></p>
<h3>一、使用OpenSSL生成SSL数字安全证书</h3>
<p><code class="command">openssl genrsa -out privkey.pem 2048<br />
openssl req -new -x509 -key privkey.pem -out cacert.pem -days 1095<br />
</code><br />
上述命令中第一步是生成用户证书 RSA 密钥对，且不带密码。<br />
第二步是证书请求生成和自签名，此时会要求输入参数，随便填，但Common Name必须填即将使用HTTPS的站点名称，比如：*.yourdomain.com 。</p>
<h3>二、确保Nginx支持OpenSSL模块</h3>
<p>Nginx默认是不支持SSL的，需要重新配置和编译，命令如下：<br />
<code class="command">wget http://nginx.org/download/nginx-0.7.65.tar.gz<br />
tar zxvf nginx-0.7.65.tar.gz<br />
cd /root/nginx-0.7.65<br />
./configure --with-http_stub_status_module --with-http_ssl_module<br />
make<br />
mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old<br />
cp ./objs/nginx /usr/local/nginx/sbin/nginx<br />
kill -USR2 `cat /usr/local/nginx/logs/nginx.pid`<br />
kill -QUIT `cat /usr/local/nginx/logs/nginx.pid.oldbin`<br />
</code><br />
上述命令其实也是一次标准的Nginx升级操作，其中的目录需要用户根据具体情况自行更改。<br />
另外，用户也可以在编译前注释掉 auto/cc/gcc 中的 CFLAGS=&#8221;$CFLAGS -g&#8221; 这行，使Nginx不以Debug模式编译，节约文件和内存占用、提高速度。</p>
<h3>三、修改Nginx配置</h3>
<p>修改nginx.conf中相应的server段：<br />
<code>	server<br />
	{<br />
		listen 443;<br />
		ssl on;<br />
		ssl_certificate /etc/ssl/cacert.pem;<br />
		ssl_certificate_key /etc/ssl/privkey.pem;<br />
		server_name www.yourdoamin.com;<br />
		index index.html index.htm index.php;<br />
		root  /home/wwwroot/yourdomain;<br />
		......<br />
		......<br />
	}<br />
</code><br />
其中SSL数字证书路径和域名路径也应根据实际情况修改。</p>
<h3>四、重启Nginx</h3>
<p>上传nginx.conf后，测试配置文件是否正确，并重启Nginx：<br />
<code class="command">/usr/local/nginx/sbin/nginx -t<br />
kill -HUP `cat /usr/local/nginx/logs/nginx.pid`<br />
</code></p>
<h3>五、使用HTTPS协议访问网站</h3>
<p>键入https://www.yourdomain.com 会出现警告框：<br />
<img src="/wp-content/uploads/2010/03/ssl-cert-security-warning.png" alt="浏览器数字证书安全警报" /><br />
由于是自己使用，点击查看证书-安装证书，下次就不会再弹出该警报框。</p>
<p>至此，你就可以使用HTTPS协议安全的访问网站，不用担心用户名和密码会在传输过程中被嗅探、盗取。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zhujun.org/web/nginx-selfsign-ssl-cert/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Debian系统下LNMP环境搭建笔记（二）</title>
		<link>http://www.zhujun.org/web/debian-lnmp-2/</link>
		<comments>http://www.zhujun.org/web/debian-lnmp-2/#comments</comments>
		<pubDate>Mon, 04 Jan 2010 14:04:54 +0000</pubDate>
		<dc:creator>朱俊</dc:creator>
				<category><![CDATA[网络开发]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[LNMP]]></category>
		<category><![CDATA[Nginx配置]]></category>

		<guid isPermaLink="false">http://www.zhujun.org/?p=25</guid>
		<description><![CDATA[记录了Linux（Debian）系统下面，搭建LNMP-Linux+Nginx+MySQL+PHP+eAcelerator的操作要点和心得笔记的文章之二。]]></description>
			<content:encoded><![CDATA[<h3>3. 配置LNMP</h3>
<p>Nginx由于没有免费的控制面板支持，所以需要修改 /usr/local/nginx/conf/nginx.conf 这个文件来实现服务器性能、特性的配置。<br />
上传下载配置文件建议使用Winscp这个工具，同样基于SSH协议，比Ftp安全。</p>
<p>在 <a rel="external nofollow" href="http://wiki.nginx.org/NginxConfiguration">http://wiki.nginx.org/NginxConfiguration</a> 有很多配置文件的文档和例子。</p>
<p class="b4list">默认的配置文件也不错，有以下几点需要注意：</p>
<ul>
<li>每次修改配置文件并上传后，需要测试配置文件是否正确，命令如下：<br />
<code class="command">/usr/local/nginx/sbin/nginx -t</code></li>
<li>修改配置后，必须重启Nginx才能生效，Nginx进程无缝重启命令如下：<br />
<code class="command">kill -HUP `cat /usr/local/nginx/logs/nginx.pid`</code></li>
<li>Nginx 默认不开启SSI（Server Side Include），需要手工开启，而官网给出的例子却无法正常工作，我是用如下配置代码实现SSI的：<br />
<code>location ~ .*\.(shtm|shtml)?$ {<br />
ssi on;<br />
ssi_silent_errors on;<br />
ssi_types text/shtml;<br />
}</code></li>
</ul>
<p><span id="more-25"></span><br />
MySQL的配置因为有PhpMyAdmin的存在，变得非常简单，也可以选择MySQL-Front这个客户端软件，实现对MySQL的远程配置、备份等操作。</p>
<p>PHP也是默认就配置好的，而且这个LNMP一键安装包选择的PHP FastCGI进程管理器是PHP-FPM（PHP FastCGI Process Manager），据说要比Lighttpd 的 spawn-fcgi 好许多。<br />
另外，默认情况下，eAcelerator是没有安装的，可以执行 ./eaccelerator.sh 自动安装，加速以后，PHP代码被预编译，大约可以节约一半的执行速度。以这个博客为例，加速前WordPress的处理时间大约在0.2秒，加速以后处理时间在0.1秒左右。</p>
<p>关于vsftp，个人感觉配置比较麻烦，我弄了半天，最后换成proftpd了事，后者配置相对简单。<br />
除非有多用户需求且权限要求比较严格，如果只是自己使用的话，Winscp完全可以满足上传下载的需求了。</p>
<p>经过最近的实践，感觉Linux（Debian）下使用LNMP搭建Web服务环境并没有想象中的困难，也不会比Windows下IIS的配置复杂多少。新手一至二天可以入门，完成安装、配置并投入生产环境。</p>
<p>（完）</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zhujun.org/web/debian-lnmp-2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

