1. 程式人生 > >03-nginx虛擬主機配置

03-nginx虛擬主機配置

nginx的配置段比apache簡單。好的伺服器都有4塊CPU,每塊CPU是8核,最多有32個核工作。比如我的是4核PC,所以把worker_processes設定為4,再多意義也不大。後面還要講nginx的優化,只改worker_connections意義不大,還需要和系統的一些引數配合才行。

4塊CPU,每塊CPU8核,有32個processes,每個process1024個connections,共三萬多connections,一臺伺服器輕鬆搞下來.

C:\Windows\System32\drivers\etc\hosts

chrome://net-internals/#dns #chrome快取

[[email protected] nginx]# cat /usr/local/nginx/var/www/html/index.html
    <html>
        wecome to z.com:8080 admin panel
    </html>
[[email protected] nginx]# vim conf/nginx.conf  #

nginx 匹配優先是:網站路徑,並且不帶正則表示式的優先。
    server {
        listen 8080;                #用的是8080的埠來訪問
        server_name 192.168.0.11;   #訪問的地址
        location / {           #根目錄下
            root
/var/www/html/;    #網頁程式的絕對路徑
            index index.html;      #預設網站
        }
    }

[[email protected] nginx]# ./sbin/nginx -s reload

 ./sbin/nginx -s reload==kill -HUP `cat logs/nginx.pid`       重讀配置檔案不用真正重啟(軟重啟)
 ./sbin/nginx -s reopen==kill -USR1 `cat logs/nginx.pid`    重讀日誌檔案,完全相當於使用訊號量USR1