<?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>apache &#8211; richliu&#039;s blog</title>
	<atom:link href="https://richliu.com/tag/apache/feed/" rel="self" type="application/rss+xml" />
	<link>https://richliu.com</link>
	<description>Linux, 工作, 生活, 家人</description>
	<lastBuildDate>Wed, 18 Jan 2017 03:34:56 +0000</lastBuildDate>
	<language>zh-TW</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>[Gentoo] 替 Apache 加上 http2 支援</title>
		<link>https://richliu.com/2016/10/17/2026/gentoo-%e6%9b%bf-apache-%e5%8a%a0%e4%b8%8a-http2-%e6%94%af%e6%8f%b4/</link>
					<comments>https://richliu.com/2016/10/17/2026/gentoo-%e6%9b%bf-apache-%e5%8a%a0%e4%b8%8a-http2-%e6%94%af%e6%8f%b4/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Mon, 17 Oct 2016 11:45:57 +0000</pubDate>
				<category><![CDATA[Gentoo]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[apache2]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[http/2]]></category>
		<guid isPermaLink="false">https://richliu.com/?p=2026</guid>

					<description><![CDATA[<p>沒有很難, 因為之前弄了 Letsencrypt 就想加一下 HTTP2, 這應該也很成熟了 /etc/por [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://richliu.com/2016/10/17/2026/gentoo-%e6%9b%bf-apache-%e5%8a%a0%e4%b8%8a-http2-%e6%94%af%e6%8f%b4/">[Gentoo] 替 Apache 加上 http2 支援</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>沒有很難, 因為之前弄了 Letsencrypt 就想加一下 HTTP2, 這應該也很成熟了<br />
<span id="more-2026"></span></p>
<p>/etc/portage/package.use 加上 alpn</p>
<pre lang="text">
www-servers/apache threads alpn
</pre>
<p>/etc/conf.d/apache 內的 APACHE2_OPTS 加上 -DSSL -DHTTP2, 像是</p>
<pre lang="text">
APACHE2_OPTS="-D DEFAULT_VHOST -D INFO -D SSL -D SSL_DEFAULT_VHOST -D LANGUAGE -D PHP -DHTTP2"
</pre>
<p>然後再執行</p>
<pre lang="text">
$ emerge -av apache
$ etc-update
$ !/etc/init.d/apache restart
</pre>
<p>etc-update 一定要做, 我就忘了做這步卡很久, 花了一點時間才 debug 出來. </p>
<p>這篇 Debug 非常好用, 不過用來用去 curl debug 最好用, 但是其他的 tool 也很有趣, 像 h2c 那個可以看 session 狀態.<br />
<a href="https://blog.cloudflare.com/tools-for-debugging-testing-and-using-http-2/" target="_blank" rel="noopener">Tools for debugging, testing and using HTTP/2</a></p>
<p>我就是用這麼原始的方式才知道錯在什麼環節</p>
<pre lang="text">
$ curl -vso /dev/null --http2 https://www.cloudflare.com/ 2 >> 1.txt
$ curl -vso /dev/null --http2 https://www.yourwebsite.com/ 2 >> 2.txt
$ vimdiff 1.txt 2.txt
</pre>
<p>我是看到這一篇才想到沒有 Load mod_http2 module<br />
<a href="https://icing.github.io/mod_h2/howto.html" target="_blank" rel="noopener">how to h2 in apache </a></p>
<p>最後再到這個網站確認有沒有成功<br />
<a href="https://tools.keycdn.com/http2-test" target="_blank" rel="noopener">HTTP/2 Test Verify HTTP/2.0 Support</a><br />
<a href="https://richliu.com/wp-content/uploads/2016/10/擷取.png"><img decoding="async" src="https://richliu.com/wp-content/uploads/2016/10/擷取-300x114.png" alt="HTT2 測試" width="300" height="114" class="aligncenter size-medium wp-image-2027" srcset="https://richliu.com/wp-content/uploads/2016/10/擷取-300x114.png 300w, https://richliu.com/wp-content/uploads/2016/10/擷取-768x292.png 768w, https://richliu.com/wp-content/uploads/2016/10/擷取-1024x390.png 1024w, https://richliu.com/wp-content/uploads/2016/10/擷取.png 1471w" sizes="(max-width: 300px) 100vw, 300px" /></a></p>
<p>雖然沒有加快多少, 至少本小站也是支援 HTTP/2 了. </p>
<p>The post <a rel="nofollow" href="https://richliu.com/2016/10/17/2026/gentoo-%e6%9b%bf-apache-%e5%8a%a0%e4%b8%8a-http2-%e6%94%af%e6%8f%b4/">[Gentoo] 替 Apache 加上 http2 支援</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://richliu.com/2016/10/17/2026/gentoo-%e6%9b%bf-apache-%e5%8a%a0%e4%b8%8a-http2-%e6%94%af%e6%8f%b4/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>[Gentoo] Letsencrypt</title>
		<link>https://richliu.com/2015/12/23/1906/gentoo-letsencrypt/</link>
					<comments>https://richliu.com/2015/12/23/1906/gentoo-letsencrypt/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Wed, 23 Dec 2015 06:37:40 +0000</pubDate>
				<category><![CDATA[Blog/wiki]]></category>
		<category><![CDATA[Gentoo]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[certbot]]></category>
		<category><![CDATA[letencrype]]></category>
		<category><![CDATA[ssl]]></category>
		<guid isPermaLink="false">https://richliu.com/?p=1906</guid>

					<description><![CDATA[<p>大家都知道 Let&#8217;s Encrypt 最近提供了三個月的免費 SSL 證書, 加上 Google [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://richliu.com/2015/12/23/1906/gentoo-letsencrypt/">[Gentoo] Letsencrypt</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>大家都知道 <a href="https://letsencrypt.org/" target="_blank" rel="noopener">Let&#8217;s Encrypt </a>最近提供了三個月的免費 SSL 證書, 加上 Google 要調高 HTTPS 的網站權重.<br />
雖然本小站人少流量少, 不過還是不免俗的升級一下 HTTPS.</p>
<p><span id="more-1906"></span></p>
<p>不過我們用的是 Gentoo, 和其他主流的 Linux Distribution 不太一樣, 所以會有些麻煩.<br />
1. 首先加入 <a href="http://gpo.zugaina.org/" target="_blank" rel="noopener">zugaina </a>的 Portage</p>
<p style="padding-left: 30px;">$layman -a zugaina</p>
<p>2. 修改設定檔</p>
<p style="padding-left: 30px;">在 /etc/portage/package.keywords 加上<br />
app-crypt/acme **<br />
www-apache/mod_h2 ~*</p>
<p style="padding-left: 30px;">在/etc/portage/package.unmask 加上<br />
www-apache/mod_h2</p>
<p style="padding-left: 30px;">然後 安裝 letsencrypt<br />
$ emerge letsencrypt</p>
<p>3. 產生證書</p>
<pre lang="bash"> $ letsencrypt certonly --manual --agree-tos -m name@domain.org -d domain.org</pre>
<p style="padding-left: 30px;">會在 /etc/letsencrypt/live/domain.org 下產生所需要的 KEY</p>
<p>4. 修改 apache 的設定, 替網站加上 https</p>
<p style="padding-left: 30px;">有碰到連線問題, 所以我就加上一些參數讓瀏覽器可以支援, 這邊是我用的設定</p>
<blockquote>
<p style="padding-left: 30px;">&lt;VirtualHost *:443&gt;<br />
ServerName domain.org<br />
DocumentRoot &#8220;/var/www/domain.org&#8221;<br />
&lt;Directory &#8220;/var/www/domain.org&#8221;&gt;<br />
AllowOverride All<br />
Require all granted<br />
&lt;/Directory&gt;<br />
SSLEngine on<br />
SSLCertificateFile  /etc/letsencrypt/live/domain.org/cert.pem<br />
SSLCertificateKeyFile /etc/letsencrypt/live/domain.org/privkey.pem<br />
SSLCertificateChainFile /etc/letsencrypt/live/domain.org/fullchain.pem</p>
<p style="padding-left: 30px;">SSLCipherSuite ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!3DES:!MD5:!PSK<br />
SSLProtocol All -SSLv2 -SSLv3</p>
<p style="padding-left: 30px;">&lt;/VirtualHost&gt;</p>
</blockquote>
<p>&nbsp;</p>
<p>4. 剛好清理一下 HTTP 網站的 Link, 移除死掉的 Link , http 改成 https</p>
<p>5. 如果是 wordpress,<br />
網站 URL 要改成 https , 順便可以加上 <a href="https://wordpress.org/plugins/https-redirection/" target="_blank" rel="noopener">Easy HTTPS Redirection </a>這個套件, 會產生新的 .htaccess 檔案, 重定位所有的連結變 https. 這樣就不會出現黃色方塊了.</p>
<p>6. 建議 60 天要更新一下證書.</p>
<p>我是放在 /etc/cron.monthly/ 下</p>
<pre lang=bash>#!/bin/sh
/etc/init.d/apache stop

letsencrypt certonly -a standalone --renew-by-default --agree-tos -d domain.org --email user@domain.org

/etc/init.d/apache start</pre>
<p>新版的改用 certbot</p>
<pre lang=bash>#!/bin/sh
/etc/init.d/apache stop

certbot certonly -a standalone --renew-by-default --agree-tos -d domain.org --email user@domain.org

/etc/init.d/apache start</pre>
<p>ref.<br />
<a href="https://www.apachelounge.com/viewtopic.php?t=6808" target="_blank" rel="noopener">mod_http2 Chrome ERR_SPDY_INADEQUATE_TRANSPORT_SECURITY</a></p>
<p><a href="http://blog.woralelandia.com/2015/12/11/howto-generate-free-ssl-certificates-for-nginxtengine-with-letsencrypt/" target="_blank" rel="noopener">HowTo: Generate free SSL certificates for Nginx/Tengine with LetsEncrypt </a></p>
<p><a href="http://blog.twkang.net/2015/12/07/lets-encrypt-for-your-host/" target="_blank" rel="noopener">Let’s Encrypt 免費讓你的網站升級成 SSL ready</a></p>
<p>The post <a rel="nofollow" href="https://richliu.com/2015/12/23/1906/gentoo-letsencrypt/">[Gentoo] Letsencrypt</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://richliu.com/2015/12/23/1906/gentoo-letsencrypt/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Gentoo Apache 2.4.3 升級後的怪問題.</title>
		<link>https://richliu.com/2012/11/06/1345/gentoo-apache-2-4-3-%e5%8d%87%e7%b4%9a%e5%be%8c%e7%9a%84%e6%80%aa%e5%95%8f%e9%a1%8c/</link>
					<comments>https://richliu.com/2012/11/06/1345/gentoo-apache-2-4-3-%e5%8d%87%e7%b4%9a%e5%be%8c%e7%9a%84%e6%80%aa%e5%95%8f%e9%a1%8c/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Mon, 05 Nov 2012 16:37:05 +0000</pubDate>
				<category><![CDATA[Gentoo]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[問題]]></category>
		<guid isPermaLink="false">https://richliu.com/?p=1345</guid>

					<description><![CDATA[<p>如果出現 &#8220;Invalid command &#8216;User&#8217;, perhaps [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://richliu.com/2012/11/06/1345/gentoo-apache-2-4-3-%e5%8d%87%e7%b4%9a%e5%be%8c%e7%9a%84%e6%80%aa%e5%95%8f%e9%a1%8c/">Gentoo Apache 2.4.3 升級後的怪問題.</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>如果出現<br />
&#8220;Invalid command &#8216;User&#8217;, perhaps misspelled or defined by a module not included in the server configuration&#8221; ..<br />
或是<br />
&#8220;Invalid command &#8216;Require&#8217;, perhaps misspelled or defined by a module not included in the server configuration&#8221; ..</p>
<p>記得在 /etc/make.conf 內的 APACHE2_MODULES= 加上<br />
[TEXT]<br />
unixd access_compat authn_alias authn_core authz_core socache_shmcb<br />
[/TEXT]<br />
P.S 我一次全加了, 免得麻煩.<br />
apache 網站的說明是說 Require 是用到 access_compat , 實際上還是要將 authz_core 和 authn_core 加入</p>
<p>如果網站有 access denied 的狀況, 要將設定稍改一下<br />
[TEXT]<br />
        #       Order allow,deny<br />
        #       Allow from all<br />
                Require all granted<br />
[/TEXT]<br />
舊的 Order 和 Allow 改用 Require command .<br />
大概是這樣. </p>
<p>The post <a rel="nofollow" href="https://richliu.com/2012/11/06/1345/gentoo-apache-2-4-3-%e5%8d%87%e7%b4%9a%e5%be%8c%e7%9a%84%e6%80%aa%e5%95%8f%e9%a1%8c/">Gentoo Apache 2.4.3 升級後的怪問題.</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://richliu.com/2012/11/06/1345/gentoo-apache-2-4-3-%e5%8d%87%e7%b4%9a%e5%be%8c%e7%9a%84%e6%80%aa%e5%95%8f%e9%a1%8c/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>[Gentoo] Apache 2.2 升級到 Apache 2.4 的問題.</title>
		<link>https://richliu.com/2012/04/28/1209/gentoo-%e5%8d%87%e7%b4%9a%e5%88%b0-apache-2-4-%e7%9a%84%e5%95%8f%e9%a1%8c/</link>
					<comments>https://richliu.com/2012/04/28/1209/gentoo-%e5%8d%87%e7%b4%9a%e5%88%b0-apache-2-4-%e7%9a%84%e5%95%8f%e9%a1%8c/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Sat, 28 Apr 2012 10:28:02 +0000</pubDate>
				<category><![CDATA[Gentoo]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[apache2]]></category>
		<category><![CDATA[apache2.4]]></category>
		<category><![CDATA[upgrade]]></category>
		<category><![CDATA[升級]]></category>
		<guid isPermaLink="false">https://richliu.com/?p=1209</guid>

					<description><![CDATA[<p>除了要在 &#8220;/etc/portage/package.unmask&#8221; 加上 [TEXT [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://richliu.com/2012/04/28/1209/gentoo-%e5%8d%87%e7%b4%9a%e5%88%b0-apache-2-4-%e7%9a%84%e5%95%8f%e9%a1%8c/">[Gentoo] Apache 2.2 升級到 Apache 2.4 的問題.</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>除了要在 &#8220;/etc/portage/package.unmask&#8221; 加上<br />
[TEXT]<br />
www-servers/apache<br />
app-admin/apache-tools<br />
[/TEXT]</p>
<p>以便升級以外..<br />
<span id="more-1209"></span></p>
<p>另外, 在 /etc/apache2/httpd.conf<br />
加上<br />
[TEXT]<br />
LoadModule authn_core_module modules/mod_authn_core.so<br />
LoadModule authz_core_module modules/mod_authz_core.so<br />
LoadModule unixd_module modules/mod_unixd.so<br />
LoadModule access_compat_module modules/mod_access_compat.so<br />
LoadModule socache_shmcb_module modules/mod_socache_shmcb.so<br />
[/TEXT]</p>
<p>從檔案 /etc/apache2/vhosts.d/00_default_vhost.conf 內移除<br />
[TEXT]<br />
# Use name-based virtual hosting.<br />
NameVirtualHost *:80<br />
[/TEXT]</p>
<p>從檔案 /etc/apache2/modules.d/00_mod_mime.conf 內移除<br />
[TEXT]<br />
# DefaultType: the default MIME type the server will use for a document<br />
# if it cannot otherwise determine one, such as from filename extensions.<br />
# If your server contains mostly text or HTML documents, &#8220;text/plain&#8221; is<br />
# a good value.  If most of your content is binary, such as applications<br />
# or images, you may want to use &#8220;application/octet-stream&#8221; instead to<br />
# keep browsers from trying to display binary files as though they are<br />
# text.<br />
DefaultType text/plain<br />
[/TEXT]</p>
<p>修改檔案, /etc/apache2/modules.d/40_mod_ssl.conf<br />
[TEXT]<br />
#SSLMutex  file:/var/run/ssl_mutex<br />
Mutex sysvsem default<br />
[/TEXT]</p>
<p>Ref <a href="https://bugs.gentoo.org/show_bug.cgi?id=410607" target="_blank" rel="noopener">Bug 410607</a></p>
<p>The post <a rel="nofollow" href="https://richliu.com/2012/04/28/1209/gentoo-%e5%8d%87%e7%b4%9a%e5%88%b0-apache-2-4-%e7%9a%84%e5%95%8f%e9%a1%8c/">[Gentoo] Apache 2.2 升級到 Apache 2.4 的問題.</a> appeared first on <a rel="nofollow" href="https://richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://richliu.com/2012/04/28/1209/gentoo-%e5%8d%87%e7%b4%9a%e5%88%b0-apache-2-4-%e7%9a%84%e5%95%8f%e9%a1%8c/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
