64bit window 7 professional 安装配置 eclipse 与 nginx

jdk, tomcat下载与安装不再说了
建议安装目录如下
D:\Java\jdk1.8.0_77
D:\Java\jre8
D:\Java\tomcat7

================================================================================

下载eclipse并解压
安装目录为D:\Java\eclipse
工作目录为D:\Java-space\espace\0
project-build automatically对勾取消,使用手动clean & build方式
window-open perspective-java, debug
window-show view-console, servers
window-preferences-workspace-utf8
window-preferences-server runtime environments-add-tomcat7(D:\Java\tomcat7)
file-new dynamic web project-HWWebApp, tomcat7, 2.5 ;下一步配置src 编译后输出为WebRoot\WEB-INF\classes;下一步配置hw, WebRoot, web.xml
servers-new server-localhost, lhl_hw, tomcat7;下一步部署项目到此server中(add and remove)
对应项目的eclipse内置tomcat会部署在D:\Java-space\espace\0\.metadata\.plugins\org.eclipse.wst.server.core\tmp0
server.xml - 配置3处端口号 <connector URIEncoding="UTF-8" port="8080" .../> <Connector port="8009" protocol="AJP/1.3" redirectPort="8443"/> <Server port="8005" shutdown="SHUTDOWN">
context.xml - 配置JNDI与一些全局变量
open launch configuration - tomcat jvm 启动参数(-xmx -xms)

================================================================================

下载nginx并解压
安装目录为D:\Prog\nginx-1.12.1
主配置文件conf/nginx.conf内容为(修改前先将原主配置文件备份为nginx.conf.default)
worker_processes 1; #工作进程数
events {
worker_connections 1024; #每一个工作进程同时开启的最大连接数
}

#http-server-location HTTP反向代理
http {
include mime.types;
default_type application/octet-stream;

sendfile on; #允许上传/下载文件

keepalive_timeout 65;
server_names_hash_bucket_size 64;

#后端服务器组
include upstream/*.conf;
#虚拟主机
include conf.d/*.conf;
}
后端服务器组配置文件conf/upstream/upstream_server.conf内容为
#后端服务器组-主站-lhl.cn/
upstream lhl_cn {
#ip_hash;
server 127.0.0.1:80;
}

#后端服务器组-分站-lhl.cn/hw/
upstream lhl_hw {
ip_hash;
server 127.0.0.1:8080;
}

虚拟主机配置文件conf/conf.d/www.lhl.cn.conf内容为
server {
listen 80;
server_name www.lhl.cn;
#rewrite ^/$ /hw last;
location / {
proxy_pass http://lhl_cn;
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;
}
location ^~ /hw {
proxy_pass http://lhl_hw;
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;
}
}

start nginx
nginx -s reload
nginx -s stop

HOSTS配置127.0.0.1 www.lhl.cn

浏览器中访问如下地址

http://www.lhl.cn/hw/
http://www.lhl.cn/hw/MyWebController

posted @ 2018-01-27 12:07  LAUHank  阅读(140)  评论(0编辑  收藏  举报