发表于: 2018-04-03 22:40:39
1 684
今天完成的事情:
1.学习了nginx配置文件中的server部分:
#虚拟主机定义
server {
#监听端口
listen 80;
#访问域名
server_name localhost;
#编码格式,若网页格式与此不同,将被自动转码
#charset koi8-r;
#虚拟主机访问日志定义
#access_log logs/host.access.log main;
#对URL进行匹配
location / {
#访问路径,可相对也可绝对路径
root html;
#首页文件。以下按顺序匹配
index index.html index.htm;
}
#错误信息返回页面
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
#访问URL以.php结尾则自动转交给127.0.0.1
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
#php脚本请求全部转发给FastCGI处理
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
#禁止访问.ht页面 (需ngx_http_access_module模块)
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
#HTTPS虚拟主机定义
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
因为只有一个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出现了各种错误,只好卸载了重装,重新安装的时候也是错误不断。
评论