[nginx]-centos7安装nginx的goaccess

wget https://tar.goaccess.io/goaccess-1.3.tar.gz

tar -xzvf goaccess-1.3.tar.gz

cd goaccess-1.3/

./configure --enable-geoip --enable-utf8

configure参数如下

Configure Options

Multiple options can be used to configure GoAccess. For a complete up- to-date list of configure options, run ./configure --help

--enable-debug

Compile with debugging symbols and turn off compiler optimizations.

--enable-utf8

Compile with wide character support. Ncursesw is required.

--enable-geoip=

Compile with GeoLocation support. MaxMind's GeoIP is required. legacy will utilize the original GeoIP databases. mmdb will utilize the enhanced GeoIP2 databases.

--enable-tcb=

Compile with Tokyo Cabinet storage support. memhash will utilize Tokyo Cabinet's in-memory hash database. btree will utilize Tokyo Cabinet's on-disk B+ Tree database.

--disable-zlib

Disable zlib compression on B+ Tree database.

--disable-bzip

Disable bzip2 compression on B+ Tree database.

--with-getline

Dynamically expands line buffer in order to parse full line requests instead of using a fixed size buffer of 4096.

--with-openssl

 

[nginx]-centos7安装nginx的goaccess_第1张图片

configure error  Missing development libraries for ncurses

 

[nginx]-centos7安装nginx的goaccess_第2张图片

yum -y install ncurses-devel

执行之后 不报错了。如果还缺少别的依赖 根据图中的安装就可以了

[nginx]-centos7安装nginx的goaccess_第3张图片

make && make install

 

[nginx]-centos7安装nginx的goaccess_第4张图片

执行下面的命令

goaccess -d -f /var/log/nginx/access.log -p /usr/local/etc/goaccess/goaccess.conf  -o /var/log/nginx/goaccess.html

然后mkdir –p /ftp/www

cp  /var/log/nginx/goaccess.html  /ftp/www

将生成的goaccess.html 通过location模块解析(因为我这边只是测试不需要实时监控,需要实时监控的话需要使用crontab定时生成goaccess.html,然后解析)

 

[nginx]-centos7安装nginx的goaccess_第5张图片

贴一下我nginx的配置

user root;

pid /var/run/nginx.pid;

worker_processes 1;

worker_rlimit_nofile 100000;

events {

    worker_connections 2048;

    multi_accept on;

    use epoll;

}

 

http {

    server_tokens off;

    sendfile on;

    tcp_nopush on;

    tcp_nodelay on;

log_format  main  '$remote_addr $remote_user [$time_local] "$request" '

                  '$status $body_bytes_sent "$http_referer" '

                  '$http_user_agent $http_x_forwarded_for $request_time $upstream_response_time $upstream_addr $upstream_status';

  access_log  /var/log/nginx/access.log main;

  error_log   /var/log/nginx/error.log;

    client_body_buffer_size      128k;

    client_max_body_size         100m;

    client_header_buffer_size    1k;

    large_client_header_buffers  4 4k;

    output_buffers               1 32k;

    keepalive_timeout 60;

    keepalive_requests 100000;

    client_header_timeout 15;

    client_body_timeout 60;

    send_timeout 25;

    reset_timedout_connection on;

    limit_conn_zone $binary_remote_addr zone=addr:5m;

    limit_conn addr 100;

    include /usr/local/nginx/conf/mime.types;

    default_type text/html;

    charset UTF-8;

    gzip on;

    gzip_disable "MSIE [1-6]\.";

    gzip_proxied any;

    gzip_vary off;

    gzip_min_length 1000;

    gzip_comp_level 6;

    open_file_cache max=100000 inactive=20s;

    open_file_cache_valid 30s;

    open_file_cache_min_uses 2;

    open_file_cache_errors off;

proxy_cache_path /cache levels=1:2 keys_zone=cache_aks:30m max_size=2g;

server {

    listen       80;

    server_name  172.16.128.240;

 

location ~*\.(htm|eot|ttf|woff|html|js|css|less|json|gif|jpg|jpeg|png|bmp|swf|ioc|rar|zip|txt|flv|mid|doc|docx|ppt|pdf|xls|xlsx|mp3|mp4|wma|apk|zip|rar|map)$ {

    root   /ftp/www/;

}

 

}  

         

}

 

 

$ goaccess -h
#
常用参数
-a --agent-list 启用由主机用户代理的列表。为了更快的解析,不启用该项
-d --with-output-resolver HTML/JSON输出中开启IP解析,会使用GeoIP来进行IP解析
-f --log-file 需要分析的日志文件路径
-p --config-file 配置文件路径
-o --output 输出格式,支持htmljsoncsv
-m --with-mouse
控制面板支持鼠标点击
-q --no-query-string 忽略请求的参数部分
--real-time-html 实时生成HTML报告
--daemonize 守护进程模式,--real-time-html时使用

加上这些参数可以实时查看数据:--real-time-html --daemonize
默认使用WebSocket监听7890端口,加上参数 --port

这边测试了--real-time-html –daemonize参数

启动命令为goaccess -d -f /var/log/nginx/access.log -p /usr/local/etc/goaccess/goaccess.conf  -o /var/log/nginx/goaccess.html --real-time-html –daemonize

会生成一个进程Daemonized GoAccess: 23384

然后访问了几次之后把文件替换之后 发现网页数据变了。这个的前提也是要解析goaccess.html,我这边测试懒得搞了[nginx]-centos7安装nginx的goaccess_第6张图片

那这样就不需要启动crontab去运行了

[nginx]-centos7安装nginx的goaccess_第7张图片

官网地址

https://goaccess.io/download

你可能感兴趣的:(nginx)