Nginx相關

(內容有摘抄,如侵權,聯繫刪除,謝謝)html

一、安裝nginxnginx

二、啓動:app

#啓動nginx
$/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
#查看nginx的運行狀況
$ps -ef | grep nginx
$netstat -tunlp | grep 8000
-t (tcp) 僅顯示tcp相關選項
-u (udp)僅顯示udp相關選項
-n 拒絕顯示別名,能顯示數字的所有轉化爲數字
-l 僅列出在Listen(監聽)的服務狀態
-p 顯示創建相關連接的程序名

三、中止操做tcp

#查詢nginx主進程號
$ps -ef | grep nginx
#從容中止Nginx:
$kill -QUIT 主進程號  
#例如:kill -QUIT 16391

#快速中止Nginx:
$kill -TERM 主進程號  

#強制中止Nginx:
$kill -9 主進程號  
#kill -HUP 住進稱號或進程號文件路徑  或者使用
$/usr/nginx/sbin/nginx -s reload  

nginx -t -c /usr/nginx/conf/nginx.conf 
或者
/usr/nginx/sbin/nginx -t 

四、conf/nignx.conf相關配置spa

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;
    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;
   
    server{
        listen    80;
        server_name (域名);
        index index.html index.htm index.shtml;
        location / {
            proxy_pass http://(下面upstream對應名稱);
            proxy_set_header X-real-ip $remote_addr;
            proxy_set_header Host $http_host;
        }
        #access_log  /data/wwwlogs/access_op.report.bitauto.com.log  access;
    }

    upstream 名稱{
        server (ip):8101;
    }
}
相關文章
相關標籤/搜索