[Web Server] Nginx/Apache 環境變數設定 (Environment Variables)

Intro Nginx/Apache 環境變數設定速查 Nginx設定 fastcgi_param RUNTIME_ENVIROMENT ‘DEV’ For example: server { listen 80; root /var/www/html; index index.php; server_name localhost; location / { index index.php; } location ~ .*\.(php|php5)?$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param RUNTIME_ENVIROMENT ‘DEV’ } } Nginx 加入 […]

[Linux] SSH PEM 免密碼登入指南 (Public Key Authentication)

Intro X.509標準下我們可以製作PEM私鑰,用以登入放置公鑰的伺服器。 製作流程 1. 當前帳號執行Key產生器 $ ssh-keygen 產生於~/.ssh下: id_rsa.pub // 公開金鑰(public key) id_rsa // 私密金鑰(private key) 2. Public Key放至登入伺服器上帳號的~/.ssh/authorized_keys: ssh user@remotehost ‘mkdir -p ~/.ssh;cat >> ~/.ssh/authorized_keys’ < ~/.ssh/id_rsa.pub or ssh-copy-id -i ~/.ssh/id_rsa.pub user@remotehost 進階用法 其他參數產生鑰匙用法: ssh-keygen -t rsa -b 4096 […]

[Windows] 關閉 Windows 10 自動更新

Intro Windows 10 更新太XX 注意! Windows 10自動更新的機制不斷再更新,本教學也會持續更新。 第三方關閉自動更新軟體:StopUpdates10 關閉服務(Service) 服務(Services) > Windows Update > 關閉停用 + 復原不動作0重試 服務(Services) > Windows Update Medic Service > 關閉停用 Service服務有權限鎖,以系統管理員執行REG add “HKLM\SYSTEM\CurrentControlSet\Services\WaaSMedicSvc” /v “Start” /t REG_DWORD /d “4” /f 設定自動更新模式 可修改為停用或提醒下載模式 執行gpedit.msc: 電腦設定 > […]

[Network] Traceroute & Tracert/Tracepath 工具指南

Intro Traceroute – Wikipedia 可顯示封包在IP網路經過的路由器的IP位址。 Windwos平台指令:tracert Linux Linux平台指令:traceroute or tracepath traceroute(8) — Linux manual page Linux 可以額外安裝 traceroute 套件,與內建 tracert 不相同 $ traceroute www.google.com // TCP on port 443 $ traceroute -T -p 443 www.google.com MacOS 原生的traceroute不支援 TCP protocol,可以利用 Homebrew […]

[i18n] 淺談Internationalization – Language Identifiers (RFC 3066)

Intro 常見的國家語系代碼如en-US, zh-TW,是遵照RFC 3066定義。 RFC 3066 簡而言之,使用ISO 639搭配ISO 3166組合而成: [ISO 639-2]-[ISO 3166-1] 產生如en-US, zh-TW codes。 代碼查詢表 – Code Tables ISO 639-2 – 語系表 ISO 3166-1 – 國別表 ISO 15924 – 地區書寫表 RFC 3066 – 完整語系國別表(含ISO 15924定義) Reference IETF語言標籤 – IETF […]

[Yii2] i18n(Internationalization) – 語系架構設定範例 (使用Key對應架構)

Intro 官網文件:Internationalization 語系代碼:[i18n] 淺談Internationalization – Language Identifiers (RFC 3066) 架構範例 別於官網以主要語系(英文)為sourceLanguage,本章範例以Key的架構去定義語系(也就是Message是指定一個Key必經轉譯)。 Configuration return [ // set target language to be English ‘language’ => ‘en-US’, // set source language to be a customized key which means it will always translate. ‘sourceLanguage’ […]

[MySQL] MySQL效能測試指南(連線|運行) – MySQL Benchmark

Intro MySQL Benchmark方法指南。 效能測試 取得PROFILE資料檢測Query: SET profiling=1;<query>;SHOW PROFILE; 從mysqlDB測測CPU: SELECT DISTINCT Transition_type_id FROM `time_zone_transition`; 連線測試 MySQL目前有個有趣的連線Latency問題,可參考:[MySQL] 如何佈署Database最佳連線路由 – phpMyAdmin建議走本機或內網 這邊提供測試方法(透過mysql client): 預裝好的選mysqldatabase來測試: use mysql; 找最大的time_zone_transition來測: SELECT * FROM `time_zone_transition`; 結果範例最後的資訊帶有總體來回時間: 120208 rows in set (0.08 sec) 交叉測試便可知越遠的client connection時間越久。

[PHP] Codeigniter 3 底層解析

Intro CodeIgniter User Guide bcit-ci/CodeIgniter Router Core: system/core/Router.php 由Codeigniter core class執行裝載為$RTR。 Uri中,Query String(Uri)的載入是在__construct()執行_set_routing()後,分別設定完成以下Properties: class – Controller name method – Action name directory – Controller directory if exist _set_routing() => _parse_routes() > _set_request() or _set_default_controller() 所以Router需裝載Uri並透過Uri取得segments注入設定。 Uri Core: system/core/Uri.php __construct()即會解析Uri(uri_string)至segments:_set_uri_string() Uri拿取方法uri_protocol預設就是使用:_parse_request_uri() […]