Nginx的使用总结

启动与停止等命令

ps -ef|grep nginx

start nginx

nginx -s reload

nginx -s stop    //快速停止nginx

nginx -s quit      //完整有序的停止nginx

 

/usr/local/java/nginx17/sbin

./nginx

linux下nginx的安装

下载nginx及其相关插件

下载openssl :http://download.csdn.net/download/yuanyuan_186/9503203

下载zlib:http://download.csdn.net/download/qin1174586290/6364757

下载pcre:http://download.csdn.net/download/zlyzheng/8301861

下载nginx:https://nginx.org/download/nginx-1.10.1.tar.gz

 

 

安装gcc

查看是否安装gcc,输入rpm -qa | grep gcc

[root@localhost ~]# rpm -qa | grep gcc

gcc-c++-4.8.2-16.el7.x86_64

libgcc-4.8.2-16.el7.x86_64

gcc-4.8.2-16.el7.x86_64

gcc-gfortran-4.8.2-16.el7.x86_64

 

出现gcc-c++,libgcc,gcc说明已经安装。

否则在线安装gcc,安装gcc输入yum install gcc-c++

[root@localhost ~]# yum install gcc-c++

 

安装和编译openssl

cd /usr/local/java/nginx/

tar zxvf openssl-1.1.1g.tar.gz

cd openssl-1.1.1g

./config && make && make install

 

安装和编译pcre

cd /usr/local/java/nginx/

tar zxvf pcre2-10.35.tar.gz

cd pcre2-10.35

./configure && make && make install

安装和编译zlib

cd /usr/local/java/nginx/

tar zxvf zlib-1.2.11.tar.gz

cd zlib-1.2.11

./configure && make && make install

安装和编译nginx

cd /usr/local/java/nginx/

tar zxvf nginx-1.17.10.tar.gz

cd nginx-1.17.10

./configure --prefix=/usr/local/java/nginx17

//指定nginx安装路径

make && make install

//[root@localhost nginx10] ./configure && make && make install

 

 

nginx的卸载

一、卸载

如果是使用yum安装:

yum remove nginx

 

如果已经不记得安装方式了,那么可以使用以下步骤进行全删除:

 

rm -rf /etc/nginx/

rm -rf /usr/sbin/nginx

rm /usr/share/man/man1/nginx.1.gz

apt-get remove nginx*

nginx实现统计分离

文件位置

 

 statistics_proxy_params

#proxy_redirect off;   
#proxy_set_header Host $host;   
#proxy_set_header X-Real-IP $remote_addr;   
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

#proxy_http_version 1.1;
#proxy_set_header Upgrade $http_upgrade;
#proxy_set_header Connection "upgrade";

#client_max_body_size 40m;   
#client_body_buffer_size 128k;   
#proxy_connect_timeout 30000;   
#proxy_send_timeout 30000;   
#proxy_read_timeout 30000;   
#proxy_buffer_size 128k;   
#proxy_buffers 2 256k;   
#proxy_busy_buffers_size 256k;   
#proxy_temp_file_write_size 256k;


proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-Forward-For $remote_addr;

client_max_body_size 40m;   
client_body_buffer_size 128k;   
proxy_connect_timeout 30000;   
proxy_send_timeout 30000;   
proxy_read_timeout 30000;   
proxy_buffer_size 128k;   
proxy_buffers 2 256k;   
proxy_busy_buffers_size 256k;   
proxy_temp_file_write_size 256k;

  statistics.location

location ^~/vaccinate/a/child_baseinfo/documentStatistics/list{
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}

location ^~/vaccinate/a/child_baseinfo/documentStatistics/sele{
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}

location ^~/vaccinate/a/child_baseinfo/documentStatistics/caseRepetitionList {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}

location ^~/vaccinate/a/chheHere/list {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}

