Nginx相关

(内容有摘抄,如侵权,联系删除,谢谢)

1、安装nginx

2、启动:

#启动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 显示建立相关链接的程序名

3、停止操作

#查询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 

4、conf/nignx.conf相关配置

#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;
    }
}

 

posted on 2018-05-24 19:55  凤鸣岐山  阅读(152)  评论(0编辑  收藏  举报

导航