当前位置:小鱼儿玄机二站 > 计算机网络 > 职业日志,nginx服务傻子搭建

职业日志,nginx服务傻子搭建

文章作者:计算机网络 上传时间:2019-11-01

具备日志文件目录在/data/visitlog下,按日期分子目录

nginx服务呆子搭建

1,上传全部所需包至服务器

安装步骤:

elasticsearch-1.7.0.zip  

风流罗曼蒂克、先准备好相关源码包和次序包,如下图

jdk-7u79-linux-x64.rpm  

图片 1

kibana-4.1.1-linux-x64.tar.gz  

持有包都在云服务器的/src目录下。

logstash-1.5.3.tar.gz

图片 2

nginx-1.8.0.tar.gz

二、安装

2,安装jdk

1、安装nginx服务器,支持vod stream、fileupload

rpm -ivh nginx-1.8.0.tar.gz

cd /src

echo export JAVA_HOME=/usr/java/jdk1.7.0_79/ >> /etc/profile

 

echo export PATH=$JAVA_HOME/bin:$PATH >> /etc/profile

tar zxvf pcre-8.36.tar.gz

echo export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar >> /etc/profile

 

source /etc/profile

cd pcre-8.36

3,部署elk

////pcre是多少个相当的小的正则表明式库,还小很苍劲

tar xzf kibana-4.1.1-linux-x64.tar.gz -C /data/elk/

./configure --prefix=/usr/local/pcre

tar xzf logstash-1.5.3.tar.gz -C /data/elk/

 

unzip elasticsearch-1.7.0.zip

make && make install

mv elasticsearch-1.7.0 /data/elk/elasticsearch

 

cd /data/elk

cd ..

mv kibana-4.1.1-linux-x64 kibana

 

mv logstash-1.5.3 logstash

tar zxvf openssl-1.0.1j.tar.gz

4,配置logstash

 

mkdir /data/elk/logstash/etc

groupadd www

vim /data/elk/logstash/etc/logs.conf

 

input {
  file {
     path => ["/data/visitlog/**/*.log" ]
     #start_position => "beginning"   #start_position为从何处导入日志,不安插的情状下默以为从开启服务时初步导入生成的日记,beginning为将引得中全数日志导入
   }
}
output {
  stdout { codec=> dots }
  elasticsearch {host => "localhost" }
}

useradd -g www www -s /bin/false

5,运转服务

 

nohup /data/elk/kibana/bin/kibana &

unzip nginx-upload-module-2.2.zip

nohup /data/elk/elasticsearch/bin/elasticsearch &

 

nohup /data/elk/logstash/bin/logstash -f /data/elk/logstash/etc/log.conf &

unzip nginx-upload-progress-module-master.zip

6,查看是还是不是有9200 9300 5601端口运维

 

7,登录kibana查看

tar zxvf zlib-1.2.8.tar.gz

 

8,nginx反向代理与认证登陆配置

tar zxvf nginx-1.6.2.tar.gz

yum install pcre-devel zlib-devel -y

 

tar xzf nginx-1.8.0.tar.gz

cd nginx-1.6.2

cd nginx-1.8.0

 

./configure --prefix=/usr/local/nginx

./configure --prefix=/usr/local/nginx --without-http_memcached_module --user=www --group=www --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_mp4_module --with-http_flv_module --with-openssl=/src/openssl-1.0.1j --with-pcre=/src/pcre-8.36 --with-zlib=/src/zlib-1.2.8 --add-module=/src/nginx-upload-progress-module-master --add-module=/src/nginx-upload-module-2.2

make && make install

 

vim /etc/init.d/nginx

make && make install

#!/bin/bash
# nginx Startup script for the Nginx HTTP Server
# this script create it by ruijie. at 2014.02.26
# if you find any errors on this scripts,please contact ruijie.
# and send mail to ruijie at gmail dot com.
#            ruijie.qiao@gmail.com
### BEGIN INIT INFO
# Provides:          nginx
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts nginx
# Description:       starts the nginx server
### END INIT INFO

 

nginxd=/usr/local/nginx/sbin/nginx
nginx_config=/usr/local/nginx/conf/nginx.conf
nginx_pid=/usr/local/nginx/logs/nginx.pid

vi /etc/rc.d/init.d/nginx                #编写运转文件增加下边内容 (铅白全体)

RETVAL=0
prog="nginx"

 

