发表于: 2018-04-03 22:40:39

1 684


今天完成的事情:

1.学习了nginx配置文件中的server部分:

  1. #虚拟主机定义
  2.    server {
  3.        #监听端口
  4.        listen       80;
  5.        #访问域名
  6.        server_name  localhost;
  7.        #编码格式,若网页格式与此不同,将被自动转码
  8.        #charset koi8-r;
  9.        #虚拟主机访问日志定义
  10.        #access_log  logs/host.access.log  main;
  11.        #对URL进行匹配
  12.        location / {
  13.            #访问路径,可相对也可绝对路径
  14.            root   html;
  15.            #首页文件。以下按顺序匹配
  16.            index  index.html index.htm;
  17.        }
  18. #错误信息返回页面
  19.        #error_page  404              /404.html;
  20.        # redirect server error pages to the static page /50x.html
  21.        #
  22.        error_page   500 502 503 504  /50x.html;
  23.        location = /50x.html {
  24.            root   html;
  25.        }
  26. #访问URL以.php结尾则自动转交给127.0.0.1
  27.        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
  28.        #
  29.        #location ~ \.php$ {
  30.        #    proxy_pass   http://127.0.0.1;
  31.        #}
  32. #php脚本请求全部转发给FastCGI处理
  33.        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  34.        #
  35.        #location ~ \.php$ {
  36.        #    root           html;
  37.        #    fastcgi_pass   127.0.0.1:9000;
  38.        #    fastcgi_index  index.php;
  39.        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
  40.        #    include        fastcgi_params;
  41.        #}
  42. #禁止访问.ht页面 (需ngx_http_access_module模块)
  43.        # deny access to .htaccess files, if Apache's document root
  44.        # concurs with nginx's one
  45.        #
  46.        #location ~ /\.ht {
  47.        #    deny  all;
  48.        #}
  49.    }
  50. #HTTPS虚拟主机定义
  51.    # HTTPS server
  52.    #
  53.    #server {
  54.    #    listen       443 ssl;
  55.    #    server_name  localhost;
  56.    #    ssl_certificate      cert.pem;
  57.    #    ssl_certificate_key  cert.key;
  58.    #    ssl_session_cache    shared:SSL:1m;
  59.    #    ssl_session_timeout  5m;
  60.    #    ssl_ciphers  HIGH:!aNULL:!MD5;
  61.    #    ssl_prefer_server_ciphers  on;
  62.    #    location / {
  63.    #        root   html;
  64.    #        index  index.html index.htm;
  65.    #    }
  66.    #}

因为只有一个tomcat所以就没做负载均衡,稍微改了一下proxy_pass,已经可以不用访问端口就可以进入tomcat主页了。

一个简单的代理tomcat的8080访问端口;

关于nginx的日志文件配置:

这一段本来是被注释的,可是我看了一下被注释了还是可以输出,不过我还是把注释去掉了,后面的$变量分别表示:

access_log表示输出的路径为logs/access.log,然后通过sort、uniq把日志中的数据提取出来做运算。

关于shell脚本:

第一行要写这个#!/bin/bash声明这是个脚本文件,编辑之后要chmod给脚本文件权限才能运行:

通过nginx的日志文件access.log从中提取数据然后处理生成统计访问IP地址和次数的脚本文件:

IP访问10此,URL访问49次,下面是各个IP的访问次数(这里面IP还有国外的,惊了)

明天计划的事情:

实现动静分离。

安装resin,在resin环境下跑通程序,学习AOP,通过resin日志获得控制台每个方法响应时间以及连接数据库的时间。

收获:

简单的学习了脚本文件,学习了nginx的配置文件,看了2个小时AOPspring切面管理controller和service。

今天遇到的问题:

没有修改hosts文件实现二级域名,原因,win10系统上安装nginx报错,按照网上解决办法没有成功解决问题,直接换到linux上安装了。

动静分离没有实现。

安装resin出现了各种错误,只好卸载了重装,重新安装的时候也是错误不断。


返回列表 返回列表
评论

    分享到