nginx安装

nginx安装

1.进入目录

/etc/yum.repos.d

 vim nginx.repo

2.粘贴配置

[nginx]

name=nginx repo

baseurl=http://nginx.org/packages/centos/7/$basearch/

gpgcheck=0

enabled=1

 

3.安装nginx

yum install  nginx

4.产看安装

rpm -ql nginx

 

5.启动nginx

nginx        启动

nginx -s stop 停止

nginx -t 检查语法

nginx -s reload 重新加载配置文件

worker_cpu_affinity [cpumast] 绑定cpu提高缓存命中率 cpumast 00000001 0号cpu 00000010 1号cpu

worker_priority number  worker进程优先级 【-20,20

worker_rlimit_nofile number worker进程所能打开的文件数量上限

daemon on | off  on后台启动 off 前台启动

events配置

accept_mutex on | off      处理新的连接请求的方法 on 由各个worker轮训处理请求。   off 唤起所有worker ,然后进行竞争

http相关配置

配置一个虚拟主机

server{

listen address [:port]|port;

server_name:server_name;

root /path/to/document_root;

}

server{

listen address [:port]|port;

ip:ip;

root /path/to/document_root;

}

监听5609端口

server { 

listen 5609;
access_log /usr/local/nginx/logs/kibana_access.log main; 

error_log /usr/local/nginx/logs/kibana_error.log error; 

 location / {

 allow 127.0.0.1;

deny all; 

proxy_pass http://127.0.0.1:5601; } 

} 

密码认证登陆

location / { 

auth_basic "elk auth";
 auth_basic_user_file /etc/nginx/pass/htpasswd;

 proxy_pass http://127.0.0.1:5601; 

}
printf "elk:$(openssl passwd -1 elk) " >/etc/nginx/pass/htpasswd 

 

 

 

 

 

 

原文地址:https://www.cnblogs.com/xyj179/p/10341634.html