<?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[Stories by Yu-Cheng Hung on Medium]]></title>
        <description><![CDATA[Stories by Yu-Cheng Hung on Medium]]></description>
        <link>https://medium.com/@rommelhong?source=rss-f9480375c374------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*GeRxKcDrIo-RSU_mx9qDNQ.jpeg</url>
            <title>Stories by Yu-Cheng Hung on Medium</title>
            <link>https://medium.com/@rommelhong?source=rss-f9480375c374------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 11:12:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rommelhong/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Replace python2 with python3 in Debian]]></title>
            <link>https://rommelhong.medium.com/replace-python2-with-python3-in-debian-55144fa62130?source=rss-f9480375c374------2</link>
            <guid isPermaLink="false">https://medium.com/p/55144fa62130</guid>
            <category><![CDATA[debian]]></category>
            <category><![CDATA[python2]]></category>
            <category><![CDATA[python3]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Yu-Cheng Hung]]></dc:creator>
            <pubDate>Tue, 31 May 2022 02:09:27 GMT</pubDate>
            <atom:updated>2022-05-31T02:09:27.778Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Remove python2</strong></p><pre>sudo apt purge -y python2.7-minimal</pre><p><strong>With python3 already</strong></p><pre>sudo ln -s /usr/bin/python3 /usr/bin/python</pre><p><strong>pip</strong></p><pre>sudo apt install -y python3-pip<br>sudo ln -s /usr/bin/pip3 /usr/bin/pip</pre><p><strong>Confirm currently version of python</strong></p><pre>python --version</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=55144fa62130" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Git: 如何從遠端拉取連結建立本地端尚未存在的branch以及如何合併特定檔案至指定branch]]></title>
            <link>https://rommelhong.medium.com/git-%E5%A6%82%E4%BD%95%E5%BE%9E%E9%81%A0%E7%AB%AF%E6%8B%89%E5%8F%96%E9%80%A3%E7%B5%90%E5%BB%BA%E7%AB%8B%E6%9C%AC%E5%9C%B0%E7%AB%AF%E5%B0%9A%E6%9C%AA%E5%AD%98%E5%9C%A8%E7%9A%84branch%E4%BB%A5%E5%8F%8A%E5%A6%82%E4%BD%95%E5%90%88%E4%BD%B5%E7%89%B9%E5%AE%9A%E6%AA%94%E6%A1%88%E8%87%B3%E6%8C%87%E5%AE%9Abranch-f826bf279555?source=rss-f9480375c374------2</link>
            <guid isPermaLink="false">https://medium.com/p/f826bf279555</guid>
            <category><![CDATA[github]]></category>
            <dc:creator><![CDATA[Yu-Cheng Hung]]></dc:creator>
            <pubDate>Thu, 23 Dec 2021 07:36:23 GMT</pubDate>
            <atom:updated>2021-12-23T07:36:23.696Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/318/1*IQ0FP41w0LbeQLKu0rpBOA.png" /><figcaption>Reference: <a href="https://icon-icons.com/icon/git-scm-logo/170097">https://icon-icons.com/icon/git-scm-logo/170097</a></figcaption></figure><p><strong>情境</strong></p><p>遠端branches:</p><p>master, develop, feature-a</p><p>本地端branches:</p><p>develop, feature-a</p><p>當初pull專案到本地端後，整理branch時不小心把master砍掉，後面開發時都是在遠端做feature合併到develop再合併到master，因此也就一直放著沒處理，然而今天遇到一個情況是，feature-a有5個新commits，也已經合併到develop，但暫時還不想全部合併到master，只想合併commit中的一個檔案到master。</p><p><strong>作法</strong></p><p>一、拉取遠端master至本地端</p><p>因為需要與遠端同步，所以並不能直接在本地端執行：</p><pre>git checkout master</pre><p>這樣做會直接同步你本地端的某一分支(看你切換在哪)的程式碼，而我們目前是希望建立一個與遠端master同步的branch：</p><pre>git checkout -b master origin/master</pre><p>倘若出現類似的error msg：</p><pre>fatal: &#39;origin/master&#39; is not a commit and a branch &#39;master&#39; cannot be created from it</pre><p>可以嘗試執行：</p><pre>git fetch --all</pre><p>這邊如果出現https驗證輸入帳密但又驗證失敗的話，請改ssh key驗證並且：</p><pre>git remote set-url origin {your repository SSH URL}</pre><p>如果驗證成功但是建立branch還是失敗，可嘗試：</p><pre>git remote set-branches --add &#39;origin&#39; &#39;master&#39;</pre><p>然後：</p><pre>git fetch &#39;origin&#39;</pre><p>再執行：</p><pre>git checkout --track &#39;origin/master&#39;</pre><p>成功訊息：</p><pre>Switched to a new branch &#39;master&#39;<br>Branch &#39;master&#39; set up to track remote branch &#39;master&#39; from &#39;origin&#39;.</pre><p>可用 git log確認一下同步狀況。</p><p>二、合併develop的特定檔案至master</p><p>因為這些commit都有牽扯到其他檔案的修改，所以並不考慮cherry-pick。</p><p>1.切換到你想要合併的目標分支 (master)：</p><pre>git checkout master</pre><p>2.選擇特定檔案 (testfile1.php)和特定分支 (develop)：</p><pre>git checkout develop testfile1.php</pre><p>3.確認狀態：</p><pre>git status</pre><p>4.沒問題即可commit：</p><pre>git commit -m &quot;{ your commit message }&quot;</pre><p>參考資料</p><ol><li><a href="https://www.796t.com/post/OTEyaWE=.html">【GIT】如何在git中合併特定檔案</a></li><li><a href="https://stackoverflow.com/questions/49297153/why-is-it-not-a-commit-and-a-branch-cannot-be-created-from-it">Why is it not a commit and a branch cannot be created from it?</a></li><li><a href="https://www.itread01.com/content/1545631571.html">git獲取遠端伺服器的指定分支</a></li><li><a href="https://chouandy.pixnet.net/blog/post/243176867-%E5%9C%A8-git-%E4%B8%AD%E4%BD%BF%E7%94%A8-ssh-key-push-%E6%88%96-pull-repository">在 Git 中使用 SSH Key Push 或 Pull Repository</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f826bf279555" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[在Laravel 8 REST API中應用JSON Web Token (JWT)]]></title>
            <link>https://rommelhong.medium.com/%E5%9C%A8laravel-8-rest-api%E4%B8%AD%E6%87%89%E7%94%A8json-web-token-jwt-6318fa57ba46?source=rss-f9480375c374------2</link>
            <guid isPermaLink="false">https://medium.com/p/6318fa57ba46</guid>
            <category><![CDATA[laravel8]]></category>
            <category><![CDATA[jwt]]></category>
            <dc:creator><![CDATA[Yu-Cheng Hung]]></dc:creator>
            <pubDate>Wed, 03 Mar 2021 09:27:15 GMT</pubDate>
            <atom:updated>2021-03-03T09:27:15.726Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/335/1*7imYpOKGppo7TX3giUK2OA.png" /></figure><p>各位讀者們好，前陣子Laravel更新至8版且有讀者詢問是否有相關的JWT應用範例，因此我也試著研究了一下在Laravel 8中如何應用JWT驗證，算是承接前篇文章 – <a href="https://rommelhong.medium.com/%E5%9C%A8laravel-6-rest-api%E4%B8%AD%E6%87%89%E7%94%A8json-web-token-jwt-e067e7fc7b1f">在Laravel 6 REST API中應用JSON Web Token (JWT)</a> ，那麼就開始本次的內容吧！</p><p>首先建立一個全新的 Laravel 8 project</p><pre>composer create-project laravel/laravel laravel-jwt-auth --prefer-dist</pre><p>在MySQL中新建一個 database: laravel_db</p><p>並且修改 .env 檔案中的 db 名稱(名稱可自由設定)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/255/1*H2H4TICD8KxJjL_FvCnXwA.png" /></figure><p>執行 migration</p><pre>php artisan migrate</pre><p>此時查看db，應會是如下的結構(此為HeidiSQL)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/296/1*iy0sI2U0EUA59ryL1XMlNg.png" /></figure><p>接著安裝 jwt package</p><pre>composer require tymon/jwt-auth</pre><p>完成後至 config/app.php 將 laravel service provider 和 JWTAuth、JWTFactory include 進去</p><pre>&#39;providers&#39; =&gt; [<br>    ....<br>    ....<br>    Tymon\JWTAuth\Providers\LaravelServiceProvider::class,<br>],<br>&#39;aliases&#39; =&gt; [<br>    ....<br>    &#39;JWTAuth&#39; =&gt; Tymon\JWTAuth\Facades\JWTAuth::class,<br>    &#39;JWTFactory&#39; =&gt; Tymon\JWTAuth\Facades\JWTFactory::class,<br>    ....<br>],</pre><p>設定 config/jwt.php</p><pre>php artisan vendor:publish --provider=&quot;Tymon\JWTAuth\Providers\LaravelServiceProvider&quot;</pre><p>產生 secret key</p><pre>php artisan jwt:secret</pre><p>成功後可在 .env 中看到如下的畫面</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/830/1*-688Xwa2NJ0pU5ocziTtXA.png" /></figure><p>修改 app/Models/User.php，加入兩個function：getJWTIdentifier() 和 getJWTCustomClaims()</p><pre>&lt;?php</pre><pre>namespace App\Models;</pre><pre>use Illuminate\Contracts\Auth\MustVerifyEmail;<br>use Illuminate\Database\Eloquent\Factories\HasFactory;<br>use Illuminate\Foundation\Auth\User as Authenticatable;<br>use Illuminate\Notifications\Notifiable;</pre><pre>use Tymon\JWTAuth\Contracts\JWTSubject;</pre><pre>class User extends Authenticatable implements JWTSubject<br>{<br>    use HasFactory, Notifiable;</pre><pre>/**<br>     * The attributes that are mass assignable.<br>     *<br>     * <a href="http://twitter.com/var">@var</a> array<br>     */<br>    protected $fillable = [<br>        &#39;name&#39;,<br>        &#39;email&#39;,<br>        &#39;password&#39;,<br>    ];</pre><pre>/**<br>     * The attributes that should be hidden for arrays.<br>     *<br>     * <a href="http://twitter.com/var">@var</a> array<br>     */<br>    protected $hidden = [<br>        &#39;password&#39;,<br>        &#39;remember_token&#39;,<br>    ];</pre><pre>/**<br>     * The attributes that should be cast to native types.<br>     *<br>     * <a href="http://twitter.com/var">@var</a> array<br>     */<br>    protected $casts = [<br>        &#39;email_verified_at&#39; =&gt; &#39;datetime&#39;,<br>    ];<br>    <br>    /**<br>     * Get the identifier that will be stored in the subject claim of the JWT.<br>     *<br>     * <a href="http://twitter.com/return">@return</a> mixed<br>     */<br>    public function getJWTIdentifier() {<br>        return $this-&gt;getKey();<br>    }</pre><pre>/**<br>     * Return a key value array, containing any custom claims to be added to the JWT.<br>     *<br>     * <a href="http://twitter.com/return">@return</a> array<br>     */<br>    public function getJWTCustomClaims() {<br>        return [];<br>    }    <br>}</pre><p>注意上方要use JWTSubject，class 宣告時要 implements JWTSubject</p><p>接著修改 config/auth.php</p><pre>&lt;?php</pre><pre>return [</pre><pre>&#39;defaults&#39; =&gt; [<br>        &#39;guard&#39; =&gt; &#39;api&#39;,<br>        &#39;passwords&#39; =&gt; &#39;users&#39;,<br>    ],</pre><pre>&#39;guards&#39; =&gt; [<br>        &#39;web&#39; =&gt; [<br>            &#39;driver&#39; =&gt; &#39;session&#39;,<br>            &#39;provider&#39; =&gt; &#39;users&#39;,<br>        ],</pre><pre>&#39;api&#39; =&gt; [<br>            &#39;driver&#39; =&gt; &#39;jwt&#39;,<br>            &#39;provider&#39; =&gt; &#39;users&#39;,<br>            &#39;hash&#39; =&gt; false,<br>        ],<br>    ],</pre><p>建立 Authentication Controller</p><pre>php artisan make:controller AuthController</pre><p>將下列 functions 加入 app/Http/Controllers/AuthController.php</p><pre>&lt;?php</pre><pre>namespace App\Http\Controllers;<br>use Illuminate\Http\Request;</pre><pre>use Illuminate\Support\Facades\Auth;<br>use App\Models\User;<br>use Validator;</pre><pre>class AuthController extends Controller<br>{<br>    /**<br>     * Create a new AuthController instance.<br>     *<br>     * <a href="http://twitter.com/return">@return</a> void<br>     */<br>    public function __construct() {<br>        $this-&gt;middleware(&#39;auth:api&#39;, [&#39;except&#39; =&gt; [&#39;login&#39;, &#39;register&#39;]]);<br>    }</pre><pre>/**<br>     * Get a JWT via given credentials.<br>     *<br>     * <a href="http://twitter.com/return">@return</a> \Illuminate\Http\JsonResponse<br>     */<br>    public function login(Request $request){<br>     $validator = Validator::make($request-&gt;all(), [<br>            &#39;email&#39; =&gt; &#39;required|email&#39;,<br>            &#39;password&#39; =&gt; &#39;required|string|min:6&#39;,<br>        ]);</pre><pre>if ($validator-&gt;fails()) {<br>            return response()-&gt;json($validator-&gt;errors(), 422);<br>        }</pre><pre>if (! $token = auth()-&gt;attempt($validator-&gt;validated())) {<br>            return response()-&gt;json([&#39;error&#39; =&gt; &#39;Unauthorized&#39;], 401);<br>        }</pre><pre>return $this-&gt;createNewToken($token);<br>    }</pre><pre>/**<br>     * Register a User.<br>     *<br>     * <a href="http://twitter.com/return">@return</a> \Illuminate\Http\JsonResponse<br>     */<br>    public function register(Request $request) {<br>        $validator = Validator::make($request-&gt;all(), [<br>            &#39;name&#39; =&gt; &#39;required|string|between:2,100&#39;,<br>            &#39;email&#39; =&gt; &#39;required|string|email|max:100|unique:users&#39;,<br>            &#39;password&#39; =&gt; &#39;required|string|confirmed|min:6&#39;,<br>        ]);</pre><pre>if($validator-&gt;fails()){<br>            return response()-&gt;json($validator-&gt;errors()-&gt;toJson(), 400);<br>        }</pre><pre>$user = User::create(array_merge(<br>                    $validator-&gt;validated(),<br>                    [&#39;password&#39; =&gt; bcrypt($request-&gt;password)]<br>                ));</pre><pre>return response()-&gt;json([<br>            &#39;message&#39; =&gt; &#39;User successfully registered&#39;,<br>            &#39;user&#39; =&gt; $user<br>        ], 201);<br>    }</pre><pre>/**<br>     * Log the user out (Invalidate the token).<br>     *<br>     * <a href="http://twitter.com/return">@return</a> \Illuminate\Http\JsonResponse<br>     */<br>    public function logout() {<br>        auth()-&gt;logout();</pre><pre>return response()-&gt;json([&#39;message&#39; =&gt; &#39;User successfully signed out&#39;]);<br>    }</pre><pre>/**<br>     * Refresh a token.<br>     *<br>     * <a href="http://twitter.com/return">@return</a> \Illuminate\Http\JsonResponse<br>     */<br>    public function refresh() {<br>        return $this-&gt;createNewToken(auth()-&gt;refresh());<br>    }</pre><pre>/**<br>     * Get the authenticated User.<br>     *<br>     * <a href="http://twitter.com/return">@return</a> \Illuminate\Http\JsonResponse<br>     */<br>    public function userProfile() {<br>        return response()-&gt;json(auth()-&gt;user());<br>    }</pre><pre>/**<br>     * Get the token array structure.<br>     *<br>     * <a href="http://twitter.com/param">@param</a>  string $token<br>     *<br>     * <a href="http://twitter.com/return">@return</a> \Illuminate\Http\JsonResponse<br>     */<br>    protected function createNewToken($token){<br>        return response()-&gt;json([<br>            &#39;access_token&#39; =&gt; $token,<br>            &#39;token_type&#39; =&gt; &#39;bearer&#39;,<br>            &#39;expires_in&#39; =&gt; auth()-&gt;factory()-&gt;getTTL() * 60,<br>            &#39;user&#39; =&gt; auth()-&gt;user()<br>        ]);<br>    }</pre><pre>}</pre><p>設定 routes/api.phproutes/api.php</p><pre>&lt;?php</pre><pre>use Illuminate\Http\Request;<br>use Illuminate\Support\Facades\Route;<br>use App\Http\Controllers\AuthController;</pre><pre>/*<br>|--------------------------------------------------------------------------<br>| API Routes<br>|--------------------------------------------------------------------------<br>|<br>| Here is where you can register API routes for your application. These<br>| routes are loaded by the RouteServiceProvider within a group which<br>| is assigned the &quot;api&quot; middleware group. Enjoy building your API!<br>|<br>*/</pre><pre>Route::group([<br>    &#39;middleware&#39; =&gt; &#39;api&#39;,<br>    &#39;prefix&#39; =&gt; &#39;auth&#39;</pre><pre>], function ($router) {<br>    Route::post(&#39;/login&#39;, [AuthController::class, &#39;login&#39;]);<br>    Route::post(&#39;/register&#39;, [AuthController::class, &#39;register&#39;]);<br>    Route::post(&#39;/logout&#39;, [AuthController::class, &#39;logout&#39;]);<br>    Route::post(&#39;/refresh&#39;, [AuthController::class, &#39;refresh&#39;]);<br>    Route::get(&#39;/user-profile&#39;, [AuthController::class, &#39;userProfile&#39;]);    <br>});</pre><p>以上就是設定和修改的部分，接著用 Postman 來進行行為測試</p><p>讀者們可選擇用 php artisan serve 或者 xampp 的方式啟動專案，筆者這邊選擇用 xampp 並設定 port 為 1106</p><p>測試一：使用者註冊</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*arh2C0s9S5eHRA6KUHRi2g.png" /></figure><p>測試二：使用者登入，登入成功即回應 access token</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GPV1Sz6ZYkA7sYKKvyKkXQ.png" /></figure><p>測試三：以 JWT token 取得user profile</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3oGKrpH3-nmR2pP_p_FTlQ.png" /></figure><p>測試四：更新 JWT token，取得綠框中新的 token</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*INRE0XtNWarZGYutVSIdAg.png" /></figure><p>測試五：使用者登出，移除 JWT token</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wd1X0NzOiimy8Ffrqb-pMA.png" /></figure><p>以上就是測試的方式及畫面，完整程式碼github如下：</p><p><a href="https://github.com/rommelhong/jwt-laravel8">https://github.com/rommelhong/jwt-laravel8</a></p><p>本篇內容參考：<a href="https://www.positronx.io/laravel-jwt-authentication-tutorial-user-login-signup-api/">https://www.positronx.io/laravel-jwt-authentication-tutorial-user-login-signup-api/</a></p><p>謝謝大家！</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6318fa57ba46" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[解決使用Postman測試Laravel 6 POST Request時遇到419 Unknown Status的錯誤]]></title>
            <link>https://rommelhong.medium.com/%E8%A7%A3%E6%B1%BA%E4%BD%BF%E7%94%A8postman%E6%B8%AC%E8%A9%A6laravel-6-post-request%E6%99%82%E9%81%87%E5%88%B0419-unknown-status%E7%9A%84%E9%8C%AF%E8%AA%A4-c81ecab8ce06?source=rss-f9480375c374------2</link>
            <guid isPermaLink="false">https://medium.com/p/c81ecab8ce06</guid>
            <category><![CDATA[post]]></category>
            <category><![CDATA[laravel-6]]></category>
            <category><![CDATA[419]]></category>
            <category><![CDATA[ajax]]></category>
            <dc:creator><![CDATA[Yu-Cheng Hung]]></dc:creator>
            <pubDate>Tue, 17 Nov 2020 08:30:46 GMT</pubDate>
            <atom:updated>2020-11-17T08:30:46.337Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a0Bd5Bk6BY4S5SM1E5oJGw.jpeg" /><figcaption>From: <a href="https://morioh.com/p/1d212a3be479">https://morioh.com/p/1d212a3be479</a></figcaption></figure><p>嗨大家好，最近又到了計畫結案的階段，筆者在解決OWASP針對計畫官網進行資安弱掃的風險漏洞時，使用了Postman來測試Ajax Post Request Method的Response，這時遇到了Laravel Post CSRF Token的老問題，在此將解法做個紀錄分享給有需要的朋友們。</p><p>這邊我用searchNews這個Post Method當作例子，需要的參數有 filter和 type，前者資料型態為 string，後者則為 int，此時若直接Send出去則會收到419 unknown status的回傳狀態：</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qea1QpPyya-c6ygetR7wAg.png" /></figure><p>這時我們只需要在Headers中帶入CSRF Token做驗證即可解決這個問題，筆者的做法如下，先寫一個Get Method去取得CSRF Token：</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/1*2el-Onruqvn4Pnm6FN2B3A.png" /></figure><p>設定Route，我的Controller命名為 HomeController：</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yV49YsQ9Ranz329V8OtBQQ.png" /></figure><p>用Postman執行並取得CSRF Token：</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*np0jA7rKZ07nJhqJuUqJhg.png" /></figure><p>回到searchNews並在Headers中加入 X-CSRF-TOKEN和剛才取得的CSRF Token值：</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qZnUdDQORJbJ7rrN0IZZZw.png" /></figure><p>重新Send後即可成功取得資料：</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_yUgNiWuh9B0cS7KrOdPZg.png" /></figure><p>那這次的分享就到這裡，希望可以幫助到大家，歡迎分享交流！</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c81ecab8ce06" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Let’s Encrypt SSL憑證更新錯誤排除(Ubuntu 18.04 LTS + Apache 2)]]></title>
            <link>https://rommelhong.medium.com/lets-encrypt-ssl%E6%86%91%E8%AD%89%E6%9B%B4%E6%96%B0%E9%8C%AF%E8%AA%A4%E6%8E%92%E9%99%A4-ubuntu-18-04-lts-apache-2-3f167be0c402?source=rss-f9480375c374------2</link>
            <guid isPermaLink="false">https://medium.com/p/3f167be0c402</guid>
            <category><![CDATA[ubuntu-18]]></category>
            <category><![CDATA[lets-encrypt]]></category>
            <dc:creator><![CDATA[Yu-Cheng Hung]]></dc:creator>
            <pubDate>Thu, 16 Apr 2020 10:01:34 GMT</pubDate>
            <atom:updated>2020-04-16T10:01:34.654Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IHqe0U1fGG4Eu3FBAJtdYA.jpeg" /><figcaption>引用：<a href="https://blog.256pages.com/nginx-nodejs-letsencrypt-update/">https://blog.256pages.com/nginx-nodejs-letsencrypt-update/</a></figcaption></figure><p>嗨大家好，有在關注筆者的朋友們想必都已經看過這篇文章：<a href="https://medium.com/@rommelhong/%E5%9C%A8ubuntu-18-04-lts-apache-2%E4%B8%AD%E5%AE%89%E8%A3%9D%E4%BD%BF%E7%94%A8lets-encrypt-ssl%E6%86%91%E8%AD%89-d2957a0b070f">在Ubuntu 18.04 LTS + Apache 2中安裝使用Let’s Encrypt SSL憑證</a> ，一轉眼九十天的效期即將過去，又到了要自動更新憑證的時候了，雖然說當初有設定使用Certbot這個方便的管理套件來自動更新，但畢竟筆者是第一次設定這個憑證，還是想手動確定一下是否能正常更新，於是先執行以下指令看看狀態：</p><pre>$sudo systemctl status certbot.timer</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eP5BmpLExAOyg91yKMHeag.png" /></figure><p>恩恩看起來沒問題，那麼就執行以下指令進行更新吧！</p><pre>$ sudo certbot renew --dry-run</pre><p>……沒想到居然直接噴錯！</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JbaVJnFGcKZpNUOYP9Q-OQ.png" /></figure><p>當下一陣緊張，畢竟這是組內很重要的計畫官網，不過定下神一看，立刻看到訊息中顯示的錯誤警告訊息(紅色字體)，恩恩…缺少nginx套件！可是我已經改成apache2了呀，此時想到當初在產生檔案時曾經誤用nginx，就猜想可能是這個問題，同時也看到訊息提示設定檔案(紅框處)，立刻打開圖中的檔案查看內容：</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/1*0wl8OkAr1G-TmJ1esw-a4w.png" /></figure><p>果不其然，其中的設定還是為nginx，難怪更新時會去搜尋相關套件，但筆者當初已把nginx相關套件完全移除，所以才會報錯，知道問題後立刻進行修改：</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/984/1*HMz9CvohSBPMpJ-O4GLnZA.png" /></figure><p>再次運行更新：</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/664/1*w5_J3uA6hY3ncjy9ioHdGQ.png" /></figure><p>即可成功完成憑證更新！希望這篇能幫助到個位，謝謝收看！</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3f167be0c402" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ubuntu 18.04 解決遠端連線MySQL速度緩慢問題]]></title>
            <link>https://rommelhong.medium.com/ubuntu-18-04-%E8%A7%A3%E6%B1%BA%E9%81%A0%E7%AB%AF%E9%80%A3%E7%B7%9Amysql%E9%80%9F%E5%BA%A6%E7%B7%A9%E6%85%A2%E5%95%8F%E9%A1%8C-774ba875466b?source=rss-f9480375c374------2</link>
            <guid isPermaLink="false">https://medium.com/p/774ba875466b</guid>
            <category><![CDATA[mysql]]></category>
            <category><![CDATA[ubuntu]]></category>
            <dc:creator><![CDATA[Yu-Cheng Hung]]></dc:creator>
            <pubDate>Fri, 21 Feb 2020 09:36:37 GMT</pubDate>
            <atom:updated>2020-02-21T09:36:37.415Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X1qaYTfcBrvDz7SuHemC2w.png" /><figcaption>引用： <a href="https://zh.wikipedia.org/wiki/MySQL">https://zh.wikipedia.org/wiki/MySQL</a></figcaption></figure><p>嗨大家好，前陣子有同仁反應在遠端連線MySQL時連線速度緩慢，且在做資料匯入時也是，希望筆者能去Server端檢查看看，因此就上網搜尋有無相關問題的解決方法，最後也成功解決問題，在此做個紀錄分享給各位。</p><p>Ubuntu 18.04的MySQL的相關設定都在 etc/mysql/mysql.conf.d/mysqld.cnf中，打開來並在 [mysql_safe]下加入：</p><pre>skip-name-resolve</pre><p>儲存後重啟MySQL：</p><pre>$ sudo /etc/init.d/mysql restart</pre><p>這樣做後連線速度的確有提升，原因是MySQL預設在接受遠端連線時，會試圖去反向解析連線端的domain name，此時若解析失敗，會等待一段時間才會進行後續動作，因此可以加入上列程式碼關閉此預設，加速連線。</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=774ba875466b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[在Windows Server 2016中架設Laravel 6網站]]></title>
            <link>https://rommelhong.medium.com/%E5%9C%A8windows-server-2016%E4%B8%AD%E6%9E%B6%E8%A8%ADlaravel-6%E7%B6%B2%E7%AB%99-49802bd9c95f?source=rss-f9480375c374------2</link>
            <guid isPermaLink="false">https://medium.com/p/49802bd9c95f</guid>
            <category><![CDATA[windows-server-2016]]></category>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[xampp]]></category>
            <dc:creator><![CDATA[Yu-Cheng Hung]]></dc:creator>
            <pubDate>Fri, 07 Feb 2020 07:36:22 GMT</pubDate>
            <atom:updated>2020-02-07T07:36:22.620Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m4PMb0pvzUDw0Yx027sFyA.png" /><figcaption>引用： <a href="https://dotblogs.com.tw/itken/2017/01/22/windows-server-container">https://dotblogs.com.tw/itken/2017/01/22/windows-server-container</a></figcaption></figure><p>嗨各位讀者們好，這兩天筆者在建置新Laravel 6專案網站的VM Server環境，使用的是Windows Server 2016，因此遇到有滿多值得記錄下來的部分，各位若有相關的經驗歡迎交流分享。</p><h4>一、安裝XAMPP</h4><p>在<a href="https://medium.com/@rommelhong/laravel-6-%E4%B9%8B%E7%92%B0%E5%A2%83%E5%AE%89%E8%A3%9D%E8%88%87%E6%B3%A8%E6%84%8F%E4%BA%8B%E9%A0%85-33da98132cb2">Laravel 6 之環境安裝與注意事項</a>這篇文章中筆者表示在Windows建置Laravel 6開發環境很方便的懶人包是使用XAMPP，不過在正式上線環境中，phpMyAdmin是一個有資安風險的資料庫管控軟體，因此在安裝XAMPP時請不要勾選phpMyAdmin，並完成XAMPP安裝。</p><h4>擾人的坑點：</h4><p>不建議安裝phpMyAdmin更大的原因是，網路上有許多關於XAMPP中phpMyAdmin和MySQL的管理帳號密碼權限設定方式，但當你實地下去操作便會發現除了新版設定方式已有所改變外，phpMyAdmin在帳密設定這一塊寫得並不好，以圖形化介面做phpMyAdmin和MySQL的管理帳號密碼權限設定會使得錯誤訊息百出，而且又很難找出問題所在，因此還是建議各位直接進MySQL中以指令做設定，免得在彎路上越繞越遠…</p><h4>二、設定MySQL root及專案使用者帳號密碼</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*oEarSk0t9eNsUo33hPH63Q.png" /></figure><p>點擊Shell進入命令提示列，並以下列指令設定root密碼(預設root密碼為空)：</p><pre>mysqladmin -u root password &#39;your_password&#39;;</pre><p>新增一個專案使用者帳密：</p><pre>CREATE USER &#39;your_account&#39;@&#39;localhost&#39; IDENTIFIED BY &#39;your_password&#39;;</pre><p>賦予這個專案使用者管理特定db的權限：</p><pre>GRANT ALL PRIVILEGES ON your_db.* TO &#39;your_account&#39;@&#39;localhost&#39;;</pre><p>這邊推薦使用<a href="https://www.heidisql.com/">HeidiSQL</a>做資料庫管理，安裝使用上無任何學習曲線，以剛剛新設定好的使用者帳密登入管理即可。</p><h4>三、設定XAMPP於VM中持續執行</h4><p>目前筆者是以遠端桌面連線的方式進入VM操作，這邊會有一個問題是當連線中斷後，所有以我這個使用者帳號所執行的工作程序即會完全停止，顯然這樣的情形是不允許發生的，因此我們必須將XAMPP設定進入Server的工作排程中，以讓其持續運行。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T5V0eX2Bp0Za2gi_CbfsQA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nk0qtSHKXf0w-Ye3A11mNQ.png" /></figure><p>建立基本工作並且依個人需求做設定，成功後即可看到XAMPP存在於進行中工作列中。</p><p>接著請至XAMPP資料夾並以系統管理員身分執行xampp-controller，並將Apache和MySQL打勾：</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_VQmdaXiop8a_o6jB08FeQ.png" /></figure><p>以上即是關於Windows Server 2016中Laravel 6的環境架設，謝謝大家！</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=49802bd9c95f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ubuntu 16.04和Ubuntu 18.04設置DNS Nameservers]]></title>
            <link>https://rommelhong.medium.com/ubuntu-16-04%E5%92%8Cubuntu-18-04%E8%A8%AD%E7%BD%AEdns-nameservers-dd99425bb8f?source=rss-f9480375c374------2</link>
            <guid isPermaLink="false">https://medium.com/p/dd99425bb8f</guid>
            <category><![CDATA[ubuntu]]></category>
            <category><![CDATA[dns]]></category>
            <dc:creator><![CDATA[Yu-Cheng Hung]]></dc:creator>
            <pubDate>Fri, 31 Jan 2020 13:59:29 GMT</pubDate>
            <atom:updated>2020-01-31T15:01:34.525Z</atom:updated>
            <content:encoded><![CDATA[<h3>Ubuntu 16.04和Ubuntu 18.04設置DNS</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*0j5udfE7f6c3b2--9eN5hQ.jpeg" /><figcaption>引用： <a href="https://hostingserviceslab.com/choose-and-set-up-domain/">https://hostingserviceslab.com/choose-and-set-up-domain/</a></figcaption></figure><p>前陣子處理兩台Ubuntu Server間的相關設定，因為分別為16.04和18.04兩種版本，而Ubuntu在這兩種版本的設定方式剛好做了一次改版而有所不同，所以在這邊想做個跟DNS(Domain Name System)設定有關的紀錄，以供自己和大家日後參考。</p><h4>常用的DNS解析器</h4><p>Google：8.8.8.8, 8.8.4.4</p><p>Cloudflare：1.1.1.1, 1.0.0.1</p><p>OpenDNS：208.67.222.222, 208.67.220.220</p><p>Level3：209.244.0.3, 209.244.0.4</p><p>HiNet：168.95.1.1, 168.95.192.1</p><p>SeedNet：139.175.55.244, 139.175.150.20</p><p>PRIVATE：10.5.254.149, 10.5.254.150</p><h4>Ubuntu 16.04 DNS設定</h4><p>Ubuntu 16.04中有關IP連線等相關設定皆在 /etc/network/interfaces中：</p><pre>$ sudo vi /etc/network/interfaces</pre><p>在其中加入想套用的DNS nameserver(以Google為例)：</p><pre>dns-nameservers 8.8.8.8<br>dns-nameservers 8.8.4.4</pre><p>套用網路設定：</p><pre>$ sudo /etc/init.d/networking restart</pre><p>Ubuntu 18.04 DNS設定</p><p>Ubuntu 18.04中有關IP連線等設定改在/etc/netplan/01-netcfg.yaml中：</p><pre>$   sudo vi /etc/netplan/01-netcfg.yaml</pre><p>內容大概會長的如下所示，將想套用的DNS填入nameservers的address中：</p><pre>network: <br>    version: 2 <br>    renderer: networkd <br>    ethernets: <br>        ens3: <br>            dhcp4: no <br>            addresses: [192.168.121.199/24] <br>            gateway4: 192.168.121.1 <br>            nameservers: <br>                addresses: [8.8.8.8, 8.8.4.4]</pre><p>套用網路設定：</p><pre>$ sudo netplan apply</pre><p>查看當前DNS設定：</p><pre>$ systemd-resolve --status | grep &#39;DNS Servers&#39; -A2</pre><p>DNS更改後並不會立即生效，其生效時間受限於外部（ISP網路業者）DNS主機的更新時間，台灣本地約4 – 8小時，全球完全生效則需24 – 48小時。那麼今天的分享就到這邊，我們下次見。</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dd99425bb8f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[解決Ubuntu 16.04重啟錯誤：Kernel Panic — not syncing: VFS: Unable to mount root fs on unknown-block(0,0)]]></title>
            <link>https://rommelhong.medium.com/%E8%A7%A3%E6%B1%BAubuntu-16-04%E9%87%8D%E5%95%9F%E9%8C%AF%E8%AA%A4-kernel-panic-not-syncing-vfs-unable-to-mount-root-fs-on-unknown-block-0-0-34181fb3a84c?source=rss-f9480375c374------2</link>
            <guid isPermaLink="false">https://medium.com/p/34181fb3a84c</guid>
            <category><![CDATA[kernel]]></category>
            <category><![CDATA[ubuntu]]></category>
            <dc:creator><![CDATA[Yu-Cheng Hung]]></dc:creator>
            <pubDate>Fri, 24 Jan 2020 05:34:31 GMT</pubDate>
            <atom:updated>2020-01-24T05:34:31.270Z</atom:updated>
            <content:encoded><![CDATA[<h3>解決Ubuntu 16.04重啟錯誤：Kernel Panic — not syncing: VFS: Unable to mount root fs on unknown-block(0,0)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/825/1*bro3WnuQis_S6FWph_e51w.png" /><figcaption>引用： <a href="https://blog.csdn.net/tianzhaixing2013/article/details/79178495">https://blog.csdn.net/tianzhaixing2013/article/details/79178495</a></figcaption></figure><p>午安各位讀者們新年快樂！鼠年行大運！筆者前陣子在執行將新舊VM做IP轉換的工作，而IP轉換完畢後，Ubuntu 16.04版的這個舊server需要重新啟動才能完全棄掉舊的IP而使用新的IP(不重啟的話它會同時佔著新舊IP)，而Ubuntu 18.04則沒有這個問題，因此想當然耳，我就在Ubuntu 16.04版的舊server中下了重啟指令：</p><pre>$ sudo reboot</pre><p>結果就在重啟到一半時卡住並出現了以下的錯誤訊息(亦可參考首頁圖)：</p><pre>Kernel Panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)</pre><p>於是又開始求助估狗大神，但在試了好幾篇文章的解法後始終無法解決我自己的問題，最後總算找到正確步驟順序，因此在這分享給跟我遇到一樣問題的朋友，希望能幫助到你們。</p><p>首先會出現這個錯誤有很高機率是你的/boot空間已經滿載了，因此為了能先進入系統內做清理，我們第一步需要先將VM的電源關閉，稍等一下再重新啟動電源，此時會進入Ubuntu開機選單，大概會長的像下圖，請選擇Advanced options for Ubuntu的選項：</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*paNRY7YmNmpjHZognVN3uA.png" /></figure><p>進去後你會看到許多不同版本的內核清單，大概會如下圖所示，這時候就是很考驗人品的時候了，請選擇一個來開啟吧，記得不要選recovery mode：</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JmsbAfNbZMS5DT__0he3Ag.jpeg" /></figure><p>如果你成功啟動並登入，那恭喜你成功一半了！接著用下列指令檢查容量狀況：</p><pre>$ df -h</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q_eUBoi4PJ4ytYwdoxWIlg.png" /></figure><p>果然是boot滿了！既然如此，先用下列指令確定目前運作的內核版本：</p><pre>$ uname -a</pre><p>記好後，進入/boot資料夾，裡面會有各個不同版本的內核相依檔案，先手動刪除低於目前運作版本的相依檔案，直到/boot容量非100％為止。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DjtYw6lbK-qElaciWJEVpw.png" /></figure><p>記住這個步驟非常重要！原因是當/boot容量達100％時，不管你做什麼動作都是無效的，包含清除內核來騰出空間的動作也無法進行，因此我們必須先清出一點空間使得後續動作能產生效果。</p><p>接著執行以下指令修復一些損壞的內核：</p><pre>$ sudo apt-get -f install</pre><p>列出目前所有內核清單：</p><pre>$ dpkg --list | grep linux-image</pre><p>現在可以開始正式移除低版本的內核了：</p><pre>$ sudo apt-get purge linux-image-xxxx-generic</pre><p>或是：</p><pre>$ sudo apt-get purge linux-image-extra-xxx-xx-generic</pre><p>都移除完成後更新GRUB 2：</p><pre>$ sudo update-grub2</pre><p>最後，放心的執行重啟吧！相信可以正常地進入Ubuntu了！</p><pre>$ sudo reboot</pre><p>筆者在解決這個問題的時候關鍵點就是在手動清除/boot騰出空間和下載修復內核，倘若不做這個動作，不管如何purge都沒有效果，希望能幫助到大家，那就下次見囉，掰掰！</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=34181fb3a84c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[在Ubuntu 18.04 LTS + Apache 2中安裝使用Let’s Encrypt SSL憑證]]></title>
            <link>https://rommelhong.medium.com/%E5%9C%A8ubuntu-18-04-lts-apache-2%E4%B8%AD%E5%AE%89%E8%A3%9D%E4%BD%BF%E7%94%A8lets-encrypt-ssl%E6%86%91%E8%AD%89-d2957a0b070f?source=rss-f9480375c374------2</link>
            <guid isPermaLink="false">https://medium.com/p/d2957a0b070f</guid>
            <category><![CDATA[apache]]></category>
            <category><![CDATA[ubuntu]]></category>
            <category><![CDATA[lets-encrypt]]></category>
            <dc:creator><![CDATA[Yu-Cheng Hung]]></dc:creator>
            <pubDate>Fri, 17 Jan 2020 13:59:55 GMT</pubDate>
            <atom:updated>2020-01-17T13:59:55.356Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IHqe0U1fGG4Eu3FBAJtdYA.jpeg" /><figcaption>引用： <a href="https://blog.256pages.com/nginx-nodejs-letsencrypt-update/">https://blog.256pages.com/nginx-nodejs-letsencrypt-update/</a></figcaption></figure><p>嗨大家好，今天想來聊聊如何在Ubuntu 18.04 LTS和Apache 2的環境下安裝使用Let’s Encrypt SSL憑證，除了相關操作步驟外，也會分享筆者在工作過程中遇到的一些坑，希望能讓對這塊不熟的讀者們少繞一些冤枉路，此外也歡迎有相關經驗的讀者能一起討論指教，那麼我們就直接進入主題吧，GO！</p><h4>什麼是Let’s Encrypt？</h4><p>Let’s Encrypt可提供使用者免費、自動化和公開的SSL憑證，對於使用者可說是相當方便，有興趣的讀者可由連結造訪其<a href="https://letsencrypt.org/zh-tw/">官網</a>以獲得更多資訊！</p><h4>確認安裝環境很重要！</h4><p>那麼為什麼會特別強調Apache 2呢？因為這就是筆者誤踩的第一個坑！當時在網路上找相關教學時，因為不熟悉加上該教學文章沒有特別提到環境問題，所以照著步驟安裝執行的結果雖然成功產生憑證並掛上Domain，但我的HTTP並不會自動轉址HTTPS，原因是該篇教學環境是Nginx，照步驟執行的過程中一併安裝了Nginx並用來產生SSL憑證，而Nginx搶佔了Apache2的80 port，導致雖然有成功掛上SSL憑證，但HTTP會一直轉址至Apache2 Ubuntu Default Page，無法轉址HTTPS，當時在這個地方研究了很久，後來將Nginx移除後重新以Apache2的方式跑一次Let’s Encrypt才徹底解決了轉址的問題，希望讀者們能多加小心！</p><h4>安裝Certbot</h4><p>這邊我們先安裝Certbot套件來協助我們完成自動化SSL認證：</p><pre>$ sudo add-apt-repository ppa:certbot/certbot</pre><p>接著安裝Certbot的Apache package：</p><pre>$ sudo apt install python-certbot-apache</pre><h4>確認ServerName是否設置正確</h4><p>請至以下檔案檢查是否已將ServerName設成你想註冊的Domain：</p><pre>$ sudo vi /etc/apache2/sites-available/your_domain.conf</pre><p>可以此指令驗證配置是否成功：</p><pre>$ sudo apache2ctl configtest</pre><p>記得重啟Apache服務：</p><pre>$ sudo systemctl reload apache2</pre><h4>為HTTPS開通防火牆設定</h4><pre>$ sudo ufw allow &#39;Apache Full&#39;<br>$ sudo ufw delete allow &#39;Apache&#39;</pre><p>查看防火牆狀態：</p><pre>$ sudo ufw status</pre><p>應該可以看到下列畫面：</p><pre>Output</pre><pre>Status: active<br><br>To                         Action      From<br>--                         ------      ----<br>OpenSSH                    ALLOW       Anywhere                  <br>Apache Full                ALLOW       Anywhere                  <br>OpenSSH (v6)               ALLOW       Anywhere (v6)             <br>Apache Full (v6)           ALLOW       Anywhere (v6)</pre><h4>獲得SSL憑證</h4><pre>$ sudo certbot --apache -d your_domain -d www.your_domain</pre><p>這邊會要你輸入email用來確認申請者身分並激活後續開通流程，依序填入Domain和IP，並在如何配置HTTPS的地方選擇「2」，使所有的HTTP在Apache層級即可自動轉址HTTPS。</p><p>最後會出現成功訊息，並告訴你憑證檔存放路徑：</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GKhjFBWhQ7CBFa9hMP_qzg.png" /></figure><p>有效認證日期為九十天，我們可以用下列指令讓Cerbot自動續訂：</p><pre>$ sudo certbot renew --dry-run</pre><p>經過上述的操作後，相信各位的網站都已獲得SSL安全憑證，也都能自動轉址，那麼就下次見囉！See You！</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d2957a0b070f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>