[ -x $nginxd ] || exit 0

#!/bin/bash

# nginx Startup script for the Nginx HTTP Server

# it is v.0.0.2 version.

# chkconfig: - 85 15

# description: Nginx is a high-performance web and proxy server.

# It has a lot of features, but it's not for everyone.

# processname: nginx

# pidfile: /var/run/nginx.pid

# config: /usr/local/nginx/conf/nginx.conf

nginxd=/usr/local/nginx/sbin/nginx

nginx_config=/usr/local/nginx/conf/nginx.conf

nginx_pid=/usr/local/nginx/logs/nginx.pid

RETVAL=0

prog="nginx"

# Source function library.

. /etc/rc.d/init.d/functions

# Source networking configuration.

. /etc/sysconfig/network

# Check that networking is up.

[ ${NETWORKING} = "no" ] && exit 0

[ -x $nginxd ] || exit 0

# Start nginx daemons functions.

start() {

if [ -e $nginx_pid ];then

echo "nginx already running...."

exit 1

fi

echo -n $"Starting $prog: "

daemon $nginxd -c ${nginx_config}

RETVAL=$?

echo

[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx

return $RETVAL

}

# Stop nginx daemons functions.

stop() {

echo -n $"Stopping $prog: "

killproc $nginxd

RETVAL=$?

echo

[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /usr/local/nginx/logs/nginx.pid

}

reload() {

echo -n $"Reloading $prog: "

#kill -HUP `cat ${nginx_pid}`

killproc $nginxd -HUP

RETVAL=$?

echo

}

# See how we were called.

case "$1" in

start)

start

;;

stop)

stop

;;

reload)

reload

;;

restart)

stop

start

;;

status)

status $prog

RETVAL=$?

;;

*)

echo $"Usage: $prog {start|stop|restart|reload|status|help}"

exit 1

esac

exit $RETVAL

# Start nginx daemons functions.
start() {

 

    if [ -e $nginx_pid ] && netstat -tunpl | grep nginx &> /dev/null;then
        echo "nginx already running...."
        exit 1
    fi

保存!!

    echo -n $"Starting $prog!"
    $nginxd -c ${nginx_config}
    RETVAL=$?
    echo
    [ $RETVAL = 0 ] && touch /var/lock/nginx
    return $RETVAL
}

 

# Stop nginx daemons functions.
stop() {
    echo -n $"Stopping $prog!"
    $nginxd -s stop
    RETVAL=$?
    echo
    [ $RETVAL = 0 ] && rm -f /var/lock/nginx
}

chmod 775 /etc/rc.d/init.d/nginx      #付与文件实行权限

# reload nginx service functions.
reload() {
    echo -n $"Reloading $prog!"
    #kill -HUP `cat ${nginx_pid}`
    $nginxd -s reload
    RETVAL=$?
    echo

 

}

chkconfig nginx on                            #安装开机运营

# See how we were called.
case "$1" in
start)
        start
        ;;

stop)
        stop
        ;;

reload)
        reload
        ;;

restart)
        stop
        start
        ;;

*)
        echo $"Usage: $prog {start|stop|restart|reload|help}"
        exit 1
esac

exit $RETVAL

 

chmod +x /etc/init.d/nginx

mkdir /usr/local/nginx/conf/conf.d

nginx.conf http模块中加多include     /usr/local/nginx/conf/conf.d/*.conf; 注释掉server模块

vim /usr/local/nginx/conf/conf.d/kibana.conf

server {
        listen       80;
        server_name  localhost;
        #charset koi8-r;
        #access_log  logs/kibana.access.log  main;
        error_log   logs/kibana.error.log;
        location / {
            #root   html;
            #index  index.html index.htm;
            auth_basic "secret";
            auth_basic_user_file /usr/local/nginx/passwd.db;
            proxy_pass ;
            proxy_set_header   Cookie $http_cookie;
            #proxy_cookie_path  /vga/ /;
            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;
        }
}

htpasswd -c /usr/local/nginx/passwd.db admin    #admin为报到顾客

chmod 777 passwd.db

service nginx start

9,今后可直接运用IP地址来报到kibana,提醒输入客户名密码

本文永世更新链接地址:http://www.linuxidc.com/Linux/2016-09/135099.htm

图片 3

本文由小鱼儿玄机二站发布于计算机网络,转载请注明出处:职业日志,nginx服务傻子搭建

关键词: