nginx1.9+tomcat配置
来源:互联网 发布:杨丽音 知乎 编辑:程序博客网 时间:2024/04/29 16:37
安装教程可参考:http://www.cnblogs.com/super-d2/p/3662215.html
一、下载地址
Nginx:http://nginx.org/en/download.html
Tomcat:http://tomcat.apache.org/
1、解压Nginx到:E:\server\nginx-1.2.9
命令行启动Nginx以下几种,任选:
1、start nginx(推荐)
2、nginx.exe
若果想停止nginx,dos环境运行命令以下几种:
1、nginx -s stop(直接停止服务,不一定能对信息保存完整)
2、nginx -s quit(推出服务,在保存所有信息后自行退出)
3、直接去进程中关闭所有nginx.exe程序
二、Nginx配置:
Nginx配置文件默认在conf目录,主要配置文件为nginx.conf,我们安装在E:\server\nginx-1.2.9、默认主配置文件为E:\server\nginx-1.2.9\nginx.conf。下面是nginx作为前端反向代理服务器的配置。
以下3个文件都放置在nginx-1.2.9.1\conf目录下:
nginx.conf
#Nginx所用用户和组#user niumd niumd;#工作的子进程数量(通常等于CPU数量或者2倍于CPU)worker_processes 2;#错误日志存放路径#error_log logs/error.log;#error_log logs/error.log notice;error_log logs/error.log info;#指定pid存放文件pid logs/nginx.pid;events { #使用网络IO模型linux建议epoll,FreeBSD建议采用kqueue #use epoll; #允许最大连接数 worker_connections 2048;}http { include mime.types; default_type application/octet-stream; #定义日志格式 #log_format main '$remote_addr - $remote_user [$time_local] $request ' # '"$status" $body_bytes_sent "$http_referer" ' # '"$http_user_agent" "$http_x_forwarded_for"'; #access_log off; access_log logs/access.log; client_header_timeout 3m; client_body_timeout 3m; send_timeout 3m; client_header_buffer_size 1k; large_client_header_buffers 4 4k; sendfile on; tcp_nopush on; tcp_nodelay on; #keepalive_timeout 75 20; <span style="color:#ff0000;"> include gzip.conf;</span>
upstream localhost { #ip_hash #ip_hash; server localhost:8080; server localhost:8801; } <span style="color:#ff0000;">inclue proxy.conf;</span>server { listen 80; server_name localhost; location / { proxy_connect_timeout 3; proxy_send_timeout 30; proxy_read_timeout 30; proxy_pass http://localhost; } }}
Proxy.conf
proxy_redirect off;proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;client_max_body_size 10m;client_body_buffer_size 128k;proxy_connect_timeout 300;proxy_send_timeout 300;proxy_read_timeout 300;proxy_buffer_size 4k;proxy_buffers 4 32k;proxy_busy_buffers_size 64k;proxy_temp_file_write_size 64k;#gzip on;#gzip_min_length 1000;#gzip_types text/plain text/css application/x-javascript;
Gzip.conf
gzip on;gzip_min_length 1000;gzip_types text/plain text/css application/x-javascript;
注意一定要注意nginx.conf中红色标记的引入文件;不然就会一直处于连接访问状态;
三、Tomcat配置
配置两个tomcat7,要求shutdown/http/ajp3个地方的端口都不能相互冲突,保证两个tomcat能够同时正常运行;
四、测试
开启tomcat,开启nginx,在IE中访问http://localhost/查看是否出现tomcat的欢迎界面;如果想看不同的效果可自行去修改tomcat自带的index.jsp代码,做一下mark
- nginx1.9+tomcat配置
- Nginx1.9 配置TCP负载均衡
- linux nginx1.9.2+tomcat8 配置 多tomcat负载均衡,并使静态文静不通过tomcat解析
- CentOS配置nginx1.8.0
- Nginx1.10.1安装配置
- centos6.9源码安装nginx1.12.2并配置php7
- nginx1.6.2配置实例-线上
- nginx1.8.1配置反向代理
- nginx1.8.1配置反向代理
- nginx1
- nginx1
- CentOS6.5+Nginx1.9+Mysql5.7+PHP7.0.6(LNMP)环境配置
- REHL5.4 配置nginx1.2.0 PHP5.3.10
- Windows下nginx1.x + php5环境配置
- Nginx1.8运行Laravel5的配置
- nginx1.6 centos6.5 安装配置
- nginx1.6.2+tomcat8.0.36 配置https
- CentOS6.5安装配置Nginx1.11.5
- c++ 实现结构体单链表的 创建 插入 删除等操作
- Linux GCC 编译 指令------- -c -o
- Android中通过intent启动另一个应用
- Windows平台下解决Oracle12c使用PDB数据库创建SDE的问题
- R语言画图——par()参数介绍
- nginx1.9+tomcat配置
- Eclipse将引用了第三方jar包的Java项目打包成jar文件的两种方法
- 自定义倒计时TextView控件
- GenericServlet为什么有两个init方法
- 瀑布流demo(完美注释)
- POJ-1006 Biorhythms (中国剩余定理)
- SAT数学考题知识范围增量分析
- 数据结构存储的顺序和链式对比
- Comparable接口的实现和使用