<?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>SSL模块 &#8211; 编码无悔 /  Intent &amp; Focused</title>
	<atom:link href="https://www.codelast.com/tag/ssl%e6%a8%a1%e5%9d%97/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.codelast.com</link>
	<description>最优化之路</description>
	<lastBuildDate>Mon, 27 Apr 2020 17:57:51 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>[原创] 为nginx添加SSL支持模块</title>
		<link>https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e4%b8%banginx%e6%b7%bb%e5%8a%a0ssl%e6%94%af%e6%8c%81%e6%a8%a1%e5%9d%97/</link>
					<comments>https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e4%b8%banginx%e6%b7%bb%e5%8a%a0ssl%e6%94%af%e6%8c%81%e6%a8%a1%e5%9d%97/#respond</comments>
		
		<dc:creator><![CDATA[learnhard]]></dc:creator>
		<pubDate>Mon, 12 Jun 2017 04:32:20 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[原创]]></category>
		<category><![CDATA[综合]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[SSL模块]]></category>
		<guid isPermaLink="false">https://www.codelast.com/?p=9285</guid>

					<description><![CDATA[<p>
因为网站要加SSL证书的原因，把nginx折腾了一番，结果SSL相关的配置加到了nginx的配置文件中后，nginx竟然启动不起来了，用 <span style="color:#0000ff;">systemctl status nginx</span> 查看到的错误信息大致如下：</p>
<blockquote>
<p>
		Failed to start SYSV: Nginx is an HTTP(S) server, HTTP(S) reverse ...</p>
</blockquote>
<p>于是用如下命令测试问题所在：</p>
<blockquote>
<p>
		/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf</p>
</blockquote>
<p>其中，/usr/local/nginx/sbin/nginx 是我的nginx安装后的可执行程序路径，/usr/local/nginx/conf/nginx.conf 是我的nginx主配置文件路径。<br />
<span id="more-9285"></span><br />
该命令输出如下：</p>
<blockquote>
<div>
		nginx: [emerg] the &#34;ssl&#34; parameter requires ngx_http_ssl_module in /usr/local/nginx/conf/nginx.conf:41</div>
</blockquote>
<div>
	可见，nginx缺少SSL模块支持。这是因为我当年建站的时候根本没用到SSL啊，所以以前编译nginx的时候使用了不带SSL支持的默认编译参数。<br />
	为了让nginx添加SSL模块，只能重新编译它。但是，如何在现有nginx的基础上，添加一个支持SSL的编译参数呢？首先要找回原来编译nginx时的编译参数，然后再加上支持SSL的编译参数。如果不这样做，那么编译出来的nginx可能就会有问题（某些旧的编译参数被去掉了，使得nginx不能支持某些功能）。<br />
	<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="http://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">http://www.codelast.com/</span></a><br />
	所以先查看旧的nginx的编译参数：
<section class="output_wrapper" id="output_wrapper_id" style="font-size: 16px; color: rgb(62, 62, 62); line-height: 1.6; letter-spacing: 0px; font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;">
<pre style="font-size: inherit; color: inherit; line-height: inherit; margin-top: 0px; margin-bottom: 0px; padding: 0px;">
<code class="bash language-bash hljs" style="margin: 0px 2px; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); padding: 0.5em; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;">/usr/<span class="hljs-built_in" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(248, 35, 117); word-wrap: inherit !important; word-break: inherit !important;">local</span>/nginx/sbin/nginx&#160;-V
</code></pre>
</section>
<p>输出的信息中，最重要的一句是：</p></div>
<blockquote>
<div>
		configure arguments: --prefix=/usr/local/nginx</div>
</blockquote>
<div>
	可见，当时我编译nginx的时候，只是指定了一个安装路径，没有其他特殊的编译参数。那么现在事情就好办了：回到nginx的源码目录下，加上SSL支持参数重新编译：
<section class="output_wrapper" id="output_wrapper_id" style="font-size: 16px; color: rgb(62, 62, 62); line-height: 1.6; letter-spacing: 0px; font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;">
<pre style="font-size: inherit; color: inherit; line-height: inherit; margin-top: 0px; margin-bottom: 0px; padding: 0px;">
<code class="bash language-bash hljs" style="margin: 0px 2px; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); padding: 0.5em; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;">./configure&#160;--prefix=/usr/</code></pre></section></div>&#8230; <a href="https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e4%b8%banginx%e6%b7%bb%e5%8a%a0ssl%e6%94%af%e6%8c%81%e6%a8%a1%e5%9d%97/" class="read-more">Read More </a>]]></description>
										<content:encoded><![CDATA[<p>
因为网站要加SSL证书的原因，把nginx折腾了一番，结果SSL相关的配置加到了nginx的配置文件中后，nginx竟然启动不起来了，用 <span style="color:#0000ff;">systemctl status nginx</span> 查看到的错误信息大致如下：</p>
<blockquote>
<p>
		Failed to start SYSV: Nginx is an HTTP(S) server, HTTP(S) reverse ...</p>
</blockquote>
<p>于是用如下命令测试问题所在：</p>
<blockquote>
<p>
		/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf</p>
</blockquote>
<p>其中，/usr/local/nginx/sbin/nginx 是我的nginx安装后的可执行程序路径，/usr/local/nginx/conf/nginx.conf 是我的nginx主配置文件路径。<br />
<span id="more-9285"></span><br />
该命令输出如下：</p>
<blockquote>
<div>
		nginx: [emerg] the &quot;ssl&quot; parameter requires ngx_http_ssl_module in /usr/local/nginx/conf/nginx.conf:41</div>
</blockquote>
<div>
	可见，nginx缺少SSL模块支持。这是因为我当年建站的时候根本没用到SSL啊，所以以前编译nginx的时候使用了不带SSL支持的默认编译参数。<br />
	为了让nginx添加SSL模块，只能重新编译它。但是，如何在现有nginx的基础上，添加一个支持SSL的编译参数呢？首先要找回原来编译nginx时的编译参数，然后再加上支持SSL的编译参数。如果不这样做，那么编译出来的nginx可能就会有问题（某些旧的编译参数被去掉了，使得nginx不能支持某些功能）。<br />
	<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="http://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">http://www.codelast.com/</span></a><br />
	所以先查看旧的nginx的编译参数：</p>
<section class="output_wrapper" id="output_wrapper_id" style="font-size: 16px; color: rgb(62, 62, 62); line-height: 1.6; letter-spacing: 0px; font-family: &quot;Helvetica Neue&quot;, Helvetica, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;">
<pre style="font-size: inherit; color: inherit; line-height: inherit; margin-top: 0px; margin-bottom: 0px; padding: 0px;">
<code class="bash language-bash hljs" style="margin: 0px 2px; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); padding: 0.5em; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;">/usr/<span class="hljs-built_in" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(248, 35, 117); word-wrap: inherit !important; word-break: inherit !important;">local</span>/nginx/sbin/nginx&nbsp;-V
</code></pre>
</section>
<p>输出的信息中，最重要的一句是：</p></div>
<blockquote>
<div>
		configure arguments: --prefix=/usr/local/nginx</div>
</blockquote>
<div>
	可见，当时我编译nginx的时候，只是指定了一个安装路径，没有其他特殊的编译参数。那么现在事情就好办了：回到nginx的源码目录下，加上SSL支持参数重新编译：</p>
<section class="output_wrapper" id="output_wrapper_id" style="font-size: 16px; color: rgb(62, 62, 62); line-height: 1.6; letter-spacing: 0px; font-family: &quot;Helvetica Neue&quot;, Helvetica, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;">
<pre style="font-size: inherit; color: inherit; line-height: inherit; margin-top: 0px; margin-bottom: 0px; padding: 0px;">
<code class="bash language-bash hljs" style="margin: 0px 2px; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); padding: 0.5em; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;">./configure&nbsp;--prefix=/usr/<span class="hljs-built_in" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(248, 35, 117); word-wrap: inherit !important; word-break: inherit !important;">local</span>/nginx&nbsp;--with-http_ssl_module
make
</code></pre>
</section>
<p><span id="docs-internal-guid-a0001a48-9a82-942a-4ea2-e8bd8bba5160"><span style="font-size: 11pt; font-family: Arial; vertical-align: baseline; white-space: pre-wrap;"><span style="color:#ff0000;">注意，此时千万不能手快直接 make install</span>！因为我原来的nginx还有一堆的配置文件，不能被覆盖。我们应该只覆盖编译出来的nginx可执行程序：</span></span></p>
<section class="output_wrapper" id="output_wrapper_id" style="font-size: 16px; color: rgb(62, 62, 62); line-height: 1.6; letter-spacing: 0px; font-family: &quot;Helvetica Neue&quot;, Helvetica, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;">
<pre style="font-size: inherit; color: inherit; line-height: inherit; margin-top: 0px; margin-bottom: 0px; padding: 0px;">
<code class="bash language-bash hljs" style="margin: 0px 2px; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); padding: 0.5em; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;">cp&nbsp;/usr/<span class="hljs-built_in" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(248, 35, 117); word-wrap: inherit !important; word-break: inherit !important;">local</span>/nginx/sbin/nginx&nbsp;~/
cp&nbsp;objs/nginx&nbsp;/usr/<span class="hljs-built_in" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(248, 35, 117); word-wrap: inherit !important; word-break: inherit !important;">local</span>/nginx/sbin/
</code></pre>
</section>
<p><span id="docs-internal-guid-a0001a48-9a82-942a-4ea2-e8bd8bba5160"><span style="font-size: 11pt; font-family: Arial; vertical-align: baseline; white-space: pre-wrap;">其中，objs/nginx 是新编译出来的nginx可执行程序。</span></span><br />
	<span id="docs-internal-guid-a0001a48-9a82-942a-4ea2-e8bd8bba5160"><span style="font-size: 11pt; font-family: Arial; vertical-align: baseline; white-space: pre-wrap;">覆盖之后，再尝试重新启动nginx，就没有问题了。</p>
<p>	<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
	<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;版权声明&nbsp;<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;<br />
	转载需注明出处：<u><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><em><span style="color: rgb(0, 0, 255);"><strong style="font-size: 16px;"><span style="font-family: arial, helvetica, sans-serif;">codelast.com</span></strong></span></em></a></u>&nbsp;<br />
	感谢关注我的微信公众号（微信扫一扫）：</span></span></p>
<p style="border: 0px; font-size: 13px; margin: 0px 0px 9px; outline: 0px; padding: 0px; color: rgb(77, 77, 77);">
		<span id="docs-internal-guid-a0001a48-9a82-942a-4ea2-e8bd8bba5160"><span style="font-size: 11pt; font-family: Arial; vertical-align: baseline; white-space: pre-wrap;"><img decoding="async" alt="wechat qrcode of codelast" src="https://www.codelast.com/codelast_wechat_qr_code.jpg" style="width: 200px; height: 200px;" /></span></span></p>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e4%b8%banginx%e6%b7%bb%e5%8a%a0ssl%e6%94%af%e6%8c%81%e6%a8%a1%e5%9d%97/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
