{%hackmd DfWYF9cYREebVNN1eEOz-w %} nginx ====== > ***不知自己不知道, 那你會以為你知道.*** ###### tags: `nginx` `202209` ## [[WebServer 基礎概念系列]] ## Nginx 的 config ### 能調整什麼? - 負載平衡 - 所有的設定都來自於 config file,Nginx 主設定檔會放在 ```/etc/nginx/nginx.conf``` - 預設會在 `/etc/nginx/sites-enabled/` 下建立 link 到 `/etc/nginx/sites-available/` 中所有的檔案,也可以在這建立 default - 不同的域名對應的 config file 會放在 ```/etc/nginx/conf.d/<<dommain>>.conf``` ### 統一管理不同域名的 config,建立 default.conf ```bash # root 權限建立並編輯 default.conf 在 /etc/nginx/conf.d/ $ sudo touch /etc/nginx/conf.d/default.conf $ sudo vim /etc/nginx/conf.d/default.conf ``` ### 查詢 config 位置,驗證 syntax 是否正確 ``` shell $ nginx -t ``` ## 效能設定 主要的配置檔位置在 Linux 環境中會在 /etc/nginx 底下,除了 epoll 可以從機制上影響效能外,也可以從系統服務的性質從[核心的設定](http://nginx.org/en/docs/ngx_core_module.html)以及相關設定優化效能。 - worker_processes 就是配合主機核心數,若是 4 核心就可以設置 `worker_processes 4` ## nginx base on Linux [[Ubuntu 基礎概念#Nginx on Ubuntu]] ## nginx base on windows ref: - [# PHP-FastCGI on Windows](https://www.nginx.com/resources/wiki/start/topics/examples/phpfastcgionwindows/) - [Official Win32 Binaries](https://nginx.org/en/download.html) ```bash # 到 C => 解壓縮 => 重新命名 => cd 到目標(後來用手動做掉, unzip 指令要設定環境變數, 沒想好用哪個應用) $ cd c:\ $ unzip nginx-1.2.3.zip $ ren nginx-1.2.3 nginx $ cd nginx ``` ### 啟動與確認 ref: [# nginx for Windows](https://nginx.org/en/docs/windows.html) ```bash $ start nginx $ tasklist /fi "imagename eq nginx.exe" ``` ### nginx/Windows runs as a standard console application (not a service), and it can be managed using the following commands: > nginx -s stop >> fast shutdown > > nginx -s quit > powershell: .\\nginx -s quit >> graceful shutdown (recommend) > > nginx -s reload >> changing configuration, starting new worker processes with a new configuration, graceful shutdown of old worker processes > > nginx -s reopen >> re-opening log files
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up