# Win10 IIS 啟動 web server ### 啟用IIS服務 1. 打開 Win10 控制台 2. 選擇 Programs and Features 3. 選擇 Turn Windows features on or off 4. 啟用 Internet Information Services 5. 安裝完成後, 搜尋並打開 IIS Manager ### 啟動 web server * 選擇 Default Web Site * Add virturl directory :::info [application 和 virtual directory 的差異](https://serverfault.com/questions/102523/difference-between-application-and-virtual-directory#:~:text=A%20virtual%20directory%20is%20just,root%20(or%20application%20root).) ::: ![](https://i.imgur.com/RfccULz.png) * 新增資料夾, 設定url目錄別名, 確認 Connect As 選擇 Application user * <font color="red">目標資料路徑會影響使用權限,導致權限不足無法開啟。</font> ==✗ 桌面== ==✓ D槽== ![](https://i.imgur.com/aRiAYDq.png) ### 設定 MIME Types :::warning 如果碰到找不到的檔案類型, 要自行手動新增 ::: ![](https://i.imgur.com/KmtDWft.png) * 新增 egret font, 以免無法讀取 ![](https://i.imgur.com/lgyJ1Kq.png) :::success | 副檔名 | MIME type | | -- | -- | | fnt | application/json | | tga | image/x-tga | | 某些特殊script | text/plain | ::: * Default Web Site 按啟動就完成 ![](https://i.imgur.com/SiCOOR1.png) * 設定自動開啟 [參考文章](https://www.red-gate.com/simple-talk/blogs/speeding-up-your-application-with-the-iis-auto-start-feature/) ## CORS 開放跨網域存取 :::success 1. 在 Http response 新增欄位 2. key: **Access-Control-Allow-Origin** 3. value: **\*** ::: [參考文章]( https://blog.yowko.com/iis-enable-cors ) ## 更換瀏覽預設IP :::warning 預設使用 localhost ::: 1. 點選 Default Web Site 2. Edit Bindings 3. 第一順位的 IP address 預設星號, 改成自選 IP ![](https://i.imgur.com/2Hjmyqq.png) ## 開啟資料夾瀏覽 1. 點選 Default Web Site 2. Directory Browsering 3. Actions 點選 Enable ![](https://i.imgur.com/2K9pKbQ.jpg) --- ## 啟用本機測試用的 HTTPS [參考文章](https://techexpert.tips/iis/enable-https-iis/) 步驟: 1. 開啟 Server Certificates 2. Create Self-Signed Certificate 3. friendly name 隨意輸入, 選擇 Personal 即可 5. Default Web Site 選擇 Edit Bindings 6. 新增 https, IP 選 All Unassigned, port 可用預設的 443 7. SSL 選擇剛剛建好的 certificate --- ###### tags: `教學`