Nginx 安裝與啟動
source link: https://dannypsnl.github.io/blog/2018/04/02/cs/nginx-run-and-up/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
這篇只是隨便紀錄一下好不容易終於弄懂的 Nginx ,首先各個平台安裝方式應該直接上網查詢 官網下載頁 最基本的啟動方式通常是 ,不過各平台可能有差異,應以實際位置為主 指令 設定流程 把設定檔放在 下,請根據系統到 Nginx 的設定檔目錄中尋找這個目錄 p.s…
Nginx 安裝與啟動
這篇只是隨便紀錄一下好不容易終於弄懂的 Nginx ,首先各個平台安裝方式應該直接上網查詢
最基本的啟動方式通常是 /usr/bin/nginx
,不過各平台可能有差異,應以實際位置為主
$ nginx -s stop # shut down nginx
$ nginx -s reload # reload configure, if you edit the configure & want to use it, this is what you want
把設定檔放在 sites-available/
下,請根據系統到 Nginx 的設定檔目錄中尋找這個目錄
p.s. 舉例來說,我在 gcloud 上的 Ubuntu 主機中 Nginx 設定檔目錄在
/etc/nginx
寫好設定檔之後再到 sites-enabled
目錄中,建立 link 指向 site-available
中的設定檔
最後 reload 套用新的設定
設定檔內容
這邊我也沒有深入研究,需要什麼再想是我的習慣,而且軟體總是有新的變動,所以這裡我只介紹基本的東西, 更進階的 Nginx 用法應該直接看官方文件
接著看一段簡單的設定檔
upstream service_stream {
server 127.0.0.1:8080;
}
server {
listen 80;
location / {
proxy_pass http://service_stream;
}
}
upstream
抽象了服務跟實際的伺服器的連結,這裡可以看到用一段 ip 取代直接建立一個監聽 80 port 的伺服器,
這讓網路服務模型更具有擴展性,而軟體最應該關注的就是擴展能力
upstream
不處理網路服務,而是設定處理網路服務的服務器(server
),所以稱之為上游
server
去聆聽真實的網路請求,然後把資訊轉給 upstream
,這裡是代理服務,所以用 proxy_pass
listen
決定了聆聽哪些 port ,location
決定把哪些路由導向哪個服務
author: Lîm Tsú-thuàn/林子篆/Danny
category:cs
tag:nginxweb
Similar Articles
All works in this site is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.Recommend
-
59
Vortex-1-1-1-15-1584350950 Mount & Blade II Bannerlord e1.1.2 1. 安裝 Vortex 下載&安裝 Vortex
-
35
RHEL/CentOS 離線安裝 Nginx rpm-黑暗執行緒接到指令要安裝一台 Nginx 當 Reverse Proxy。依過去幾次經驗估計是件簡單任務,應可在半小時內搞定。基本上就是照著(Ho...
-
11
Unity – ml-agents 環境準備2 – 安裝 – NaCl's Blog一直找不到時間弄個圖文版, 拖到現在就直接用文字帶過囉~ 哈哈!! 延續
-
9
.NET 5 執行環境安裝說明 2021-01-26 08:41 PM
-
11
在網路隔離環境安裝 Windows Terminal-黑暗執行緒微軟於 MSBuild 2019 推出 Windows Terminal,幾十年沒長進的命令提示字元 (Command Prompt) 及死板...
-
11
騎砍2(Mount & Blade II: Bannerlord) – MOD 安裝/管理 via Vortex
-
9
內外雙光圈、安裝又順暢的 ADATA XPG LEVANTE 360 ARGB 一體式水冷測試 不少廠商都在水冷頭上作文章,做著做著都變成違章建築,如同 ADATA XPG LEVANTE 360 ARGB 一體式水冷簡單才是最美。 處理器核心數量不斷增加,AMD 與 Int...
-
5
打造極簡式 ASP.NET Core 桌面小工具 對於網頁開發者來說,開發桌面小工具寫成網頁再轉桌面應用程式是最省時省力的選擇,而 Github 開發的 Electron 則是最流行的網頁轉桌面應用程式框架,大家日...
-
3
Phoneix 安裝與啟動這幾天好不容易有機會試玩 Elixir 的神奇框架 Phoenix 首先要用 mix 下載 phoenix $ mix archive.install https://github.com/phoenixframework/archives/raw/master/phx_new.ez 另外...
-
14
HTTPS Nginx Docker 之懶人安裝法 2022-12-11 05:45 PM 2
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK