<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Coding Cheatsheet - Medium]]></title>
        <description><![CDATA[What You Read Is What I Learn - Medium]]></description>
        <link>https://medium.com/coding-cheatsheet?source=rss----fd7deb02ba1e---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Coding Cheatsheet - Medium</title>
            <link>https://medium.com/coding-cheatsheet?source=rss----fd7deb02ba1e---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 18:25:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/coding-cheatsheet" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Android Runtime Permissions 設計]]></title>
            <link>https://medium.com/coding-cheatsheet/android-runtime-permission-%E8%A8%AD%E8%A8%88-41453364102b?source=rss----fd7deb02ba1e---4</link>
            <guid isPermaLink="false">https://medium.com/p/41453364102b</guid>
            <category><![CDATA[development]]></category>
            <category><![CDATA[permission]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Himphen Hui]]></dc:creator>
            <pubDate>Thu, 23 Feb 2017 07:17:04 GMT</pubDate>
            <atom:updated>2017-02-23T07:36:01.693Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-nc/4.0/</cc:license>
            <content:encoded><![CDATA[<p>Android 6.0 (API Level 23) 開始引入了 Runtime Permissions，過去用戶在安裝程式時需要一次接受所有權限請求，而 Runtime Permissions 可交由用戶自行判斷接受哪些權限。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*reHw_OtLBwIjXg_z2atbtg.png" /><figcaption>Twitter 使用 Runtime Permission</figcaption></figure><h3>前提</h3><p>今次教學會以「自由香港楷書」Android 應用程式作例子，自由香港楷書在 0.1.6 版本新增截圖分享功能，由於需要寫入圖片到外部空間作傳送圖片之用，因此加入了「android.permission.WRITE_EXTERNAL_STORAGE」權限。</p><p>應用程式下載：<br><a href="https://play.google.com/store/apps/details?id=hk.collaction.freehkkai">https://play.google.com/store/apps/details?id=hk.collaction.freehkkai</a></p><p>完整 0.1.6 版本的 GitHub 原始碼：<br><a href="https://github.com/collaction/freehkkai-android/tree/0.1.6">https://github.com/collaction/freehkkai-android/tree/0.1.6</a></p><h3>快速教學</h3><p>不論你的程式有否支援 API Level 22 或以下的 Android 版本，你還是要在 Android Manifest.xml 聲明權限使用：</p><pre>&lt;uses-permission android:name=&quot;android.permission.WRITE_EXTERNAL_STORAGE&quot;/&gt;</pre><p>在 MainFragment.java import 以下 Class 及定義一個 final String：</p><pre>import android.support.v4.content.ContextCompat;<br>import android.content.pm.PackageManager;</pre><pre>public class MainFragment extends BaseFragment {</pre><pre>protected final String PERMISSION_NAME = Manifest.permission.WRITE_EXTERNAL_STORAGE;</pre><pre>}</pre><p>接著當用戶按下「分享截圖」按鈕時，會執行onClickScreenCap()，檢查是否已被授權相關權限：</p><pre>if (ContextCompat.checkSelfPermission(mContext, PERMISSION_NAME) == PackageManager.PERMISSION_GRANTED) {<br>    // 已得到授權<br>} else {<br>    // 沒有授權<br>    // 或曾請求用戶授權，但被拒絕<br>    // 或用戶在系統設定中禁用授權<strong><br></strong>}</pre><p>當沒有授權時，你需要調用：</p><pre>requestPermissions<strong>(new</strong> String<strong>[]</strong> <strong>{</strong> PERMISSION_NAME <strong>}, </strong>REQUEST_PERMISSION<strong>);</strong></pre><p>假使你需要同時取得多個權限授權，你可以在 new String[] 加入權限名稱：</p><pre>requestPermissions<strong>(new</strong> String<strong>[]</strong> <strong>{</strong> PERMISSION_NAME_1, PERMISSION_NAME_2, PERMISSION_NAME_3 <strong>}, </strong>REQUEST_PERMISSION<strong>);</strong></pre><p>系統會 Dialog 詢問用戶是否需要授權程式，不論按下是否皆會調用 onRequestPermissionsResult()，取得授權後可以再次執行onClickScreenCap()。</p><pre><a href="http://twitter.com/Override">@Override</a><br> public void onRequestPermissionsResult(int requestCode, <a href="http://twitter.com/NonNull">@NonNull</a> String[] permissions, <a href="http://twitter.com/NonNull">@NonNull</a> int[] grantResults) {<br>  super.onRequestPermissionsResult(requestCode, permissions, grantResults);<br>  if (requestCode == PERMISSION_REQUEST_CODE) {<br>   if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {<br>    onClickScreenCap()<br>   } else {<br>    // 彈出請求<br>   }<br>  }<br> }</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*pdc8gS3ZSAOOiyO7hIdi_A.png" /><figcaption>requestPermissions() 的請求</figcaption></figure><p>一旦用戶在 Dialog 選擇了拒絕，往後的 Dialog 也會出現「不再詢問」的選項，有趣的是當用戶選擇了允許，「不再詢問」會被隱藏。</p><p>但是要注意當用戶點選「不再詢問」並拒絕授權，不論任何情況都會假定用戶是拒絕授權，因此你可以彈出自定的 Dialog，提醒用戶需要授權才能使用相關功能。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*BVXee7NtkK_KeXaZj6UQjw.png" /><figcaption>grantResults[0] != PackageManager.PERMISSION_GRANTED 時，你需要提醒用戶授權</figcaption></figure><p>如果剛才你同時提交多個授權檢查，只要檢查grantResults每個 value 是否PackageManager.PERMISSION_GRANTED便可以。</p><h3>小結</h3><p>不是所有 Permissions 需要用戶授權的，Android 把權限分為 Normal and Dangerous Permissions，只有 Dangerous Permissions 才需要調用 requestPermissions()。</p><p>你在 Android Studio 建立項目時，現在的 targetSdkVersion 會自動設置為 23+。如果你還未支援新的 Runtime Permissions 時，建議你先把targetSdkVersion 降級到 22。</p><p>有關哪些是 Dangerous Permissions，請到：<br><a href="https://developer.android.com/guide/topics/permissions/requesting.html">https://developer.android.com/guide/topics/permissions/requesting.html</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=41453364102b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coding-cheatsheet/android-runtime-permission-%E8%A8%AD%E8%A8%88-41453364102b">Android Runtime Permissions 設計</a> was originally published in <a href="https://medium.com/coding-cheatsheet">Coding Cheatsheet</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[如何 10 分鐘開發一個 Facebook Bot (PHP)]]></title>
            <link>https://medium.com/coding-cheatsheet/%E5%A6%82%E4%BD%95-10-%E5%88%86%E9%90%98%E9%96%8B%E7%99%BC%E4%B8%80%E5%80%8B-facebook-bot-php-fc9fc3b132c6?source=rss----fd7deb02ba1e---4</link>
            <guid isPermaLink="false">https://medium.com/p/fc9fc3b132c6</guid>
            <category><![CDATA[facebook-messenger]]></category>
            <category><![CDATA[bots]]></category>
            <dc:creator><![CDATA[Himphen Hui]]></dc:creator>
            <pubDate>Thu, 05 Jan 2017 07:46:10 GMT</pubDate>
            <atom:updated>2017-01-05T12:41:40.301Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-sa/4.0/</cc:license>
            <content:encoded><![CDATA[<h3>初始環境</h3><h4>建立一個 Facebook Page</h4><p><a href="https://www.facebook.com/pages/create">Create a Page | Facebook</a></p><h4>建立一個 Facebook App</h4><p><a href="https://developers.facebook.com/">Social technologies | Meta for Developers</a></p><h4>下載 Codeigniter</h4><p><a href="https://www.codeigniter.com/">CodeIgniter Web Framework</a></p><h4>Composer 安裝 <a href="https://github.com/pimax">pimax</a>/<a href="https://github.com/pimax/fb-messenger-php">fb-messenger-php</a></h4><p><a href="https://github.com/pimax/fb-messenger-php">pimax/fb-messenger-php</a></p><pre>composer require &quot;pimax/fb-messenger-php&quot; &quot;dev-master&quot;</pre><h3>開始 Coding</h3><h4>建立三個檔案</h4><p>在 Controllers Folder 建立一個 Bot.php 的檔案</p><pre><strong>&lt;?php<br></strong>defined(&#39;BASEPATH&#39;) <strong>OR exit</strong>(&#39;No direct script access allowed&#39;);<br><br><strong>class </strong>Bot <strong>extends </strong>CI_Controller<br>{</pre><pre><strong>   private </strong>$image_url1 = &#39;https://scontent.xx.fbcdn.net/v/t1.0-9/10002972_10152829556387298_4297087383863089212_n.jpg?oh=05537b171fe09ec9b49f1576fb21f0b1&amp;oe=591C8734&#39;;<br>   <strong>private </strong>$image_url2 = &#39;https://scontent.xx.fbcdn.net/v/t31.0-8/15800787_1780467612216765_8582748877179132963_o.png?oh=44b02b3281e514ca529f1948a261fb12&amp;oe=591AC7AC&#39;;<br>   <br>   <strong>public function </strong>index()<br>   {<br>      <strong>echo </strong>&#39;hello world&#39;;<br>   }<br>   <br>   <strong>public function </strong>facebook()<br>   {<br>   }<br>}</pre><p>在 Libraries Folder 建立一個 Facebook_bot.php 的檔案</p><pre><strong>&lt;?php<br></strong>defined(&#39;BASEPATH&#39;) <strong>OR exit</strong>(&#39;No direct script access allowed&#39;);<br><br><strong>use </strong>pimax\FbBotApp;<br><strong>use </strong>pimax\Messages\ImageMessage;<br><strong>use </strong>pimax\Messages\Message;<br><strong>use </strong>pimax\Messages\MessageButton;<br><strong>use </strong>pimax\Messages\MessageElement;<br><strong>use </strong>pimax\Messages\StructuredMessage;<br><br><strong>Class </strong>Facebook_bot<br>{<br>   <br>   <strong>public static </strong><em>$sender_id</em>;<br>   <strong>public static </strong><em>$helper</em>;<br>   <br>   <strong>public function </strong>__construct($params = [])<br>   {<br>      $ci = &amp;get_instance();<br>      $config = $ci-&gt;config;<br>      <br>      // Load config<br>      $config-&gt;load(&#39;facebook_bot&#39;);<br>      <br>      $verify_token = $config-&gt;item(&#39;verify_token&#39;);<br>      $access_token = $config-&gt;item(&#39;access_token&#39;);<br>      <br>      <strong>self</strong>::<em>$helper </em>= <strong>new </strong>FbBotApp($access_token);<br>      <br>      <strong>if </strong>($ci-&gt;input-&gt;get_post(&#39;hub_mode&#39;) === &#39;subscribe&#39; &amp;&amp;<br>         $ci-&gt;input-&gt;get_post(&#39;hub_verify_token&#39;) === $verify_token<br>      ) {<br>         <strong>die</strong>($ci-&gt;input-&gt;get_post(&#39;hub_challenge&#39;));<br>      }<br>   }<br>   <br>   <strong>public static function </strong>setSenderId($sender_id)<br>   {<br>      <strong>self</strong>::<em>$sender_id </em>= $sender_id;<br>   }<br>   <br>   <strong>public static function </strong>getMessage($text)<br>   {<br>      <strong>return new </strong>Message(<strong>self</strong>::<em>$sender_id</em>, $text);<br>   }<br>   <br>   <strong>public static function </strong>getImageMessage($url)<br>   {<br>      <strong>return new </strong>ImageMessage(<strong>self</strong>::<em>$sender_id</em>, $url);<br>   }<br>   <br>   <strong>public static function </strong>getStructuredMessage($type, $array)<br>   {<br>      <strong>switch </strong>($type) {<br>         <strong>case </strong>&#39;TYPE_BUTTON&#39;:<br>            $casted_type = StructuredMessage::<em>TYPE_BUTTON</em>;<br>            <strong>break</strong>;<br>         <strong>default</strong>:<br>            $casted_type = StructuredMessage::<em>TYPE_GENERIC</em>;<br>      }<br>      <br>      <strong>return new </strong>StructuredMessage(<strong>self</strong>::<em>$sender_id</em>, $casted_type, $array);<br>   }<br>   <br>   <strong>public static function </strong>getMessageButton($type, $title, $url = &#39;&#39;)<br>   {<br>      <strong>switch </strong>($type) {<br>         <strong>case </strong>&#39;TYPE_WEB&#39;:<br>            $casted_type = MessageButton::<em>TYPE_WEB</em>;<br>            <strong>break</strong>;<br>         <strong>default</strong>:<br>            $casted_type = MessageButton::<em>TYPE_POSTBACK</em>;<br>      }<br>      <br>      <strong>return new </strong>MessageButton($casted_type, $title, $url);<br>   }<br>   <br>   <strong>public static function </strong>getMessageElement($title, $subtitle, $image_url = &#39;&#39;, $buttons = [])<br>   {<br>      <strong>return new </strong>MessageElement($title, $subtitle, $image_url, $buttons);<br>   }<br>   <br>   <strong>public static function </strong>send($message)<br>   {<br>      <strong>self</strong>::<em>$helper</em>-&gt;send($message);<br>   }<br>}</pre><p>在 Configs Folder 建立一個 facebook_bot.php 的檔案</p><pre><strong>&lt;?php<br></strong>defined(&#39;BASEPATH&#39;) <strong>OR exit</strong>(&#39;No direct script access allowed&#39;);<br><br>$config[&#39;access_token&#39;] = &#39;access_token&#39;;<br>$config[&#39;verify_token&#39;] = &#39;verify_token&#39;;</pre><h4>取得 Page Token</h4><p>在 App 頁面選擇指定的 Page，取得 Page Token，把取得的 Page Token 放在 $config[&#39;access_token&#39;]。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/807/1*bDK57MIu50eiH-IvUP4GVA.png" /></figure><p>然後點選 Setup Webhook，指定某一網址，請注意必須使用 HTTPS。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/811/1*zDYcb46jAdMwxQ76JjpW3Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/815/1*VyCjVxWQQ4bpa4YJLxmgTA.png" /></figure><p>隨便輸入 Verify Token，並勾選 messages 及 messaging_postbacks，把取得的 Verify Token 放在 $config[&#39;verify_token&#39;]。</p><p>完成後把 Webhooks subscribe 至你的 Page。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/806/1*ncWYQWfrQkfuEnjtxzVJbg.png" /></figure><h4>接收及回應</h4><p>先載入 facebook_bot library，並把 json string 轉為 array，最後可得到 $command。</p><pre>$this-&gt;load-&gt;library(&#39;facebook_bot&#39;);<br><br>$received_string = file_get_contents(&#39;php://input&#39;);<br><br>$data = json_decode($received_string, <strong>true</strong>, 512, <em>JSON_BIGINT_AS_STRING</em>);</pre><pre><strong>if </strong>($data) {<br>   <strong>if </strong>( ! <strong>empty</strong>($data[&#39;entry&#39;][0][&#39;messaging&#39;])) {<br>      <strong>foreach </strong>($data[&#39;entry&#39;][0][&#39;messaging&#39;] <strong>as </strong>$message) {<br>         <strong>if </strong>(<strong>isset</strong>($message[&#39;message&#39;][&#39;text&#39;])) {<br>            // When bot receive message from user<br>            $command = $message[&#39;message&#39;][&#39;text&#39;];<br>         } <strong>else if </strong>(<strong>isset</strong>($message[&#39;postback&#39;][&#39;payload&#39;])) {<br>            // When bot receive button click from user<br>            $command = $message[&#39;postback&#39;][&#39;payload&#39;];<br>         } <strong>else </strong>{<br>            // Skipping empty messages<br>            <strong>continue</strong>;<br>         }<br>      }<br>   }<br>}</pre><p>接著設定 senderID，並把$command轉為小階。</p><pre>// Must set senderID before try to send message<br>Facebook_bot::<em>setSenderID</em>($message[&#39;sender&#39;][&#39;id&#39;]);<br><br>$command = strtolower($command);</pre><p>只要有了指令，你可以按自己需求作回應。</p><pre><strong>if </strong>($command === &#39;hello&#39;) {<br>   Facebook_bot::<em>send</em>(Facebook_bot::<em>getMessage</em>(&#39;Hello World&#39;));<br>} <strong>else if </strong>($command === &#39;image&#39;) {<br>   Facebook_bot::<em>send</em>(Facebook_bot::<em>getImageMessage</em>($this-&gt;image_url1));<br>} <strong>else if </strong>($command === &#39;button&#39;) {<br>    Facebook_bot::<em>send</em>(Facebook_bot::<em>getStructuredMessage</em>(&#39;TYPE_BUTTON&#39;, [<br>      &#39;text&#39; =&gt; &#39;What can I help you?&#39;,<br>      &#39;buttons&#39; =&gt; [<br>         Facebook_bot::<em>getMessageButton</em>(<br>            &#39;TYPE_WEB&#39;,<br>            &#39;你的初戀在此&#39;,<br>            &#39;https://fb.me/himphen&#39;<br>         ),<br>         Facebook_bot::<em>getMessageButton</em>(<br>            &#39;TYPE_POSTBACK&#39;,<br>            &#39;Image&#39;<br>         ),<br>         Facebook_bot::<em>getMessageButton</em>(<br>            &#39;TYPE_POSTBACK&#39;,<br>            &#39;Structured&#39;<br>         )<br>      ]<br>   ]));<br>} <strong>else if </strong>($command === &#39;structured&#39;) {<br>   $elements = [];<br>   <br>   $elements[] = Facebook_bot::<em>getMessageElement</em>(<br>      &#39;Name1&#39;,<br>      &#39;Desc1&#39;,<br>      $this-&gt;image_url1,<br>      [<br>         Facebook_bot::<em>getMessageButton</em>(<br>            &#39;TYPE_POSTBACK&#39;,<br>            &#39;Button&#39;<br>         ),<br>         Facebook_bot::<em>getMessageButton</em>(<br>            &#39;TYPE_WEB&#39;,<br>            &#39;Link&#39;,<br>            &#39;https://www.messenger.com/t/himphen&#39;<br>         ),<br>      ]<br>   );<br>   <br>   $elements[] = Facebook_bot::<em>getMessageElement</em>(<br>      &#39;Name2&#39;,<br>      &#39;Desc2&#39;,<br>      $this-&gt;image_url2,<br>      [<br>         Facebook_bot::<em>getMessageButton</em>(<br>            &#39;TYPE_POSTBACK&#39;,<br>            &#39;Button&#39;<br>         )<br>      ]<br>   );<br>   <br>   Facebook_bot::<em>send</em>(Facebook_bot::<em>getStructuredMessage</em>(&#39;TYPE_GENERIC&#39;, [<br>      &#39;elements&#39; =&gt; $elements<br>   ]));<br>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc9fc3b132c6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coding-cheatsheet/%E5%A6%82%E4%BD%95-10-%E5%88%86%E9%90%98%E9%96%8B%E7%99%BC%E4%B8%80%E5%80%8B-facebook-bot-php-fc9fc3b132c6">如何 10 分鐘開發一個 Facebook Bot (PHP)</a> was originally published in <a href="https://medium.com/coding-cheatsheet">Coding Cheatsheet</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[如何在 Amazon Linux/CentOS/RHEL 上透過 Let’s Encrypt 安裝免費 SSL/TLS 憑證]]></title>
            <link>https://medium.com/coding-cheatsheet/%E5%A6%82%E4%BD%95%E5%9C%A8-amazon-linux-centos-rhel-%E4%B8%8A%E9%80%8F%E9%81%8E-lets-encrypt-%E5%AE%89%E8%A3%9D%E5%85%8D%E8%B2%BB-ssl-tls-%E6%86%91%E8%AD%89-8aa6ccebb9fd?source=rss----fd7deb02ba1e---4</link>
            <guid isPermaLink="false">https://medium.com/p/8aa6ccebb9fd</guid>
            <category><![CDATA[lets-encrypt]]></category>
            <category><![CDATA[ssl]]></category>
            <dc:creator><![CDATA[Himphen Hui]]></dc:creator>
            <pubDate>Wed, 19 Oct 2016 13:18:22 GMT</pubDate>
            <atom:updated>2017-04-26T09:29:51.938Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-sa/4.0/</cc:license>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9Q8WOB5Zi-6MXGwYM3CAVw.png" /><figcaption>Don’t pay for SSL certs anymore. Just use Let’s Encrypt!!!</figcaption></figure><h3>安裝 Let’s Encrypt</h3><p><a href="https://letsencrypt.org/">Let’s Encrypt</a> 是由各大科技公司以及非營利團體為了推廣 HTTPS 而贊助的一家免費發佈 SSL 憑證機構。</p><h4>下載 Let’s Encrypt</h4><p>首先以 root 身份登入並前往家目錄（home directory)：</p><pre># sudo su<br># cd</pre><p>假若你並沒先前安裝 git 的話，請使用 yum 安裝 git 並接下來 clone repository：</p><pre>Install Git if you haven&#39;t it:<br># yum install git</pre><pre>Clone the repository from GitHub:<br># git clone <a href="https://github.com/letsencrypt/letsencrypt">https://github.com/letsencrypt/letsencrypt</a></pre><h4>執行 Let’s Encrypt</h4><p>現在你將取得最新的 Let’s Encrypt 程式碼，前往「~/letsencrypt」資料夾：</p><pre># cd ~/letsencrypt</pre><pre>If you are using Amazon Linux, use it:<br># ./letsencrypt-auto --debug</pre><pre>Else if you are using Centos/RHEL, use it:<br># ./letsencrypt-auto</pre><p>你或可能會見到這段警告提示：<strong>No installers are available on your OS yet; try running “letsencrypt-auto certonly” to get a cert you can install manually</strong>，那你需要輸入「<strong>letsencrypt-auto certonly」</strong>進行手動安裝。</p><p>注意你已完成安裝的話，則無需繼續以下步驟：</p><pre># ./letsencrypt-auto certonly --webroot -w WEBROOT_PATH -d DOMAIN_NAME --renew-by-default --agree-tos</pre><p>搞定了，你已經取得所需的 SSL 憑證及 public key，接下來需要在 Apache 更改設定才能生效 HTTPS。</p><pre>Congratulations! Your certificate and chain have been saved at /etc/letsencrypt/live/DOMAIN_NAME/fullchain.pem. Your cert will expire on 2016–03–10. To obtain a new version of the certificate in the future, simply run Let’s Encrypt again.</pre><h4>設定 Apache</h4><p>不要忘記安裝 Apache SSL 模組，使用 yum 安裝 mod_ssl，所有相關套件也會自動取得：</p><pre># yum install mod_ssl</pre><p>然後編輯 /etc/httpd/conf.d/httpd.conf。</p><p>加入以下程式碼在 &lt;VirtualHost *:80&gt; 後方：</p><pre>&lt;VirtualHost *:443&gt;<br>  ServerName DOMAIN_NAME<br>  DocumentRoot WEBROOT_PATH</pre><pre>SSLEngine on</pre><pre>SSLCertificateFile /etc/letsencrypt/live/DOMAIN_NAME<a href="http://www.collaction.hk/cert.pem">/cert.pem</a><br>  SSLCertificateKeyFile /etc/letsencrypt/live/DOMAIN_NAME<a href="http://www.collaction.hk/privkey.pem">/privkey.pem</a><br>  SSLCertificateChainFile /etc/letsencrypt/live/DOMAIN_NAME<a href="http://www.collaction.hk/chain.pem">/chain.pem</a><br>  SSLCACertificateFile /etc/letsencrypt/live/DOMAIN_NAME<a href="http://www.collaction.hk/fullchain.pem">/fullchain.pem</a></pre><pre>&lt;Directory WEBROOT_PATH&gt;<br>    AllowOverride All<br>    Order allow,deny<br>    Allow from all<br>    Require all granted<br>  &lt;/Directory&gt;<br>&lt;/VirtualHost&gt;</pre><p>重新啟動 Apache 服務以套用新設定。</p><pre># service httpd restart</pre><h4>利用 crontab 執行 Let’s Encrypt</h4><p>你的 SSL cert 將會 3 個月後到期，當然你可以每三個月手動執行以上指令，可惜工程師是世界上最懶惰的生物，這種事必須交由他們的僕人去做：即是寫一個程式出來吧。</p><p>（注意這方法好像不適用於所有人，你應得做足夠的測試才行！）</p><p>我們可以建立一個 crontab 工作，首先建立 sslgenerate.sh：</p><pre># vim sslgenerate.sh</pre><p>加入以下程式碼到 sslgenerate.sh:</p><pre>cd ~/letsencrypt</pre><pre>./letsencrypt-auto renew</pre><pre>service httpd restart</pre><p>建立一個 cron job：</p><pre># crontab -e<br># 30 2 * * 1 sh ~/sslgenerate.sh</pre><p>更多資料，請到：</p><p><a href="https://letsencrypt.readthedocs.org/en/latest/using.html">https://letsencrypt.readthedocs.org/en/latest/using.html</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8aa6ccebb9fd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coding-cheatsheet/%E5%A6%82%E4%BD%95%E5%9C%A8-amazon-linux-centos-rhel-%E4%B8%8A%E9%80%8F%E9%81%8E-lets-encrypt-%E5%AE%89%E8%A3%9D%E5%85%8D%E8%B2%BB-ssl-tls-%E6%86%91%E8%AD%89-8aa6ccebb9fd">如何在 Amazon Linux/CentOS/RHEL 上透過 Let’s Encrypt 安裝免費 SSL/TLS 憑證</a> was originally published in <a href="https://medium.com/coding-cheatsheet">Coding Cheatsheet</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[如何在 Amazon Linux/CentOS/RHEL 透過 yum 安裝 ImageMagick]]></title>
            <link>https://medium.com/coding-cheatsheet/%E5%A6%82%E4%BD%95%E5%9C%A8-amazon-linux-centos-rhel-%E9%80%8F%E9%81%8E-yum-%E5%AE%89%E8%A3%9D-imagemagick-3ba4517cbaa1?source=rss----fd7deb02ba1e---4</link>
            <guid isPermaLink="false">https://medium.com/p/3ba4517cbaa1</guid>
            <category><![CDATA[centos]]></category>
            <category><![CDATA[imagemagick]]></category>
            <dc:creator><![CDATA[Himphen Hui]]></dc:creator>
            <pubDate>Tue, 13 Sep 2016 05:51:18 GMT</pubDate>
            <atom:updated>2017-02-27T09:30:48.464Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<h3>什麼是 <strong>ImageMagick</strong></h3><p><strong>ImageMagick</strong> 是一個用於檢視、編輯點陣圖檔案以及進行圖像格式轉換的開放源碼軟件套裝。它可以讀取、編輯超過 100 種圖象格式，並包括了大量用於特效的濾鏡和擴充功能功能。（取自維基百科）</p><h4>安裝需求套件及 ImageMagick</h4><p>這篇文章將會引導你在 Amazon Linux/CentOS/RHEL 上安裝 ImageMagic 及IMagick PHP，首先需要安裝 PHP 需求套件：</p><pre># yum install gcc php56-devel php-pear</pre><p>接著正式安裝 ImageMagick：</p><pre># yum install ImageMagick ImageMagick-devel</pre><p>完成後你的 Linux 系統上已經包含了 ImageMagick，你可以根據你的程式語言如 <strong>Magick.NET</strong> (.Net)、<strong>IMagick</strong> (PHP)、<strong>PerlMagick</strong> (Perl) 來安裝相應 Extension。</p><p>以下會繼續安裝 <strong>IMagick </strong>PHP Extension：</p><pre># pecl install imagick<br># echo &quot;extension=imagick.so&quot; &gt; /etc/php.d/imagick.ini</pre><p>完成以上步驟，你需要重新載入 Apache 並檢查 Extension 是否正常運行。</p><pre># service httpd reload</pre><p>建立一個 PHP 檔案，包含以下程式碼，如安裝正確，你將可以見到下面的 Logo：</p><pre>&lt;?php</pre><pre>$url = &#39;https://cdn-images-1.medium.com/max/800/1*tCyGseaFSv5xb_zhYO1xJw.jpeg&#39;;</pre><pre>$img = new Imagick($url);<br>header(&#39;Content-Type: image/&#39;.$img-&gt;getImageFormat());<br>echo $img;</pre><pre>// echo $imagick-&gt;getimageblob(); Replace the above echo if you are using HHVM, otherwise it will throw a fatal exception</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*tCyGseaFSv5xb_zhYO1xJw.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3ba4517cbaa1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coding-cheatsheet/%E5%A6%82%E4%BD%95%E5%9C%A8-amazon-linux-centos-rhel-%E9%80%8F%E9%81%8E-yum-%E5%AE%89%E8%A3%9D-imagemagick-3ba4517cbaa1">如何在 Amazon Linux/CentOS/RHEL 透過 yum 安裝 ImageMagick</a> was originally published in <a href="https://medium.com/coding-cheatsheet">Coding Cheatsheet</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How To Install Free SSL/TLS Certificates using Let’s Encrypt on Amazon Linux/CentOS/RHEL]]></title>
            <link>https://medium.com/coding-cheatsheet/how-to-install-free-ssl-tls-certificates-using-lets-encrypt-on-amazon-linux-centos-rhel-6a20ef4bab4b?source=rss----fd7deb02ba1e---4</link>
            <guid isPermaLink="false">https://medium.com/p/6a20ef4bab4b</guid>
            <category><![CDATA[ssl]]></category>
            <category><![CDATA[github]]></category>
            <dc:creator><![CDATA[Himphen Hui]]></dc:creator>
            <pubDate>Wed, 27 Apr 2016 13:44:04 GMT</pubDate>
            <atom:updated>2017-02-27T03:52:27.998Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-sa/4.0/</cc:license>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9Q8WOB5Zi-6MXGwYM3CAVw.png" /><figcaption>Don’t pay for SSL certs anymore. Just use Let’s Encrypt!!!</figcaption></figure><h3>Install Let’s Encrypt</h3><p>Let’s Encrypt is a free, automated, and open certificate authority brought to everyone by the Internet Security Research Group (ISRG).</p><h4>Setup Let’s Encrypt</h4><p>First of all, run as root and go to your home directory by command these:</p><pre># sudo su<br># cd</pre><p>If you don’t got git in Linux, yum install git and clone the repository from GitHub:</p><pre>Install Git if you haven&#39;t it:<br># yum install git</pre><pre>Clone the repository from GitHub:<br># git clone <a href="https://github.com/letsencrypt/letsencrypt">https://github.com/letsencrypt/letsencrypt</a></pre><h4>Run Let’s Encrypt</h4><p>Now you retrieved all the latest scripts from the repository to your server. You can find it under “~/letsencrypt”.</p><pre># cd ~/letsencrypt</pre><pre>If you are using Amazon Linux, use it:<br># ./letsencrypt-auto --debug</pre><pre>Else if you are using Centos/RHEL, use it:<br># ./letsencrypt-auto<br></pre><p>You will probably get the notice <strong>“No installers are available on your OS yet; try running “letsencrypt-auto certonly” to get a cert you can install manually”</strong> if you run the installer that couldn’t configure everything automatically.</p><p>If you worked with above installer, you don’t have to do the steps below manually.</p><pre># ./letsencrypt-auto certonly --webroot -w WEBROOT_PATH -d DOMAIN_NAME --renew-by-default --agree-tos</pre><p>That’s it. You have retrieved the required SSL certificate and key for your domain. All we have to do is set it up in Apache.</p><pre>Congratulations! Your certificate and chain have been saved at /etc/letsencrypt/live/DOMAIN_NAME/fullchain.pem. Your cert will expire on 2016–03–10. To obtain a new version of the certificate in the future, simply run Let’s Encrypt again.</pre><h4>Setup Apache</h4><p>Don’t forget have to install the Apache SSL module. Install mod_ssl using yum package manager. All the dependencies will automatically be installed.</p><pre># yum install mod24_ssl</pre><p>Then edit file /etc/httpd/conf.d/httpd.conf. Add the following after &lt;VirtualHost *:80&gt;</p><pre>&lt;VirtualHost *:443&gt;<br>  ServerName DOMAIN_NAME<br>  DocumentRoot WEBROOT_PATH</pre><pre>  SSLEngine on</pre><pre>  SSLCertificateFile /etc/letsencrypt/live/DOMAIN_NAME<a href="http://www.collaction.hk/cert.pem">/cert.pem</a><br>  SSLCertificateKeyFile /etc/letsencrypt/live/DOMAIN_NAME<a href="http://www.collaction.hk/privkey.pem">/privkey.pem</a><br>  SSLCertificateChainFile /etc/letsencrypt/live/DOMAIN_NAME<a href="http://www.collaction.hk/chain.pem">/chain.pem</a><br>  SSLCACertificateFile /etc/letsencrypt/live/DOMAIN_NAME<a href="http://www.collaction.hk/fullchain.pem">/fullchain.pem</a></pre><pre>  &lt;Directory WEBROOT_PATH&gt;<br>    AllowOverride All<br>    Order allow,deny<br>    Allow from all<br>    Require all granted<br>  &lt;/Directory&gt;<br>&lt;/VirtualHost&gt;</pre><p>After updating Apache configuration file, restart Apache service to reload new settings.</p><pre># service httpd restart</pre><h4>Run Let’s Encrypt by crontab</h4><p>Your SSL cert will expire within 3 months. Obviously you may run the above commands every 3 months, however engineers are the most lazy species on this planet. You may create a script and a cron job to run it.</p><pre># vim sslgenerate.sh</pre><p>Add following scripts into the file sslgenerate.sh:</p><pre>cd ~/letsencrypt</pre><pre>./letsencrypt-auto certonly --webroot -w WEBROOT_PATH -d DOMAIN_NAME --renew-by-default --agree-tos</pre><pre>service httpd restart</pre><p>Finally add a cron job including the following content, all in one line:</p><pre># crontab -e<br># 30 2 * * 1 vim ~/sslgenerate.sh</pre><p>For other servers, please take a look on <a href="https://letsencrypt.readthedocs.org/en/latest/using.html">https://letsencrypt.readthedocs.org/en/latest/using.html</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6a20ef4bab4b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coding-cheatsheet/how-to-install-free-ssl-tls-certificates-using-lets-encrypt-on-amazon-linux-centos-rhel-6a20ef4bab4b">How To Install Free SSL/TLS Certificates using Let’s Encrypt on Amazon Linux/CentOS/RHEL</a> was originally published in <a href="https://medium.com/coding-cheatsheet">Coding Cheatsheet</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HTTP Strict Transport Security]]></title>
            <link>https://medium.com/coding-cheatsheet/http-strict-transport-security-9144f423dd5e?source=rss----fd7deb02ba1e---4</link>
            <guid isPermaLink="false">https://medium.com/p/9144f423dd5e</guid>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Himphen Hui]]></dc:creator>
            <pubDate>Wed, 20 Apr 2016 14:08:25 GMT</pubDate>
            <atom:updated>2016-04-20T14:07:39.195Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<p>最近發現瀏覽器支援名為「HTTP Strict Transport Security」的安全功能，大致上是用戶存取網站時只允許使用安全及加密的連結方式（HTTPS）。根據 Can I use 網站所示，90 % 以上使用者所用的瀏覽器都支援 HSTS。</p><p>提供安全的網絡瀏覽體驗，應該一律透過 HTTPS 連線到伺服器，並不建議 用 http:// 開頭。「重新導向 HTTP 至 HTTPS」的方式多數使用 htaccess，檢測來源的 Port 不是 443 的話，會作 301 重新導向，以 Collaction 網站為例，我們在 .htaccess 加入以下程式碼：</p><pre>#Redirect non HTTPS to HTTPS<br>RewriteCond %{SERVER_PORT} !^443$<br>RewriteRule ^(.*)$ <a href="https://www.collaction.hk/$1">https://www.collaction.hk/$1</a> [L,R=301]</pre><p>而 HSTS 可避免我們在重新導向 HTTPS 時啟用的 301 工作成本，同樣重要的是，我們可以確保用戶端不會受中間人攻擊，甚至被中斷、破壞。在 .htaccess 加入以下程式碼：</p><pre>Header set Strict-Transport-Security “max-age=31536000” env=HTTPS</pre><h4>相關連結</h4><ul><li><a href="http://caniuse.com/#feat=stricttransportsecurity">http://caniuse.com/#feat=stricttransportsecurity</a></li><li><a href="https://developer.mozilla.org/en-US/docs/Web/Security/HTTP_strict_transport_security">https://developer.mozilla.org/en-US/docs/Web/Security/HTTP_strict_transport_security</a></li><li><a href="https://hstspreload.appspot.com/">https://hstspreload.appspot.com/</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9144f423dd5e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coding-cheatsheet/http-strict-transport-security-9144f423dd5e">HTTP Strict Transport Security</a> was originally published in <a href="https://medium.com/coding-cheatsheet">Coding Cheatsheet</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Remove Emoji Characters in PHP]]></title>
            <link>https://medium.com/coding-cheatsheet/remove-emoji-characters-in-php-236034946f51?source=rss----fd7deb02ba1e---4</link>
            <guid isPermaLink="false">https://medium.com/p/236034946f51</guid>
            <category><![CDATA[emoji]]></category>
            <category><![CDATA[php]]></category>
            <dc:creator><![CDATA[Himphen Hui]]></dc:creator>
            <pubDate>Mon, 18 Apr 2016 08:20:00 GMT</pubDate>
            <atom:updated>2016-04-18T08:19:47.887Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<p>Just get the error message and empty cells when I opened the xlsx file created by PHPExcel. After the investigation, I found that some users enter emoji into their user bios and user name.</p><p>Here is the simple function that can remove the emoji characters in the string incase you need to export the data to Excel file with emoji characters(including Dingbats and Miscellaneous Symbols).</p><pre>function remove_emoji($string) {<br><br>    // Match Emoticons<br>    $regex_emoticons = &#39;/[\x{1F600}-\x{1F64F}]/u&#39;;<br>    $clear_string = preg_replace($regex_emoticons, &#39;&#39;, $string);<br><br>    // Match Miscellaneous Symbols and Pictographs<br>    $regex_symbols = &#39;/[\x{1F300}-\x{1F5FF}]/u&#39;;<br>    $clear_string = preg_replace($regex_symbols, &#39;&#39;, $clear_string);<br><br>    // Match Transport And Map Symbols<br>    $regex_transport = &#39;/[\x{1F680}-\x{1F6FF}]/u&#39;;<br>    $clear_string = preg_replace($regex_transport, &#39;&#39;, $clear_string);<br><br>    // Match Miscellaneous Symbols<br>    $regex_misc = &#39;/[\x{2600}-\x{26FF}]/u&#39;;<br>    $clear_string = preg_replace($regex_misc, &#39;&#39;, $clear_string);<br><br>    // Match Dingbats<br>    $regex_dingbats = &#39;/[\x{2700}-\x{27BF}]/u&#39;;<br>    $clear_string = preg_replace($regex_dingbats, &#39;&#39;, $clear_string);<br><br>    return $clear_string;<br>}</pre><p>Ref: <a href="http://stackoverflow.com/questions/12807176/php-writing-a-simple-removeemoji-function">PHP : writing a simple removeEmoji function</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=236034946f51" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coding-cheatsheet/remove-emoji-characters-in-php-236034946f51">Remove Emoji Characters in PHP</a> was originally published in <a href="https://medium.com/coding-cheatsheet">Coding Cheatsheet</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How To Install Apache MySQL and PHP (with phpMyAdmin) on Amazon Linux/CentOS/RHEL]]></title>
            <link>https://medium.com/coding-cheatsheet/how-to-install-apache-mysql-and-php-with-phpmyadmin-on-amazon-linux-centos-rhel-60cd46b2adc7?source=rss----fd7deb02ba1e---4</link>
            <guid isPermaLink="false">https://medium.com/p/60cd46b2adc7</guid>
            <category><![CDATA[lamp]]></category>
            <category><![CDATA[centos]]></category>
            <dc:creator><![CDATA[Himphen Hui]]></dc:creator>
            <pubDate>Tue, 16 Feb 2016 17:43:04 GMT</pubDate>
            <atom:updated>2016-02-22T08:16:03.385Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-sa/4.0/</cc:license>
            <content:encoded><![CDATA[<h3>Install LAMP</h3><p><strong>LAMP</strong> stands for Linux, Apache, MySQL, and PHP.</p><h4>Install Remi/EPEL Repository</h4><p>EPEL release package is available under default CentOS repositories. Install<strong> </strong>EPEL Repository with following command:</p><pre>CentOS/RHEL 7, 64-Bit:<br># rpm -Uvh http://download.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm<br># rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm</pre><pre>CentOS/RHEL 6, 32 Bit:<br># rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm<br># rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm</pre><pre>CentOS/RHEL 6, 64 Bit:<br># rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm<br># rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm</pre><h4>Install Apache ( httpd ) using Yum</h4><p>After adding EPEL and Remi repository in server, you can use the following command to install Apache.</p><pre>Apache 2.2:<br># yum --enablerepo=remi install httpd</pre><pre>Apache 2.4:<br># yum --enablerepo=remi install httpd24</pre><h4>Install MySQL using Yum</h4><p>Lets use following command to install MySQL server on your system</p><pre># yum --enablerepo=remi install mysql mysql-server</pre><p>After installing MySQL server, start the service and execute following commands for applying initial installation:</p><pre># service mysqld start<br># /usr/bin/mysql_secure_installation</pre><h4>Install PHP 5.6 using Yum</h4><p>After completing installation of Apache and MySQL, you can use the following command to install PHP 5.6.</p><pre># yum --enablerepo=remi install php56 php56-common php56-cli php56-mysql php56-devel</pre><h4>Start Services</h4><p>Finally start Apache and MySQL services using following commands and setup them to auto start on system boot.</p><pre># service httpd restart<br># chkconfig httpd on<br># service mysqld restart<br># chkconfig mysqld on</pre><h3>Bonus 1: Install phpMyAdmin</h3><p>Install phpMyAdmin using yum package manager. All the dependencies will automatically be installed.</p><pre># yum --enablerepo=remi install phpMyAdmin</pre><h4>Configure phpMyAdmin</h4><p>phpMyAdmin by default allowed to access from localhost only. If you want to make it accessible from remote computers edit /etc/httpd/conf.d/phpMyAdmin.conf.</p><pre># vim /etc/httpd/conf.d/phpMyAdmin.conf</pre><p>To allow remote access you need to add 1 line to the 2.4 config block or change 2 lines in the 2.2 (depending on your apache version):</p><pre>Alias /phpMyAdmin /usr/share/phpMyAdmin<br>Alias /phpmyadmin /usr/share/phpMyAdmin</pre><pre>&lt;Directory /usr/share/phpMyAdmin/&gt;<br>   AddDefaultCharset UTF-8</pre><pre>   &lt;IfModule mod_authz_core.c&gt;<br>     # Apache 2.4<br>     &lt;RequireAny&gt;<br>       # ADD following line<br>       <strong>Require all granted</strong><br>       Require ip 127.0.0.1<br>       Require ip ::1<br>     &lt;/RequireAny&gt;<br>   &lt;/IfModule&gt;<br>   &lt;IfModule !mod_authz_core.c&gt;<br>     # Apache 2.2<br>     # CHANGE following 2 lines<br>     <strong>Order Allow,Deny<br>     Allow from All</strong><br>     Allow from 127.0.0.1<br>     Allow from ::1<br>   &lt;/IfModule&gt;<br>&lt;/Directory&gt;</pre><pre>&lt;Directory /usr/share/phpMyAdmin/libraries/&gt;<br>    Order Deny,Allow<br>    Deny from All<br>    Allow from None<br>&lt;/Directory&gt;</pre><pre>&lt;Directory /usr/share/phpMyAdmin/setup/lib/&gt;<br>    Order Deny,Allow<br>    Deny from All<br>    Allow from None<br>&lt;/Directory&gt;</pre><pre>&lt;Directory /usr/share/phpMyAdmin/setup/frames/&gt;<br>    Order Deny,Allow<br>    Deny from All<br>    Allow from None<br>&lt;/Directory&gt;</pre><p>After updating phpMyAdmin Apache configuration file, restart Apache service to reload new settings.</p><pre># service httpd restart</pre><p>Now you can access phpMyAdmin in browser using following url. Change domain name with your server IP.</p><pre><a href="http://svr1.tecadmin.net/phpMyAdmin/">http://www.examplae.com/phpMyAdmin/</a></pre><pre>Login Details: Use MySQL username and password.</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=60cd46b2adc7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coding-cheatsheet/how-to-install-apache-mysql-and-php-with-phpmyadmin-on-amazon-linux-centos-rhel-60cd46b2adc7">How To Install Apache MySQL and PHP (with phpMyAdmin) on Amazon Linux/CentOS/RHEL</a> was originally published in <a href="https://medium.com/coding-cheatsheet">Coding Cheatsheet</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How To Install npm(Node.js) on Amazon Linux/CentOS/RHEL]]></title>
            <link>https://medium.com/coding-cheatsheet/how-to-install-npm-node-js-on-amazon-linux-centos-rhel-c918bbcd62b2?source=rss----fd7deb02ba1e---4</link>
            <guid isPermaLink="false">https://medium.com/p/c918bbcd62b2</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[linux]]></category>
            <dc:creator><![CDATA[Himphen Hui]]></dc:creator>
            <pubDate>Tue, 16 Feb 2016 17:42:42 GMT</pubDate>
            <atom:updated>2016-02-16T17:37:34.697Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-sa/4.0/</cc:license>
            <content:encoded><![CDATA[<h3>Install npm</h3><p><strong>npm</strong> is a command-line tool for interacting with a huge repository of Node.js projects.</p><h4>Install Remi/EPEL Repository</h4><pre>CentOS/RHEL 6, 32 Bit:<br># rpm -Uvh <a href="http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm">http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm</a><br># rpm -Uvh <a href="http://rpms.famillecollet.com/enterprise/remi-release-6.rpm">http://rpms.famillecollet.com/enterprise/remi-release-6.rpm</a> </pre><pre>CentOS/RHEL 6, 64 Bit:<br># rpm -Uvh <a href="http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm">http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm</a><br># rpm -Uvh <a href="http://rpms.famillecollet.com/enterprise/remi-release-6.rpm">http://rpms.famillecollet.com/enterprise/remi-release-6.rpm</a></pre><p>You will now be able to install with the command:</p><pre># yum -y install nodejs npm --enablerepo=epel</pre><p>All dependencies should be resolved automatically.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c918bbcd62b2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coding-cheatsheet/how-to-install-npm-node-js-on-amazon-linux-centos-rhel-c918bbcd62b2">How To Install npm(Node.js) on Amazon Linux/CentOS/RHEL</a> was originally published in <a href="https://medium.com/coding-cheatsheet">Coding Cheatsheet</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How To using phpMyAdmin to administer Amazon RDS]]></title>
            <link>https://medium.com/coding-cheatsheet/how-to-using-phpmyadmin-to-administer-amazon-rds-e2019aec1251?source=rss----fd7deb02ba1e---4</link>
            <guid isPermaLink="false">https://medium.com/p/e2019aec1251</guid>
            <category><![CDATA[phpmyadmin]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Himphen Hui]]></dc:creator>
            <pubDate>Tue, 16 Feb 2016 17:42:29 GMT</pubDate>
            <atom:updated>2020-01-23T15:42:28.692Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-sa/4.0/</cc:license>
            <content:encoded><![CDATA[<h3>Before You Start: Install phpMyAdmin</h3><p>Install phpMyAdmin using the yum package manager. All the dependencies will automatically be installed.</p><p>Please check <a href="https://medium.com/coding-cheatsheet/how-to-install-apache-mysql-and-php-with-phpmyadmin-on-amazon-linux-centos-rhel-60cd46b2adc7#.vpil8239b">this link</a> to install phpMyAdmin.</p><h3>Edit phpMyAdmin Config</h3><p>phpMyAdmin by default allowed to access the localhost database only. If you want to make it administer remote servers, please edit /etc/phpMyAdmin/config.inc.php.</p><pre># vim /etc/phpMyAdmin/config.inc.php</pre><p>As Amazon RDS, you need to add the following lines after the block of localhost config.</p><pre>$i++;<br>$cfg[&#39;Servers&#39;][$i][&#39;host&#39;] = &#39;xxxxxxxxxxxx.ap-northeast-1.rds.amazonaws.com&#39;;<br>$cfg[&#39;Servers&#39;][$i][&#39;port&#39;] = &#39;3306&#39;;<br>$cfg[&#39;Servers&#39;][$i][&#39;socket&#39;] = &#39;&#39;;<br>$cfg[&#39;Servers&#39;][$i][&#39;connect_type&#39;] = &#39;tcp&#39;;<br>$cfg[&#39;Servers&#39;][$i][&#39;extension&#39;] = &#39;mysqli&#39;;<br>$cfg[&#39;Servers&#39;][$i][&#39;auth_type&#39;] = &#39;cookie&#39;;</pre><p>Now you can access phpMyAdmin and choose your host.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e2019aec1251" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coding-cheatsheet/how-to-using-phpmyadmin-to-administer-amazon-rds-e2019aec1251">How To using phpMyAdmin to administer Amazon RDS</a> was originally published in <a href="https://medium.com/coding-cheatsheet">Coding Cheatsheet</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>