<?xml version="1.0" encoding="UTF-8" standalone="no"?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" version="2.0">

<channel>
	<title>電腦茶包 Blog</title>
	<atom:link href="https://www.minitw.com/feed/" rel="self" type="application/rss+xml"/>
	<link>https://www.minitw.com/</link>
	<description>解決資訊問題分享，電腦隨手筆記，RouterOS、ASP.NET、電腦資訊分享</description>
	<lastBuildDate>Fri, 19 Nov 2021 04:18:29 +0000</lastBuildDate>
	<language>zh-TW</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.5</generator>
	<itunes:explicit>no</itunes:explicit><itunes:subtitle>解決資訊問題分享、電腦隨手筆記、RouterOS心得筆記、.Net 程式設計分享</itunes:subtitle><item>
		<title>移除登入Proxmox時，跳出的 “No Valid Subscription” 訊息</title>
		<link>https://www.minitw.com/post/2018/12/19/remove-proxmox-no-valid-subscription/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=remove-proxmox-no-valid-subscription</link>
					<comments>https://www.minitw.com/post/2018/12/19/remove-proxmox-no-valid-subscription/#respond</comments>
		
		<dc:creator><![CDATA[jason]]></dc:creator>
		<pubDate>Wed, 19 Dec 2018 07:37:11 +0000</pubDate>
				<category><![CDATA[Proxmox]]></category>
		<guid isPermaLink="false">https://testblog.minitw.com/?p=1545</guid>

					<description><![CDATA[<p>登入Proxmox後，進入命令列。 輸入以下指令，一行搞定。 執行完後，登出再登&#8230;</p>
<p><a href="https://www.minitw.com/post/2018/12/19/remove-proxmox-no-valid-subscription/" class="btn-more">Read More<span class="arrow-more">&#8594;</span></a></p>
<p>這篇文章 <a href="https://www.minitw.com/post/2018/12/19/remove-proxmox-no-valid-subscription/">移除登入Proxmox時，跳出的 &#8220;No Valid Subscription&#8221; 訊息</a> 最早出現於 <a href="https://www.minitw.com">電腦茶包</a>。</p>
]]></description>
										<content:encoded><![CDATA[
<p>登入Proxmox後，進入命令列。</p>



<p>輸入以下指令，一行搞定。</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
wget -q -O - 'https://gist.github.com/tavinus/08a63e7269e0f70d27b8fb86db596f0d/raw/' | /bin/sh

</pre></div>


<p>執行完後，登出再登入，應該就不會出現&#8221;No Valid Subscription&#8221; 的訊息了。</p>



<p>以上測試，Proxmox 5.3版也適用。</p>
<p>這篇文章 <a href="https://www.minitw.com/post/2018/12/19/remove-proxmox-no-valid-subscription/">移除登入Proxmox時，跳出的 &#8220;No Valid Subscription&#8221; 訊息</a> 最早出現於 <a href="https://www.minitw.com">電腦茶包</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.minitw.com/post/2018/12/19/remove-proxmox-no-valid-subscription/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>RouterOS 動態更新IP到 Namecheap</title>
		<link>https://www.minitw.com/post/2018/05/09/routeros-ddns-namecheap/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=routeros-ddns-namecheap</link>
					<comments>https://www.minitw.com/post/2018/05/09/routeros-ddns-namecheap/#respond</comments>
		
		<dc:creator><![CDATA[jason]]></dc:creator>
		<pubDate>Wed, 09 May 2018 02:49:57 +0000</pubDate>
				<category><![CDATA[RouterOS]]></category>
		<category><![CDATA[DDNS]]></category>
		<guid isPermaLink="false">http://testblog.minitw.com/?p=1539</guid>

					<description><![CDATA[<p>之前用的好好的DDNS動態更新ChangeIP與No-IP，為什麼要換到Name&#8230;</p>
<p><a href="https://www.minitw.com/post/2018/05/09/routeros-ddns-namecheap/" class="btn-more">Read More<span class="arrow-more">&#8594;</span></a></p>
<p>這篇文章 <a href="https://www.minitw.com/post/2018/05/09/routeros-ddns-namecheap/">RouterOS 動態更新IP到 Namecheap</a> 最早出現於 <a href="https://www.minitw.com">電腦茶包</a>。</p>
]]></description>
										<content:encoded><![CDATA[
<p>之前用的好好的DDNS動態更新ChangeIP與No-IP，為什麼要換到Namecheap呢?</p>



<p>轉換DNS代管的過程大約半天內可以搞定，這又是另一個故事了，之後有時間再寫。</p>



<p>先把要換的重點列出來。</p>



<span id="more-1539"></span>



<p></p>



<ul class="wp-block-list"><li>GoDaddy DNS域名續約很貴</li><li>ChangeIP與No-IP免費版的，都有數量上的限制，年費也不便宜</li><li>Namecheap提供無限數量的DDNS，而且也可以綁定自己的域名</li></ul>



<figure class="wp-block-image size-large"><img decoding="async" src="https://testblog.minitw.com/wp-content/uploads/2020/11/image-1024x560.png" alt="" class="wp-image-1542"/></figure>



<p>換到Namecheap當然RouterOS的script也要調整，以下程式供需要的人參考</p>



<p></p>



<p class="has-black-color has-pale-pink-background-color has-text-color has-background">2021/11/19 更新script，把原本http的方式改成https。不知道是不是namecheap把http拿掉了，一直403</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: ros; title: ; notranslate">
#Script在#Script在RouterOS 6.42.1中測試通過
#Date:2018/05/07
#Script Name:namecheap DDNS Update

:local ddnsserver &quot;dynamicdns.park-your-domain.com&quot;
:local ddnspass &quot;你的密碼&quot;
:local ddnshostname &quot;於Namecheap中的ddnshostname。例：test&quot;
:local ddnsdomain &quot;於Namecheap中的ddnsdomin。例：ddns.yourdomain.com&quot;
:local ddnscomment &quot;要更新的PPPoE撥接實體註解說明內容。例：Router_ADSL-1_RouterOS&quot;
#一定要先宣告，不然後面程式無法使用
:global ddnslastipADSL1
:global ddnsipADSL1 &#x5B; /ip address get &#x5B;/ip address find interface=&#x5B;/interface get &#x5B;/interface find comment=$ddnscomment] name]] address ]
#舊的IP有存在就用舊的，不存在就建0.0.0.0/0
:if (&#x5B;:typeof &#x5B;:global ddnslastipADSL1]] = nil ) do={ :global ddnslastipADSL1 0.0.0.0/0 } else={ :set ddnslastipADSL1 $ddnslastipADSL1 }
:if (&#x5B;:typeof &#x5B;:global ddnsipADSL1]] = nil ) do={
  :log info (&quot;DDNS: No ip address present on &quot; . $ddnscomment . &quot;, please check.&quot;)
} else={
  :if ($ddnsipADSL1 != $ddnslastipADSL1) do={
    :log info &quot;DDNS: Update DDNS! (CHT:開始更新 $ddnscomment)&quot;
    :local ipFormat &#x5B;:pick $ddnsipADSL1 0 &#x5B;:find $ddnsipADSL1 &quot;/&quot;]];
    :log info (&#x5B;/tool fetch url=&quot;https://dynamicdns.park-your-domain.com/update\?host=$ddnshostname&amp;domain=$ddnsdomain&amp;password=$ddnspass&amp;ip=$ipFormat&quot; mode=https dst-path=(&quot;/DDNS-&quot;.$ddnshostname)] . &quot;CHT:更新IP：&quot; . $ddnsipADSL1)
    :log info ($ddnshostname . &quot;.&quot; . $ddnsdomain &quot;  更新回傳值--&gt;&quot; . &#x5B;/file get &quot;DDNS-$ddnshostname&quot; contents])
    :global ddnslastipADSL1 $ddnsipADSL1
  } else={

  }
}

</pre></div>


<p>參考資料：<a href="https://wiki.mikrotik.com/wiki/Dynamic_DNS_Update_Script_for_Namecheap" target="_blank" rel="noreferrer noopener">Dynamic DNS Update Script for Namecheap</a></p>
<p>這篇文章 <a href="https://www.minitw.com/post/2018/05/09/routeros-ddns-namecheap/">RouterOS 動態更新IP到 Namecheap</a> 最早出現於 <a href="https://www.minitw.com">電腦茶包</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.minitw.com/post/2018/05/09/routeros-ddns-namecheap/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>於 Windows 下安裝 OpenCC</title>
		<link>https://www.minitw.com/post/2015/05/19/install-opencc-under-windows/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=install-opencc-under-windows</link>
					<comments>https://www.minitw.com/post/2015/05/19/install-opencc-under-windows/#respond</comments>
		
		<dc:creator><![CDATA[jason]]></dc:creator>
		<pubDate>Tue, 19 May 2015 03:51:59 +0000</pubDate>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[程式設計]]></category>
		<category><![CDATA[opencc]]></category>
		<guid isPermaLink="false">http://www.minitw.com/?p=1514</guid>

					<description><![CDATA[<p>什麼是OpenCC? 請到這查看。<br />
當你很開心的使用以下指令，你就會踢到一個很痛的鐵版。<br />
C:\>pip install opencc-python<br />
然後Python就會跟你抱怨下面的事，</p>
<p>這篇文章 <a href="https://www.minitw.com/post/2015/05/19/install-opencc-under-windows/">於 Windows 下安裝 OpenCC</a> 最早出現於 <a href="https://www.minitw.com">電腦茶包</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p>不是OpenCV，別看錯了。</p>
<p>什麼是OpenCC? <a href="https://github.com/BYVoid/OpenCC" target="_blank" rel="noopener noreferrer">請到這查看</a></p>
<p>當你很開心的使用以下指令，你就會踢到一個很痛的鐵版。</p>
<div>
<div id="highlighter_88346" class="syntaxhighlighter  bat">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td class="gutter">
<div class="line number1 index0 alt2">1</div>
</td>
<td class="code">
<div class="container">
<div class="line number1 index0 alt2"><code class="bat plain">C:\&gt;pip install opencc-python</code></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>然後Python就會跟你抱怨下面的事，</p>
<p><span id="more-1514"></span></p>
<p>Downloading/unpacking opencc-python<br />
Running setup.py (path:c:\users\xxxx\appdata\local\temp\pip_build_xxxx\opencc-python\setup.py) egg_info for package opencc-python<br />
Traceback (most recent call last):<br />
File &#8220;&lt;string&gt;&#8221;, line 17, in &lt;module&gt;<br />
File &#8220;c:\users\jason\appdata\local\temp\pip_build_xxxx\opencc-python\setup.py&#8221;, line 1, in &lt;module&gt;<br />
from distribute_setup import use_setuptools<br />
ImportError: No module named distribute_setup<br />
Complete output from command python setup.py egg_info:<br />
Traceback (most recent call last):</p>
<p>File &#8220;&lt;string&gt;&#8221;, line 17, in &lt;module&gt;</p>
<p>File &#8220;c:\users\jason\appdata\local\temp\pip_build_xxxx\opencc-python\setup.py&#8221;, line 1, in &lt;module&gt;</p>
<p>from distribute_setup import use_setuptools</p>
<p>ImportError: No module named distribute_setup</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
Cleaning up&#8230;<br />
Command python setup.py egg_info failed with error code 1 in c:\users\xxxx\appdata\local\temp\pip_build_xxxx\opencc-python<br />
Storing debug log for failure in C:\Users\Jason\pip\pip.log</p>
<p>解法：</p>
<p>下載<a href="http://www.minitw.com/download/distribute_setup.zip" target="_blank" rel="noopener noreferrer"> distribute_setup.zip</a></p>
<p>解壓縮後，把distribute_setup.py放到C:\你安裝Python的目錄\Lib(例如：C:\Python27\Lib)</p>
<p>再執行一次</p>
<div>
<div id="highlighter_797880" class="syntaxhighlighter  bat">
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td class="gutter">
<div class="line number1 index0 alt2">1</div>
</td>
<td class="code">
<div class="container">
<div class="line number1 index0 alt2"><code class="bat plain">C:\&gt;pip install opencc-python</code></div>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<p>Downloading/unpacking opencc-python<br />
Running setup.py (path:c:\users\xxxx\appdata\local\temp\pip_build_xxxx\opencc-python\setup.py) egg_info for package opencc-python<br />
Downloading http://pypi.python.org/packages/source/d/distribute/distribute-0.6.27.tar.gz<br />
Extracting in c:\users\xxxx\appdata\local\temp\tmpeuwfpm<br />
Now working in c:\users\xxxx\appdata\local\temp\tmpeuwfpm\distribute-0.6.27<br />
Building a Distribute egg in c:\users\xxxx\appdata\local\temp\pip_build_xxxx\opencc-python<br />
c:\users\xxxx\appdata\local\temp\pip_build_xxxx\opencc-python\distribute-0.6.27-py2.7.egg</p>
<p>Requirement already satisfied (use &#8211;upgrade to upgrade): distribute in c:\python27_x64\lib\site-packages (from opencc-python)<br />
Requirement already satisfied (use &#8211;upgrade to upgrade): setuptools&gt;=0.7 in c:\<br />
python27_x64\lib\site-packages (from distribute-&gt;opencc-python)<br />
Installing collected packages: opencc-python<br />
Running setup.py install for opencc-python</p>
<p>Successfully installed opencc-python<br />
Cleaning up&#8230;</p>
<p>順利完成安裝</p>
<p>這篇文章 <a href="https://www.minitw.com/post/2015/05/19/install-opencc-under-windows/">於 Windows 下安裝 OpenCC</a> 最早出現於 <a href="https://www.minitw.com">電腦茶包</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.minitw.com/post/2015/05/19/install-opencc-under-windows/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>自動清空/刪除 Google Drive 的垃圾桶</title>
		<link>https://www.minitw.com/post/2015/03/16/auto-clean-delete-google-drive-trashcan/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=auto-clean-delete-google-drive-trashcan</link>
					<comments>https://www.minitw.com/post/2015/03/16/auto-clean-delete-google-drive-trashcan/#comments</comments>
		
		<dc:creator><![CDATA[jason]]></dc:creator>
		<pubDate>Mon, 16 Mar 2015 02:54:47 +0000</pubDate>
				<category><![CDATA[程式設計]]></category>
		<category><![CDATA[網路技術]]></category>
		<category><![CDATA[軟體技術]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Google Drive]]></category>
		<category><![CDATA[Script]]></category>
		<guid isPermaLink="false">http://www.minitw.com/?p=1476</guid>

					<description><![CDATA[<p>在Google Drive中，如果你對檔案按下刪除，當下檔案只會搬移到垃圾桶，並不會真的刪除。</p>
<p>而在垃圾桶內的檔案，若沒有人工去手動清空，那麼垃圾桶內的檔案將會一直存在，仍然會持續的佔用空間。</p>
<p>這就是為什麼很多人說，我明明把Google Drive內的檔案刪了，但是為什麼可用的空間仍然沒有變多。</p>
<p>如果你想定時把Google Drive垃圾桶自動清空的話，就照此篇文章執行吧。</p>
<p>這篇文章 <a href="https://www.minitw.com/post/2015/03/16/auto-clean-delete-google-drive-trashcan/">自動清空/刪除 Google Drive 的垃圾桶</a> 最早出現於 <a href="https://www.minitw.com">電腦茶包</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p>在Google Drive中，如果你對檔案按下刪除，當下檔案只會搬移到垃圾桶，並不會真的刪除。</p>
<p>而<span style="color: #ff0000;">在垃圾桶內的檔案，若沒有清空，那麼垃圾桶內的檔案將會一直存在，仍然會持續的佔用空間</span>。</p>
<p>這就是為什麼很多人說，我明明把Google Drive內的檔案刪了，但是為什麼可用的空間仍然沒有變多。</p>
<p>如果你想定時把Google Drive垃圾桶自動清空的話，就照此篇文章執行吧。</p>
<p><span id="more-1476"></span></p>
<p><strong>1.先申請API Key</strong></p>
<p>到https://console.developers.google.com/，登入後先建立一個新的專案。</p>
<p>接下來進入剛剛建立的專案，在「API和驗證」-&gt;「憑證」-&gt;「公開API存取」中，點選「建立新的金鑰」</p>
<p>此時，請把產生的「API 金鑰」記下來。</p>
<p><strong>2.建立Script</strong></p>
<p>到https://script.google.com，登入後先建立一個空白專案。</p>
<p>把以下程式碼貼上</p>
<pre class="brush: js;">
function doGet() {
    try {
        authorize();
        var key = &quot;Your API Key，放你剛剛記下來的API Key&quot;;
        var params = {
            method: &quot;DELETE&quot;,
            oAuthServiceName: &quot;drive&quot;,
            oAuthUseToken: &quot;always&quot;
        };
        UrlFetchApp.fetch(&quot;https://www.googleapis.com/drive/v2/files/trash?key=&quot; + key, params);
    }
    catch (error) {
        MailApp.sendEmail(&quot;yourEmailAddress@gmail.com&quot;, &quot;EMPTY TRASH BIN ERROR&quot;, &quot;EMPTY TRASH BIN ERROR:&lt;br&gt;&quot; + error);
        return;
    }
}

function authorize() {
    var oauthConfig = UrlFetchApp.addOAuthService(&quot;drive&quot;);
    var scope = &quot;https://www.googleapis.com/auth/drive&quot;;
    oauthConfig.setConsumerKey(&quot;anonymous&quot;);
    oauthConfig.setConsumerSecret(&quot;anonymous&quot;);
    oauthConfig.setRequestTokenUrl(&quot;https://www.google.com/accounts/OAuthGetRequestToken?scope=&quot; + scope);
    oauthConfig.setAuthorizationUrl(&quot;https://accounts.google.com/OAuthAuthorizeToken&quot;);
    oauthConfig.setAccessTokenUrl(&quot;https://www.google.com/accounts/OAuthGetAccessToken&quot;);
}
</pre>
<p>接下來請儲存程式(編輯介面中的檔案 -&gt; 存儲)。</p>
<p>儲存完後，請把執行函式選到doGet，並執行(或是點選 -&gt; 執行 -&gt; doGet)。</p>
<p>第一次執行，會請你進行google帳號的授權，請同意授權，並執行(<span style="color: #ff0000;">此時你垃圾桶內的資料將會清空，請注意</span>)。</p>
<p>&nbsp;</p>
<p><strong>3.最後把該程式建立排程就可以了</strong></p>
<p>在「資源」 -&gt; 「有專案的啟動程序」 -&gt; 點一下「尚未建立觸發程序，按一下這裡來新增觸發程序」</p>
<p>執行「doGet」，時間就看自己要多久自動清一次垃圾桶，我自己是設定每星期執行一次。</p>
<p>到這邊就完成了。恭喜你，你的垃圾桶會自動清空了!!!</p>
<p>這篇文章 <a href="https://www.minitw.com/post/2015/03/16/auto-clean-delete-google-drive-trashcan/">自動清空/刪除 Google Drive 的垃圾桶</a> 最早出現於 <a href="https://www.minitw.com">電腦茶包</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.minitw.com/post/2015/03/16/auto-clean-delete-google-drive-trashcan/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
		<item>
		<title>於 MySQL / MariaDB 中啟用 SQL Query Log</title>
		<link>https://www.minitw.com/post/2015/03/13/enabling-sql-query-log-in-mysql-or-mariadb/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=enabling-sql-query-log-in-mysql-or-mariadb</link>
					<comments>https://www.minitw.com/post/2015/03/13/enabling-sql-query-log-in-mysql-or-mariadb/#respond</comments>
		
		<dc:creator><![CDATA[jason]]></dc:creator>
		<pubDate>Fri, 13 Mar 2015 08:14:18 +0000</pubDate>
				<category><![CDATA[程式設計]]></category>
		<category><![CDATA[MariaDB]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[ORM]]></category>
		<category><![CDATA[SQL]]></category>
		<guid isPermaLink="false">http://www.minitw.com/?p=1469</guid>

					<description><![CDATA[<p>要知道前端下了什麼SQL到DB，在SQL Server中你可以使用SQL Server Profiler這個工作來達成。</p>
<p>但是在MySQL / MariaDB中目前似乎沒有一個好用的介面可以使用，</p>
<p>Oracle MySQL Enterprise Monitor 應該可以做到，但是授權商業使用的就是要錢，而且還不便宜，</p>
<p>官方定價，要使用Oracle MySQL Enterprise Monitor 最低消費，請付 USD 5000，價格請見 http://www.mysql.com/products/。</p>
<p>這價錢不是一般小公司玩的起的，所以只能先用比較陽春的方法來解決了。</p>
<p>要在 MySQL / MariaDB 中啟用SQL Query Log的功能，有以下2種方法：</p>
<p>把Log寫入檔案。<br />
把Log寫入資料庫中的Table。</p>
<p>這篇文章 <a href="https://www.minitw.com/post/2015/03/13/enabling-sql-query-log-in-mysql-or-mariadb/">於 MySQL / MariaDB 中啟用 SQL Query Log</a> 最早出現於 <a href="https://www.minitw.com">電腦茶包</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p>要知道前端下了什麼SQL到DB，在SQL Server中你可以使用SQL Server Profiler這個工作來達成。</p>
<p>但是在MySQL / MariaDB中目前似乎沒有一個好用的介面可以使用，</p>
<p>Oracle MySQL Enterprise Monitor 應該可以做到，但是授權商業使用的就是要錢，而且還不便宜，</p>
<p>官方定價，要使用Oracle MySQL Enterprise Monitor 最低消費，請付 USD 5000，價格請見 <a title="http://www.mysql.com/products/" href="http://www.mysql.com/products/" target="_blank" rel="noopener noreferrer">http://www.mysql.com/products/</a>。</p>
<p>這價錢不是一般小公司玩的起的，所以只能先用比較陽春的方法來解決了。</p>
<p>要在 MySQL / MariaDB 中啟用SQL Query Log的功能，有以下2種方法：</p>
<ol>
<li>把Log寫入檔案。</li>
<li>把Log寫入資料庫中的Table。</li>
</ol>
<p><span id="more-1469"></span></p>
<p>第1種方法最為簡單，使用編輯器編輯 /etc/mysql/my.cnf 這個檔案。</p>
<p>找到</p>
<pre class="brush: bash;">

#general_log_file = /var/log/mysql/mysql.log
#general_log = 1

</pre>
<p>把註解去掉，變成以下內容，存檔離開。</p>
<pre class="brush: bash;">

general_log_file = /var/log/mysql/mysql.log
general_log = 1

</pre>
<p>然後重新啟動mysql即可，指令為</p>
<pre class="brush: bash;">
/etc/init.d/mysql restart
</pre>
<pre></pre>
<p>然後你就可以到 /var/log/mysql/mysql.log 查看目前的Log了。</p>
<p>&nbsp;</p>
<p>第2種存到Table方法雖然難了一點，但個人比較推薦使用。</p>
<p>一樣使用編輯器編輯 /etc/mysql/my.cnf 這個檔案。</p>
<p>找到</p>
<pre class="brush: bash;">

#general_log_file = /var/log/mysql/mysql.log
#general_log = 1

</pre>
<p>把 general_log 的註解去掉，並加上 log-output=TABLE</p>
<p>變成以下內容，存檔離開。</p>
<pre class="brush: bash;">

#general_log_file = /var/log/mysql/mysql.log
general_log = 1
log-output=TABLE

</pre>
<p>然後重新啟動mysql即可，指令為</p>
<pre class="brush: bash;">
/etc/init.d/mysql restart
</pre>
<p>這時候就可以到資料庫：mysql 中的 Table：general_log 查看 Log 資料了。</p>
<pre class="brush: sql;">

SELECT * FROM `mysql`.`general_log` ORDER BY event_time DESC LIMIT 0, 1000;

</pre>
<p>但是為了以防資料庫的Log無限制的增長，所以另外加了一個定時清Log的Event機制。</p>
<p>每天進行刪除Log，只保留24小時內的Log資料。</p>
<pre class="brush: sql;">

DELIMITER $$

CREATE EVENT `mysql`.`prune_general_log`

ON SCHEDULE
EVERY 1 DAY STARTS '2015-03-13'
ON COMPLETION NOT PRESERVE
ENABLE
COMMENT 'This will trim the general_log table to contain only the past 24 hours of logs.'

DO
BEGIN
SET GLOBAL general_log = 'OFF';
RENAME TABLE mysql.general_log TO mysql.general_log2;
DELETE FROM mysql.general_log2 WHERE event_time &lt;= NOW()-INTERVAL 24 HOUR;
OPTIMIZE TABLE general_log2;
RENAME TABLE mysql.general_log2 TO mysql.general_log;
SET GLOBAL general_log = 'ON';
END$$

DELIMITER ;

</pre>
<p>這樣子基本上，對於寫程式的Debug就可以滿足了，<span style="color: #ff0000;"><del>尤其在得了「寫程式沒有ORM就會死」的病後</del></span>，</p>
<p>在Debug時如何得知ORM下了什麼SQL指令到資料庫，變成非常重要的一件事。</p>
<p>這篇文章 <a href="https://www.minitw.com/post/2015/03/13/enabling-sql-query-log-in-mysql-or-mariadb/">於 MySQL / MariaDB 中啟用 SQL Query Log</a> 最早出現於 <a href="https://www.minitw.com">電腦茶包</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.minitw.com/post/2015/03/13/enabling-sql-query-log-in-mysql-or-mariadb/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>修改SQL Server的定序</title>
		<link>https://www.minitw.com/post/2015/02/04/set-or-change-the-sql-server-collation/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=set-or-change-the-sql-server-collation</link>
					<comments>https://www.minitw.com/post/2015/02/04/set-or-change-the-sql-server-collation/#respond</comments>
		
		<dc:creator><![CDATA[jason]]></dc:creator>
		<pubDate>Wed, 04 Feb 2015 03:19:05 +0000</pubDate>
				<category><![CDATA[軟體技術]]></category>
		<category><![CDATA[sql server]]></category>
		<category><![CDATA[定序]]></category>
		<guid isPermaLink="false">http://www.minitw.com//.htm</guid>

					<description><![CDATA[<p>定序(Collation)是什麼?  請參考定序與 Unicode 支援</p>
<p>以下指令的功能是修改SQL Server中的定序為：不區分大小寫(CI)、區分腔調字(AS)、Chinese_Taiwan_Stroke 。</p>
<p>這篇文章 <a href="https://www.minitw.com/post/2015/02/04/set-or-change-the-sql-server-collation/">修改SQL Server的定序</a> 最早出現於 <a href="https://www.minitw.com">電腦茶包</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p>定序(Collation)是什麼?  <a title="定序與 Unicode 支援" href="https://msdn.microsoft.com/zh-tw/library/ms143726.aspx" target="_blank" rel="noopener noreferrer">請參考定序與 Unicode 支援</a></p>
<p>以下指令的功能是修改SQL Server中的定序為：不區分大小寫(CI)、區分腔調字(AS)、Chinese_Taiwan_Stroke 。</p>
<pre class="brush: sql;">
ALTER DATABASE [YOUR_DB_NAME] SET SINGLE_USER WITH ROLLBACK IMMEDIATE
ALTER DATABASE [YOUR_DB_NAME] COLLATE Chinese_Taiwan_Stroke_CI_AS
ALTER DATABASE [YOUR_DB_NAME] SET MULTI_USER WITH ROLLBACK IMMEDIATE
</pre>
<p>這篇文章 <a href="https://www.minitw.com/post/2015/02/04/set-or-change-the-sql-server-collation/">修改SQL Server的定序</a> 最早出現於 <a href="https://www.minitw.com">電腦茶包</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.minitw.com/post/2015/02/04/set-or-change-the-sql-server-collation/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Tenda F306 刷機 Tomato</title>
		<link>https://www.minitw.com/post/2015/01/20/tenda-f306-firmware-tomato/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=tenda-f306-firmware-tomato</link>
					<comments>https://www.minitw.com/post/2015/01/20/tenda-f306-firmware-tomato/#respond</comments>
		
		<dc:creator><![CDATA[jason]]></dc:creator>
		<pubDate>Tue, 20 Jan 2015 10:04:06 +0000</pubDate>
				<category><![CDATA[網路技術]]></category>
		<category><![CDATA[Tomato]]></category>
		<guid isPermaLink="false">http://www.minitw.com/?p=1459</guid>

					<description><![CDATA[<p>買這台，真的只是為了刷機來用Tomato。</p>
<p>ASUS N5X 也都要2000左右，Tenda F306以1000左右的售價，算是CP值很高。</p>
<p>紀錄一下，以免日後忘記~~</p>
<p>下載可用的Tomato Firmware，看樣子是可以跟華碩N5X Tomato Firmware的共用。</p>
<p>這篇文章 <a href="https://www.minitw.com/post/2015/01/20/tenda-f306-firmware-tomato/">Tenda F306 刷機 Tomato</a> 最早出現於 <a href="https://www.minitw.com">電腦茶包</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p>買這台，真的只是為了刷機來用Tomato。</p>
<p>ASUS N5X 也都要2000左右，Tenda F306以1000左右的售價，算是CP值很高。</p>
<p>紀錄一下，以免日後忘記~~</p>
<p>下載可用的Tomato Firmware，看樣子是可以跟華碩N5X Tomato Firmware的共用。</p>
<p><span id="more-1459"></span></p>
<p>官方下載位置，可使用此版本或較新的版本，AIO為完整版：</p>
<p><a href="http://tomato.groov.pl/download/K26RT-N/build5x-124-EN/Asus%20RT-Nxx/tomato-K26USB-1.28.RT-N5x-MIPSR2-124-AIO.trx" target="_blank" rel="noopener noreferrer">http://tomato.groov.pl/download/K26RT-N/build5x-124-EN/Asus%20RT-Nxx/tomato-K26USB-1.28.RT-N5x-MIPSR2-124-AIO.trx</a></p>
<p>或由本站下載(需解壓縮zip檔)：</p>
<p><a href="http://www.minitw.com/download/tomato_firmware/tenda_f306/tomato-K26USB-1.28.RT-N5x-MIPSR2-124-AIO.trx.zip" target="_blank" rel="noopener noreferrer">http://www.minitw.com/download/tomato_firmware/tenda_f306/tomato-K26USB-1.28.RT-N5x-MIPSR2-124-AIO.trx.zip</a></p>
<p>接下來進入F306的管理介面，使用升級的功能，再把trx檔丟進去即可。</p>
<p><span style="color: #ff0000;">注意：升級過程請勿斷線或關機</span>，刷機有風險，變磚請自行處理。</p>
<p>&nbsp;</p>
<p>升級後，使用WIFI連進去(不需帳密，SSID為tomato或tomato24)，連結http://192.168.1.1，即可進到tomato的管理介面。</p>
<p>&nbsp;</p>
<p>這篇文章 <a href="https://www.minitw.com/post/2015/01/20/tenda-f306-firmware-tomato/">Tenda F306 刷機 Tomato</a> 最早出現於 <a href="https://www.minitw.com">電腦茶包</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.minitw.com/post/2015/01/20/tenda-f306-firmware-tomato/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>把EmEditor轉換為便攜版</title>
		<link>https://www.minitw.com/post/2015/01/13/convert-emeditor-to-portable/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=convert-emeditor-to-portable</link>
					<comments>https://www.minitw.com/post/2015/01/13/convert-emeditor-to-portable/#respond</comments>
		
		<dc:creator><![CDATA[jason]]></dc:creator>
		<pubDate>Tue, 13 Jan 2015 14:51:13 +0000</pubDate>
				<category><![CDATA[電腦小技巧]]></category>
		<category><![CDATA[EmEditor]]></category>
		<guid isPermaLink="false">http://www.minitw.com/?p=1457</guid>

					<description><![CDATA[<p>EmEditor是一套強大的「處理大檔案」的處理器，官方號稱可以輕鬆處理 248 GB 大的檔案。</p>
<p>官方網站：https://zh-tw.emeditor.com/</p>
<p>下載後為一般安裝版。</p>
<p>要改為便攜版(Portable)，也很簡單。</p>
<p>EmEditor安裝完成後，於安裝的路徑下(C:\Program Files\EmEditor)，新增一個「eeUseIni.ini」的空白檔案。</p>
<p>然後開啟EmEditor，輸入你所購買的序號，EmEditor會自動在C:\Program Files\EmEditor產生一個加密過的「eeLM.ini」驗證檔。</p>
<p>這樣就完成EmEditor的便攜版。</p>
<p>這篇文章 <a href="https://www.minitw.com/post/2015/01/13/convert-emeditor-to-portable/">把EmEditor轉換為便攜版</a> 最早出現於 <a href="https://www.minitw.com">電腦茶包</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p>EmEditor是一套強大的「處理大檔案」的處理器，官方號稱可以輕鬆處理 248 GB 大的檔案。</p>
<p>官方網站：<a href="https://zh-tw.emeditor.com/" target="_blank" rel="noopener noreferrer">https://zh-tw.emeditor.com/</a></p>
<p>下載後為一般安裝版。</p>
<p>要改為便攜版(Portable)，也很簡單。</p>
<p><span id="more-1457"></span></p>
<p>EmEditor安裝完成後，於安裝的路徑下(C:\Program Files\EmEditor)，新增一個「eeUseIni.ini」的空白檔案。</p>
<p>然後開啟EmEditor，輸入你所購買的序號，EmEditor會自動在C:\Program Files\EmEditor產生一個加密過的「eeLM.ini」驗證檔。</p>
<p>這樣就完成EmEditor的便攜版。</p>
<p>這篇文章 <a href="https://www.minitw.com/post/2015/01/13/convert-emeditor-to-portable/">把EmEditor轉換為便攜版</a> 最早出現於 <a href="https://www.minitw.com">電腦茶包</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.minitw.com/post/2015/01/13/convert-emeditor-to-portable/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>在Ubuntu上Redmine與Git + Grack整合</title>
		<link>https://www.minitw.com/post/2014/08/07/on-ubuntu-using-redmine-integration-with-git-and-grack/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=on-ubuntu-using-redmine-integration-with-git-and-grack</link>
					<comments>https://www.minitw.com/post/2014/08/07/on-ubuntu-using-redmine-integration-with-git-and-grack/#respond</comments>
		
		<dc:creator><![CDATA[jason]]></dc:creator>
		<pubDate>Thu, 07 Aug 2014 08:21:30 +0000</pubDate>
				<category><![CDATA[Redmine]]></category>
		<category><![CDATA[網站架設]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[grack]]></category>
		<category><![CDATA[redmine]]></category>
		<category><![CDATA[ubuntu]]></category>
		<guid isPermaLink="false">http://www.minitw.com//.htm</guid>

					<description><![CDATA[<p>本篇文章是依據 在Microsoft Azure中，手動安裝Redmine for Ubuntu Linux 實作完成後的續集。</p>
<p>會想把Redmine與Git整合起來，是因為這樣子對於專案的進度與程式碼的管控會比較方便。<br />
不然分2邊寫，實在是很困擾，工程師就是不太喜歡這種事。<br />
而因為工作性質的關係，專案也不能放上GitHub，所以就只能自己架設跟整合了。</p>
<p>當Redmine跟Git整合後，隨之而來的就是帳號驗證的問題，<br />
一般有以下幾種方式：<br />
1.完全不驗證，這也太不安全了。<br />
2.使用htpasswd檔案來驗證。缺點是每個人都要再額外開立帳號，如果要改密碼的話會很麻煩。<br />
3.結合LDAP來驗證。目前公司沒有LDAP，所以不討論。<br />
4.使用SSH來存取git。缺點是每個人都要在ubuntu中開立系統帳號，並設定權限，也是很麻煩吶。<br />
5.結合redmine中的帳號密碼來驗證。就是本文使用的方式。</p>
<p>這過程也踢了好幾次鐵板，為了避免自己忘記，也順便造福網友，故有此文章的產生。</p>
<p>話不多說了，直接進入主題吧。</p>
<p>這篇文章 <a href="https://www.minitw.com/post/2014/08/07/on-ubuntu-using-redmine-integration-with-git-and-grack/">在Ubuntu上Redmine與Git + Grack整合</a> 最早出現於 <a href="https://www.minitw.com">電腦茶包</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p>本篇文章是依據 <a title="在Microsoft Azure中，手動安裝Redmine for Ubuntu Linux" href="http://www.minitw.com/server/in-microsoft-azure-manually-installation-redmine-for-ubuntu-linux.htm" target="_blank" rel="noopener noreferrer">在Microsoft Azure中，手動安裝Redmine for Ubuntu Linux</a> 實作完成後的續集。</p>
<p>會想把Redmine與Git整合起來，是因為這樣子對於專案進度與程式碼管控會比較方便。<br />
不然分2邊寫，實在是很困擾，工程師就是不太喜歡這種事。<br />
而因為工作性質的關係，專案也不能放上GitHub，所以就只能自己架設跟整合了。</p>
<p>當Redmine跟Git整合後，隨之而來的就是帳號驗證的問題，<br />
一般有以下幾種方式：<br />
1.完全不驗證，這也太不安全了。<br />
2.使用htpasswd檔案來驗證。缺點是每個人都要再額外開立帳號，如果要改密碼的話會很麻煩。<br />
3.結合LDAP來驗證。目前公司沒有LDAP，所以不討論。<br />
4.使用SSH來存取git。缺點是每個人都要在ubuntu中開立系統帳號，並設定權限，也是很麻煩吶。<br />
5.結合redmine中的帳號密碼來驗證。就是本文使用的方式。</p>
<p>這過程也踢了好幾次鐵板，為了避免自己忘記，也順便造福網友，故有此文章的產生。</p>
<p>話不多說了，直接進入主題吧。</p>
<p>&nbsp;</p>
<p><span id="more-1441"></span></p>
<p>先安裝必要的元件</p>
<pre class="brush: bash;">
sudo apt-get install libapache-dbi-perl libapache2-mod-perl2 git git-core
sudo apt-get install libapache2-reload-perl libapache2-mod-auth-mysql
</pre>
<p>啟用等一下Apache會使用到的組件</p>
<pre class="brush: bash;">
sudo a2enmod auth_mysql
sudo a2enmod dav_fs
</pre>
<p>建立等一下會使用到的git repository資料夾</p>
<pre class="brush: bash;">
sudo mkdir /var/git_repository
sudo mkdir /var/git_repository/test
cd /var/git_repository/test
sudo git init --bare
</pre>
<p>修正git repository資料夾的權限</p>
<pre class="brush: bash;">
sudo chown -R www-data:www-data /var/git_repository/
</pre>
<p>安裝grack，之後把git掛到apache上會用到。</p>
<pre class="brush: bash;">
cd ~
git clone http://github.com/schacon/grack.git
</pre>
<p>設定grack</p>
<pre class="brush: bash;">
sudo vi ~/grack/config.ru
</pre>
<p>********修改你的 :project_root  為你放置 git repository 的位置 ********<br />
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + &#8216;/lib&#8217;)</p>
<p>use Rack::ShowExceptions</p>
<p>require &#8216;grack&#8217;<br />
require &#8216;git_adapter&#8217;</p>
<p>config = {<br />
:project_root =&gt; &#8220;<span style="color: #ff0000;">/var/git_repository</span>&#8220;,<br />
:adapter =&gt; Grack::GitAdapter,<br />
:git_path =&gt; &#8216;/usr/bin/git&#8217;,<br />
:upload_pack =&gt; true,<br />
:receive_pack =&gt; true,<br />
}</p>
<p>run Grack::App.new(config)<br />
*************************</p>
<p>&nbsp;</p>
<p>安裝grack相關的元件</p>
<pre class="brush: bash;">
cd ~/grack/
sudo bundle install
</pre>
<p>建立相關資料夾及修改權限，並設定連結到apache的目錄中</p>
<pre class="brush: bash;">
mkdir ~/grack/public
mkdir ~/grack/tmp
sudo chown -R www-data:www-data ~/grack
sudo ln -s ~/grack/public /var/www/git
</pre>
<p>修改apache的git設定檔</p>
<pre class="brush: bash;">
sudo vi /etc/apache2/sites-available/redmine.conf
</pre>
<p>把以下設定檔加上 redmine.conf 裡面</p>
<pre class="brush: xml;">
#Git + Grack Config--Start
&lt;Directory /var/www/git&gt;
            RailsBaseURI /git
            PassengerResolveSymlinksInDocumentRoot on
&lt;/Directory&gt;

PerlLoadModule Apache::Redmine
&lt;Directory &quot;/var/www/git&quot;&gt;
    Options None
    AllowOverride None
    &lt;IfVersion &lt; 2.3 &gt;
    Order allow,deny
    Allow from all
    &lt;/IfVersion&gt;
    &lt;IfVersion &gt;= 2.3&gt;
    Require all granted
    &lt;/IfVersion&gt;
&lt;/Directory&gt;

&lt;Location &quot;/git&quot;&gt;
    Order allow,deny
    Allow from all

    AuthType Basic
    AuthName &quot;Git repositories&quot;
    Require valid-user
    PerlAccessHandler Apache::Authn::Redmine::access_handler
    PerlAuthenHandler Apache::Authn::Redmine::authen_handler

    ## for mysql
    RedmineDSN &quot;DBI:mysql:database=redmine;host=localhost&quot;
    RedmineDbUser &quot;redmine&quot;
    RedmineDbPass &quot;your password&quot;

&lt;/Location&gt;
#Git + Grack Config--End
</pre>
<p>Copy Redmine.pm 模組到Apache的模組資料夾中</p>
<pre class="brush: bash;">
sudo cp ~/redmineSVN/redmine2.5/extra/svn/Redmine.pm /usr/lib/perl5/Apache
</pre>
<p>調整Redmine.pm</p>
<pre class="brush: bash;">
sudo vi /usr/lib/perl5/Apache/Redmine.pm
</pre>
<p>***********找到下面的字串，修改前<br />
sub RedmineDSN {<br />
my ($self, $parms, $arg) = @_;<br />
$self-&gt;{RedmineDSN} = $arg;<br />
my $query = &#8220;SELECT<br />
users.hashed_password, users.salt, users.auth_source_id, roles.permissions, projects.status<br />
FROM projects, users, roles<br />
WHERE<br />
users.login=?<br />
AND projects.identifier=?<br />
AND users.status=1<br />
..<br />
..<br />
..<br />
***********修改後<br />
sub RedmineDSN {<br />
my ($self, $parms, $arg) = @_;<br />
$self-&gt;{RedmineDSN} = $arg;<br />
my $query = &#8220;SELECT<br />
users.hashed_password, users.salt, users.auth_source_id, roles.permissions, projects.status<br />
FROM projects, users, roles<br />
WHERE<br />
users.login=?<br />
<span style="color: #ff0000;">OR</span> projects.identifier=?<br />
AND users.status=1<br />
..<br />
..<br />
..<br />
**************</p>
<p>這邊這個鐵板，讓我的腳踢的又紅又腫，腳都快斷了。<br />
因為驗證模組會多丟一組projects.identifier去跟redmine的資料庫進行比對驗證。<br />
所以說，<span style="color: #ff0000;">如果你redmine中專案的唯一編碼與git專案資料夾名稱不一樣的話，就會發生驗證不過。</span><br />
解法就是在驗證時，排除projects.identifier。</p>
<p>這個問題足足花了我一整天的時間，最後才找到問題的根源。</p>
<p>&nbsp;</p>
<p>最後就是把apache重新啟動了</p>
<pre class="brush: bash;">
sudo service apache2 restart
</pre>
<p>接下來，你就可以進行測試了，輸入你redmine中的帳號與密碼進行驗證。<br />
成功的話，應該就會顯示目前該專案的相關資訊。</p>
<pre class="brush: bash;">
git ls-remote http://localhost/git/test
</pre>
<p>參考資料：<br />
<a href="http://www.kenming.idv.tw/howto_redmine_integrate_git_and_github" target="_blank" rel="noopener noreferrer">HowTo-Redmine 整合 Git/GitHub</a></p>
<p><a href="http://www.redmine.org/projects/redmine/wiki/HowTo_configure_Redmine_for_advanced_git_integration" target="_blank" rel="noopener noreferrer">HowTo configure Redmine for advanced git integration</a></p>
<p><a href="http://blog.longwin.com.tw/2011/03/redmine-debian-ubuntu-linux-2011/" target="_blank" rel="noopener noreferrer">將 Redmine 安裝於 Debian、Ubuntu Linux</a></p>
<p><a href="http://blog.longwin.com.tw/2012/12/redmine-issue-git-commit-integration-2012/" target="_blank" rel="noopener noreferrer">Redmine issues 與 Git commits 整合</a></p>
<p>這篇文章 <a href="https://www.minitw.com/post/2014/08/07/on-ubuntu-using-redmine-integration-with-git-and-grack/">在Ubuntu上Redmine與Git + Grack整合</a> 最早出現於 <a href="https://www.minitw.com">電腦茶包</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.minitw.com/post/2014/08/07/on-ubuntu-using-redmine-integration-with-git-and-grack/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>在Microsoft Azure中，手動安裝Redmine for Ubuntu Linux</title>
		<link>https://www.minitw.com/post/2014/07/22/in-microsoft-azure-manually-installation-redmine-for-ubuntu-linux/?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=in-microsoft-azure-manually-installation-redmine-for-ubuntu-linux</link>
					<comments>https://www.minitw.com/post/2014/07/22/in-microsoft-azure-manually-installation-redmine-for-ubuntu-linux/#respond</comments>
		
		<dc:creator><![CDATA[jason]]></dc:creator>
		<pubDate>Mon, 21 Jul 2014 16:36:06 +0000</pubDate>
				<category><![CDATA[Redmine]]></category>
		<category><![CDATA[網站架設]]></category>
		<category><![CDATA[Azure]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[redmine]]></category>
		<category><![CDATA[ubuntu]]></category>
		<guid isPermaLink="false">http://www.minitw.com//.htm</guid>

					<description><![CDATA[<p>在Microsoft Azure中，半自動安裝Redmine for Ubuntu Linux這篇文章說，說明了如何用apt來安裝redmine。<br />
然而如果你有使用新版Redmine與升級Redmine的需求，建議使用手動的方式來安裝redmine，即本文要說明的方式。</p>
<p>這篇文章 <a href="https://www.minitw.com/post/2014/07/22/in-microsoft-azure-manually-installation-redmine-for-ubuntu-linux/">在Microsoft Azure中，手動安裝Redmine for Ubuntu Linux</a> 最早出現於 <a href="https://www.minitw.com">電腦茶包</a>。</p>
]]></description>
										<content:encoded><![CDATA[<p><a title="在Microsoft Azure中，半自動安裝Redmine for Ubuntu Linux" href="http://www.minitw.com/server/in-microsoft-azure-semi-automatic-installation-redmine-for-ubuntu-linux.htm" target="_blank" rel="noopener noreferrer">在Microsoft Azure中，半自動安裝Redmine for Ubuntu Linux</a>這篇文章說，說明了如何用apt來安裝redmine。</p>
<p>然而如果你有使用新版Redmine與升級Redmine的需求，建議使用手動的方式來安裝redmine，即本文要說明的方式。</p>
<p>如果Redmine架設完成後想跟Git整合，可以參考 <a title="在Ubuntu上Redmine與Git + Grack整合" href="http://www.minitw.com/server/on-ubuntu-using-redmine-integration-with-git-and-grack.htm" target="_blank" rel="noopener noreferrer">在Ubuntu上Redmine與Git + Grack整合</a></p>
<p><span id="more-1430"></span></p>
<p>先進行apt source的更新。</p>
<pre class="brush: bash;">
sudo apt-get update
</pre>
<p>安裝apache2與passenger相關的apache元件。安裝subversion，之後要用來下載redmine官方上的程式。</p>
<pre class="brush: bash;">
sudo apt-get install apache2 libapache2-mod-passenger subversion
</pre>
<p>安裝mysql資料庫，過程中需設定mysql root的密碼。</p>
<pre class="brush: bash;">
sudo apt-get install mysql-server mysql-client
</pre>
<p>安裝redmine會使用到的元件。</p>
<pre class="brush: bash;">
sudo apt-get install ruby-dev imagemagick libmagickcore-dev libmagickwand-dev libmysqlclient-dev build-essential
</pre>
<p>於家目錄中，下載redmine官方的程式。</p>
<pre class="brush: bash;">
cd ~
mkdir redmineSVN
cd redmineSVN
sudo svn co http://svn.redmine.org/redmine/branches/2.5-stable redmine2.5
</pre>
<p>建立plugin資料夾與連結redmine到apache2。</p>
<pre class="brush: bash;">
sudo mkdir ~/redmineSVN/redmine2.5/public/plugin_assets
sudo ln -s ~/redmineSVN/redmine2.5/public /var/www/redmine
</pre>
<p>建立redmine的設定檔</p>
<pre class="brush: bash;">
cd ~/redmineSVN/redmine2.5/
sudo cp config/configuration.yml.example config/configuration.yml
sudo cp config/database.yml.example config/database.yml
</pre>
<p>登入mysql資料庫(需輸入root的密碼)</p>
<pre class="brush: bash;">
mysql -uroot -p
</pre>
<p>建立redmine要使用的user與database。<br />
<span style="color: #ff0000;">注意：請記得把密碼改成你想要的。</span></p>
<pre>CREATE DATABASE redmine CHARACTER SET utf8;
CREATE USER 'redmine'@'localhost' IDENTIFIED BY '<span style="color: #ff0000;">my_password</span>';
GRANT ALL PRIVILEGES ON redmine.* TO 'redmine'@'localhost';
FLUSH PRIVILEGES;
EXIT;

</pre>
<p>編輯redmine資料庫設定檔</p>
<pre class="brush: bash;">
sudo vi ~/redmineSVN/redmine2.5/config/database.yml
</pre>
<p>修改後結果如下：<br />
production:<br />
adapter: mysql2<br />
database: redmine<br />
host: localhost<br />
username: redmine<br />
password: &#8220;<span style="color: #ff0000;">my_password</span>&#8221;<br />
encoding: utf8</p>
<p>安裝bundler與相關套件</p>
<pre class="brush: bash;">
sudo gem install bundler
sudo bundle install --without development test
</pre>
<p>redmine初始化設定</p>
<pre class="brush: bash;">
sudo bundle exec rake generate_secret_token
sudo RAILS_ENV=production bundle exec rake db:migrate
sudo RAILS_ENV=production bundle exec rake redmine:load_default_data
</pre>
<p>啟用rewrite與passenger模組</p>
<pre class="brush: bash;">
sudo a2enmod rewrite passenger
</pre>
<p>編輯/etc/apache2/mods-enabled/passenger.conf檔案</p>
<pre class="brush: bash;">
sudo vi /etc/apache2/mods-enabled/passenger.conf
</pre>
<p>把PassengerDefaultUser www-data加入到/etc/apache2/mods-enabled/passenger.conf中。<br />
加入後，最終的結果如下</p>
<pre class="brush: xml;">
&lt;IfModule mod_passenger.c&gt;
  PassengerDefaultUser www-data
  PassengerRoot /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini
  PassengerDefaultRuby /usr/bin/ruby
&lt;/IfModule&gt;
</pre>
<p>把預設的site設定檔關掉，建立一個新的redmine site設定檔</p>
<pre class="brush: bash;">
sudo a2dissite 000-default
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/redmine.conf
</pre>
<p>編輯redmine site的設定檔</p>
<pre class="brush: bash;">
sudo vi /etc/apache2/sites-available/redmine.conf
</pre>
<p>找到<br />
DocumentRoot /var/www/html<br />
修改為<br />
DocumentRoot /var/www</p>
<p>並增加</p>
<pre class="brush: xml;">
&lt;Directory /var/www/redmine&gt;
            RailsBaseURI /redmine
            PassengerResolveSymlinksInDocumentRoot on
&lt;/Directory&gt;
</pre>
<p>啟用redmine site設定檔</p>
<pre class="brush: bash;">
sudo a2ensite redmine
</pre>
<p>修正redmine的目錄檔案權限</p>
<pre class="brush: bash;">
sudo chown -R www-data ~/redmineSVN/redmine2.5
sudo chgrp -R www-data ~/redmineSVN/redmine2.5
</pre>
<p>重新啟動apache2</p>
<pre class="brush: bash;">
sudo service apache2 restart
</pre>
<p>這篇文章 <a href="https://www.minitw.com/post/2014/07/22/in-microsoft-azure-manually-installation-redmine-for-ubuntu-linux/">在Microsoft Azure中，手動安裝Redmine for Ubuntu Linux</a> 最早出現於 <a href="https://www.minitw.com">電腦茶包</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.minitw.com/post/2014/07/22/in-microsoft-azure-manually-installation-redmine-for-ubuntu-linux/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>