nginx 安裝+參數配置
- 如果有安裝 apache2,先移除
- apt-get purge apache2*
- apt-get autoremove
- apt-get install nginx
- service nginx start
- enter http://localhost/ 測試是否有畫面
- Edit System Config
- nano /etc/nginx/nginx.conf
- worker_processes 1; 設定CPU使用核心數
- Edit Server
- index.php
- nano /etc/nginx/sites-available/default
- index index.php index.html index.htm; –> 加上 index.php
- root /usr/share/nginx/html; –> 文件根目錄
- server_name server.unixmen.local; –> Server FQDN(完整網域名稱)
- test
- nginx -t
- 顯示以下訊息為正確
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful - service nginx restart
相關配置 & 漏洞(?)
- 0day
- 解開 location ~ \.php$ { 系列註解
- 第一行加上 try_files $uri =404; –> 防止 0day 漏洞
- 路徑解析錯誤
- 撰寫fastcgi.conf 重新指定環境參數 (link)
SSL
listen 443;
ssl on;
ssl_certificate /usr/local/nginx/conf/server.crt;
ssl_certificate_key /usr/local/nginx/conf/server.key;
Upstream (load balance)
link
Vitrual Host
同個 Port,只要用 server_name 即可切割,nginx 會依照 server_name讀取指定參數。
listen 443;
ssl on;
ssl_certificate /usr/local/nginx/conf/server.crt;
ssl_certificate_key /usr/local/nginx/conf/server.key;
Upstream (load balance)
link
Vitrual Host
同個 Port,只要用 server_name 即可切割,nginx 會依照 server_name讀取指定參數。
- server_name *.domain.com
- server_name abc.domain.com
- server_name abc.*
- server_name ~^(?<user>.+)\.domain\.com$
相關連結
nginx 安裝+參數配置
Reviewed by Wild
on
8/31/2014 01:36:00 下午
Rating:
沒有留言:
沒有Google帳號也可發表意見唷!