1)源码安装nginx:
首先准备好安装包
tar zxf nginx-1.16.1.tar.gz
安装nginx解压所需要的依赖包 cd nginx-1.16.1 yum -y install gcc gcc-c++ zlib-devel pcre-devel 检查环境并编译安装 ./configure && make && make install
开启nginx服务:
/usr/local/nginx/sbin/nginx
关闭nginx服务:
/usr/local/nginx/sbin/nginx -s stop
平滑重载nginx:
/usr/local/nginx/sbin/nginx -s reload
nginx 端口为80
netstat -ntlp | grep 80
2)配置yum源安装:
vim /etc/yum.repos.d/nginx.repo
配置内容
[nginx] name=nginx repo baseurl=http://nginx.org/packages/centos/7/$basearch/ gpgcheck=0 enabled=1
安装nginx
yum -y install nginx
开启服务:
systemctl start nginx #centos7 service nginx start #centos6
以上为nginx的安装方式,不局限于此方法,仅供参考。
Logstash的文件
配置logstash配置、定义配置规则NIGNXACCESS,用来配置nginx过滤访问日志,记住加权限
cd /usr/share/logstash/vendor/bundle/jruby/2.3.0/gems/logstash-patterns-core-4.1.2/patterns/
vim nginx_access
URIPARAM1 [A-Za-z0-9$.+!*'|(){},~@#%&/=:;_?-[]]* NGINXACCESS %{IPORHOST:client_ip} (%{USER:ident}|- ) (%{USER:auth}|-) [%{HTTPDATE:timestamp}] "(?:%{WORD:verb} (%{NOTSPACE:request}|-)(?: HTTP/%{NUMBER:http_version})?|-)" %{NUMBER:status} (?:%{NUMBER:bytes}|-) "(?:%{URI:referrer}|-)" "%{GREEDYDATA:agent}"
chmod 644 /var/log/nginx/access.log