如何使用 OpenSSL 建立開發測試用途的自簽憑證 (Self-Signed Certificate)

1. 建立 ssl.conf 設定檔

[req]
prompt = no
default_md = sha256
default_bits = 2048
distinguished_name = dn
x509_extensions = v3_req

[dn]
C = TW
ST = Taiwan
L = Taipei
O = My Inc.
OU = IT Department
emailAddress = admin@example.com
CN = CA Disaplay Name

[v3_req]
subjectAltName = @alt_names

[alt_names]
DNS.1 = *.localhost
DNS.2 = localhost
DNS.3 = *.your.domain.name
DNS.4 = 192.168.1.100

2. 透過 OpenSSL 命令產生出自簽憑證與相對應的私密金鑰


openssl req -x509 -new -nodes -sha256 -utf8 -days 3650 -newkey rsa:2048 -keyout server.key -out server.crt -config ssl.conf


3. 透過 OpenSSL 命令產生 PKCS#12 憑證檔案 (*.pfx 或 *.p12), IIS才需要


openssl pkcs12 -export -in server.crt -inkey server.key -out server.pfx


4. 匯入自簽憑證到 WINDOWS 憑證 「受信任的根憑證授權單位」

Windows 請以「系統管理員身分」執行以下命令,即可將憑證匯入到 Windows 的憑證儲存區之中:


certutil -addstore -f "ROOT" server.crt

若要以手動方式匯入,可以參考以下步驟:


  • 開啟檔案總管,並滑鼠雙擊 server.crt 檔案
  • 點擊「安裝憑證」按鈕
  • 選取「目前使用者」並按「下一步」繼續
  • 選取「將所有憑證放入以下的存放區」並按下「瀏覽」按鈕
  • 選取「受信任的根憑證授權單位」並按下「確定」
  • 按「下一步」繼續
  • 按「完成」繼續
  • 在 安全性警告 視窗按下「是(Y)」即可完成設定

請注意:在匯入完成後 Google Chrome 瀏覽器可能不會立刻顯示這是個有效憑證 (因為快取的關係),但你只要過一段時間重開 Chrome 瀏覽器,即可看見網址列的變化,不會再出現紅色不安全的提示。



參考文章:

The Will Will Web ( 感謝保哥分享 )

https://blog.miniasp.com/post/2019/02/25/Creating-Self-signed-Certificate-using-OpenSSL

PHPStorm CUSTOM CODE NAVIGATION CodeIgniter


PHPStorm 支援 CodeIgniter 沒那麼高,
需要自行定義屬性來產生關聯

http://tekina.info/integrate-code-navigation-codeigniter-phpstorm/?fbclid=IwAR1m6Zf7K0Gri-rvaPuVOciC_5whWSg6i1bO1tZibdGcL7GymKDDycK9MzI

VirtualBox cannot create symbolic link

關閉所有 VM 及 VirtualBox

Windwos 10 使用管理員權限執行解開軟連結限制

VBoxManage setextradata "VM_NAME" VBoxInternal2/SharedFoldersEnableSymlinksCreate/SHARE_NAME 1

NGINX get filename and remove prefix

location ~ "^/downloads/files/[a-zA-Z0-9]{8}\-(.*\..*)$" {
    add_header Content-disposition 'attachment; filename="$1"';
}

Windows 10 共享資料夾 CentOS 7 掛載

PHPStrom 對 samba 分享的資料夾掛載不友善
External file changes sync may be slow: Project files cannot be watched (are they under network mount?)
所以要反過 windows 10 分享給 centos 掛載, 這樣 phpstorm 在讀取檔案時就不會慢

Windwos 10
open cmd with admin
Add Windows user for share
net user __USER__ __PASSWORD__ /add

Add user to admin(optional)
net localgroup administrators __USER__ /add

Share folder and add user
net share __SHARE_NAME__=D:\www /GRANT:__USER__,FULL

Centos 7
yum install -y cifs-utils

Create mount folder
/mnt/www

Mount Folder
要明確指定權限, 否則 nginx, php 無法執行及寫入動作
mount -t cifs -o username="__USER__",password="__PASSWORD__",uid=root,gid=root,dir_mode=0774,file_mode=0774,vers=2.0 //192.168.0.120/www /mnt/www

Unmount Folder
umount /mnt/www

Auto mount with startup
vi /etc/fstab
//192.168.0.120/www    /mnt/www    cifs    auto,username=__USER__,password=__PASSWORD__,uid=root,gid=root,dir_mode=0774,file_mode=0774,vers=2.0    0 0

Execute mount
mount -a

Check mount
mount

Check df
df -h


ref:
https://hk.saowen.com/a/f9bdf856dcdefe9ef9b81d80d03f3985b5033efd7e230e2cae7c126e04d67794

fdisk add LVM to CentOS

Linux Fdisk 磁碟分割及格式化

列出 partition table(s)
# fdisk -l

格式化 /dev/sdb
# fdisk /dev/sdb
# Command (m for help): n
# Command action
   e   extended
   p   primary partition (1-4)
p
# Partition number (1-4): 1
# First cylinder (1-2610, default 1): "enter"
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610): "enter"
Using default value 2610
# Command (m for help): w

將新增實體給LVM使用
# pvcreate /dev/sdb1

查詢 VG Nname
# vgdisplay

掛載新磁區到 VG
# vgextend centos /dev/sdb1

掃描新磁區是否掛載到 VG
# pvscan

顯示目前的 LVM
# lvdisplay

選擇欲加大的 LVM 掛載新磁區
# lvextend /dev/centos/usr /dev/sdb1

重新整理 LMV 大小
# xfs_growfs /dev/centos/usr

檢查 LVM 是否已正常掛載
# df -h



ref:
https://www.rootusers.com/how-to-increase-the-size-of-a-linux-lvm-by-adding-a-new-disk/