location ^~/vaccinate/a/chheHere/tableList {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	

location ^~/vaccinate/a/child_baseinfo/createCard/list {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	

location ^~/vaccinate/a/child_baseinfo/createCard/query {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}				

location ^~/vaccinate/a/child_precheck/bsChildPrecheck/list {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	
location ^~/vaccinate/a/child_vaccinaterecord/inoculationOfStatistics/list {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	
location ^~/vaccinate/a/inoculate/quene/quenelog {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	
location ^~/vaccinate/a/inoculate/quene/exportVaccLog {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	
location ^~/vaccinate/a/inoculate/quene/exportVaccLogDetail {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	
location ^~/vaccinate/a/child_vaccinaterecord/dailyManagement/list {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	
location ^~/vaccinate/a/child_vaccinaterecord/dailyManagement/sele {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	
location ^~/vaccinate/a/child_baseinfo/overduevacc/list {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	
location ^~/vaccinate/a/child_baseinfo/overduevacc/sele {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	
location ^~/vaccinate/a/child_vaccinaterecord/jzlkh/list {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	
location ^~/vaccinate/a/child_vaccinaterecord/jzlkh/sele {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	
location ^~/vaccinate/a/child_vaccinaterecord/inoculationOfStatistics/unquaStatistics {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	
location ^~/vaccinate/a/child_baseinfo/ipvcheck/list {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	
location ^~/vaccinate/a/product/bsManageProduct/list {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	
location ^~/vaccinate/a/child_baseinfo/ipvcheck/sele {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	
location ^~/vaccinate/a/child_baseinfo/ipvchecksum/list {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	
location ^~/vaccinate/a/child_baseinfo/ipvchecksum/sele {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	
location ^~/vaccinate/a/product/bsManageProduct/productUseList {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	
location ^~/vaccinate/a/productcheck/bsProductCheck/list {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	
location ^~/vaccinate/a/productcheck/bsProductCheck/summList {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	
location ^~/vaccinate/a/manage_stock_in/manageStockIn/listSnum {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	
location ^~/vaccinate/a/jwx/jwxStockIn/list {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	
location ^~/vaccinate/a/manage_stock_in/manageStockIn/list {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	
location ^~/vaccinate/a/product/bsManageProduct/store {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	
location ^~/vaccinate/a/product/bsVaccineBatchno/list {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	
location ^~/vaccinate/a/product/bsProductYjm/list{
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	
location ^~/vaccinate/a/equtemparchives/bsEquTempRecord/getJspEquTemp {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	
location ^~/vaccinate/a/equtemparchives/bsEquTempRecord/getEquTempRecordList {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	
location ^~/vaccinate/a/bsinfobasicdata/bsInfoColdchaineQuipment/list {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	
location ^~/vaccinate/a/bsinfobasicdata/bsInfoColdchaineQuipment/tableList {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	
location ^~/vaccinate/a/assets/bsAssets/list {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	
location ^~/vaccinate/a/messagetemp/sysTemplate/list {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	
location ^~/vaccinate/a/dxmxxinfo/list {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	
location ^~/vaccinate/a/sms/smsChargeRecord/list {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	
location ^~/vaccinate/a/export/export/routineVacc6_1 {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	
location ^~/vaccinate/a/export/export/exportlist {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	
location ^~/vaccinate/a/export/export/routineVacc6_2 {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	
location ^~/vaccinate/a/export/export/nationalIPVRoutineVaccReport6_1 {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	
location ^~/vaccinate/a/export/export/typeTwoVaccReport6_2 {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	
location ^~/vaccinate/a/export/export/Exp_SecondJxc {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	
location ^~/vaccinate/a/export/export/Exp_YuShou {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	
location ^~/vaccinate/a/export/export/newbornBuildCard {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	
location ^~/vaccinate/a/export/export/preventionCard{
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	
location ^~/vaccinate/a/export/export/baseinfocomp { 
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	

location ^~/vaccinate/a/export/export/vaccinfocomp {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	
location ^~/vaccinate/a/liveliHood/list {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	
location ^~/vaccinate/a/liveliHood/tableList {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	
location ^~/vaccinate/a/remind/vacChildRemind/remindList {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	
location ^~/vaccinate/a/remind/vacChildRemind/list {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	
location ^~/vaccinate/a/remind/vacChildRemind/remindAllList {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}				
location ^~/vaccinate/a/rabiesvaccine/bsRabiesCheckin/bsCheckin {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	
location ^~/vaccinate/a/num/bsRabiesNum/list {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	
location ^~/vaccinate/a/num/bsRabiesNum/bsRabiesStockList{
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	
location ^~/vaccinate/a/rabiesvaccine/bsRabiesCheckin/bsCheckinStock {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	
location ^~/vaccinate/a/hepatitis/bsHepatitisBcheckin/bsCheckin {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	
location ^~/vaccinate/a/hepatitisnum/bsHepatitisBNum/list {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}	
location ^~/vaccinate/a/hepatitisnum/bsHepatitisBNum/bsHepatitisBStockList {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}
location ^~/vaccinate/a/hepatitis/bsHepatitisBcheckin/bsCheckinStock {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}
location ^~/vaccinate/a/schoolinfo/sysSchool/vaccCheck {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}
location ^~/vaccinate/a/checkrecord/bsChildCheckRecord/getJspStusearch {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}
location ^~/vaccinate/a/schoolinfo/sysSchool/getJspSchool {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}
location ^~/vaccinate/a/yiyuan/sysBirthHospital/list {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}
location ^~/vaccinate/a/department/sysVaccDepartment/list {
    proxy_pass $http_host_one;  
    include statistics_proxy_params;
}

  

conf配置

#user  nobody;
worker_processes  8;

#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  118.31.105.216;
	        set $http_host_one	"http://118.178.88.56:8081";	  #备
            set $http_host_two	"http://118.31.105.216:8081";   #主
			
            include vhost/statistics.location;
		    # include vhost/s.location;
		   
			location / {
				proxy_pass $http_host_two;  
				proxy_http_version 1.1;
				proxy_set_header Upgrade $http_upgrade;
				proxy_set_header Connection "Upgrade";
				proxy_set_header X-Real-IP $remote_addr;
				proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
				proxy_set_header Host $http_host;
                proxy_set_header X-Forward-For $remote_addr;
				
				client_max_body_size 40m;   
				client_body_buffer_size 128k;   
				proxy_connect_timeout 30000;   
				proxy_send_timeout 30000;   
				proxy_read_timeout 30000;   
				proxy_buffer_size 128k;   
				proxy_buffers 2 256k;   
				proxy_busy_buffers_size 256k;   
				proxy_temp_file_write_size 256k;
			}		
    }
	
	server {
			listen       80;
            server_name  jiangxi.chinavacc.net;		
			
			location / {
				proxy_pass http://127.0.0.1:8083;  
				proxy_http_version 1.1;
				proxy_set_header Upgrade $http_upgrade;
				proxy_set_header Connection "Upgrade";
				proxy_set_header X-Real-IP $remote_addr;
				proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

				client_max_body_size 40m;   
				client_body_buffer_size 128k;   
				proxy_connect_timeout 30000;   
				proxy_send_timeout 30000;   
				proxy_read_timeout 30000;   
				proxy_buffer_size 128k;   
				proxy_buffers 2 256k;   
				proxy_busy_buffers_size 256k;   
				proxy_temp_file_write_size 256k;
			}		
    }

    server {
        listen       8088;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}

  

 

posted on 2020-06-12 17:29  有酒有故事  阅读(284)  评论(0编辑  收藏  举报

导航