nginx 是一個 非常強大的 web 伺服器 但也因為強大 所以設定也有一定的學習難度
故寫這一篇 來記錄 有哪些設定可以操作 操作系統預設為 linux
nginx 所在目錄 預設為 /etc/nginx
nginx 主要設定檔路徑為 /etc/nginx/nginx.config
nginx log 檔案位置 /var/log/nginx
偵測 nginx 是否有在執行中
ps -ef | grep nginx
輸入完以上指令後 可以在 cmd 看到 ngxin 執行的process
停止執行序
kill signal {{processId}}
停止全部
pkill -9 nginx
測試 nginx config 是否正確
nginx -t
設定檔 修改後的realod
nginx -s reload
nginx log 的位置
/var/nginx/log
如何客制化 nginx log 檔案
nginx.conf
....
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" $request_time '; # 這裡來自定義
access_log /var/log/nginx/access.log main; # 這裡要引入
error_log /var/log/nginx/error.log;
...
}
### nginx 隱藏版本號
http { server_tokens off;
}
# 如何設定ssl
sudo apt install certbot python3-certbot-nginx sudo certbot —nginx -d xxx.co -d www.xxx.co // 自己要換成自己的域名 sudo crontab -e
0 3 * * * /usr/bin/certbot renew —quiet // 每天凌晨三點更新
# 如何安裝NGINX
```
sudo apt-get install nginx
```
# 安裝NVIM
```
# 不要用這個方法 會裝很舊的 neo vim
sudo apt-get install neovim
# 使用這個
https://github.com/neovim/neovim/blob/master/INSTALL.md
```
# 鎖機器人
https://www.mxp.tw/9411/