Nginx+Tomcat web站(Linux)   +windows

Nginx+Tomcat web站(Linux)

1、Nginx+Tomcat  Web站

2、JDK+Apache Tomcat (jsp)服务器配置(Windows)


OS


IP


子网掩码


路由网关


Centos6.6

nginx


Eth0:192.168.26.211


255.255.252.0


192.168.25.3


Eth1:192.168.30.3


24


Centos6.6

tomcat


Eth0:192.168.30.1


24


Win7

client


Eth0:192.168.25.159


255.255.252.0


192.168.25.3

node1:设置IP:ifconfig eth0 192.168.30.1/24 up

ip a

node2:双网卡

ifconfig eth0 192.168.26.211/22 up

ifconfig eht1 192.168.30.3/24 up

ip a

安装NGINX:

配置 nginx配置文件:vim /etc/nginx/nginx.conf

#user  nobody;

worker_processes  1;

#error_log  logs/error.log;

#error_log  logs/error.log  notice;

#error_log  logs/error.log  info;

#pid        logs/nginx.pid;

events {

worker_connections  1024;

}

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  logs/access.log  main;

sendfile        on;

#tcp_nopush     on;

#keepalive_timeout  0;

keepalive_timeout  65;

#gzip  on;

server {

listen       80;

server_name  localhost;

#charset koi8-r;

#access_log  logs/host.access.log  main;

location / {

#root   html;

#index  index.html index.htm;

proxy_pass http://192.168.30.1:8080;

}

#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;

}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80

#

#location ~ \.php$ {

#    proxy_pass   http://127.0.0.1;

#}

# 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;

#}

# deny access to .htaccess files, if Apache‘s document root

# concurs with nginx‘s one

#

#location ~ /\.ht {

#    deny  all;

#}

}

# another virtual host using mix of IP-, name-, and port-based configuration

#

#server {

#    listen       8000;

#    listen       somename:8080;

#    server_name  somename  alias  another.alias;

#    location / {

#        root   html;

#        index  index.html index.htm;

#    }

#}

# 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;

#    }

#}

}

动静分离示例:nginx.conf

#user  nobody;

worker_processes  1;

#error_log  logs/error.log;

#error_log  logs/error.log  notice;

#error_log  logs/error.log  info;

#pid        logs/nginx.pid;

events {

worker_connections  1024;

}

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  logs/access.log  main;

sendfile        on;

#tcp_nopush     on;

#keepalive_timeout  0;

keepalive_timeout  65;

#gzip  on;

server {

listen       80;

server_name  localhost;

#charset koi8-r;

#access_log  logs/host.access.log  main;

location / {

root   html;

index  index.html index.htm;

}

location ~* \.(jsp|do)$ {

proxy_pass http://192.168.30.1:8080;

}

#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;

}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80

#

#location ~ \.php$ {

#    proxy_pass   http://127.0.0.1;

#}

# 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;

#}

# deny access to .htaccess files, if Apache‘s document root

# concurs with nginx‘s one

#

#location ~ /\.ht {

#    deny  all;

#}

}

# another virtual host using mix of IP-, name-, and port-based configuration

#

#server {

#    listen       8000;

#    listen       somename:8080;

#    server_name  somename  alias  another.alias;

#    location / {

#        root   html;

#        index  index.html index.htm;

#    }

#}

# 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;

#    }

#}

}

jdk+apache tomcat (jsp)服务器配置(windows)

服务器:win 2008(192.168.26.70)

先安装JDK:双击运行安装JDK

安装完成后查看java(jdk)生成的文件

C:\Program Files\Java

设置JAVA环境变量:

二、配置JDK环境变量(在步骤查看如何配置环境变量)

1,新建变量名:JAVA_HOME,变量值:C:\Program Files\Java\jdk1.8.0_101

2,打开PATH,添加变量值:%JAVA_HOME%\bin;%JAVA_HOME%\jre\bin

3,新建变量名:CLASSPATH,变量值:.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar

备注:

1,.表示当前路径,%JAVA_HOME%就是引用前面指定的JAVA_HOME;

2,JAVA_HOME指明JDK安装路径,此路径下包括lib,bin,jre等文件夹,tomcat,eclipse等的运行都需要依靠此变量。

3,PATH使得系统可以在任何路径下识别java命令。

4,CLASSPATH为java加载类(class or lib)路径,只有类在classpath中,java命令才能识别。

测试是否安装成功:java -version

安装TOMCAT:双击运行安装包

端口默认为8080,这里我们更改为8081服务器端口被其它程序占用了。

安装成功后,到安装路径可以查看安装生成的文件

C:\Program Files\Apache Software Foundation\Tomcat 7.0

其中root即为我们TOMCAT程序(JSP)页根目录。

安装成功即可访问TOMCAT默认页。

我们自己写一个JSP项测试下访问效果。

index.jsp脚本:

<%@ page language="java"%>

<%@ page import="java.util.*"%>

<html>

<head>

<title> JSP TEST PAGE </title>

</head>

<body>

<%

out.println("hello world!");

out.println("hello jerry!");

%>

</body>

</html>

测试访问:http://192.168.26.70:8081/testapp

把ROOT下面默认页删除,把测试页放root下可以直接输入IP:端口访问

后台管理页:

时间: 2024-08-27 03:57:09

Nginx+Tomcat web站(Linux)   +windows的相关文章

Visual Studio2015发布web站点到windows azure Cloud Service(PAAS)

我们上一篇文章介绍了,通过visual studio2015发布站点到windows azure的VM(Microsoft Vsitual Machines)下,那是所谓的IAAS方式,今天呢.我们使用visural studio2015发布站点到windows azure 的Cloud Services,这就是PAAS服务模式.PaaS是Platform-as-a-Service的缩写,意思是平台即服务.把服务器平台作为一种服务提供的商业模式.而计算机时代相应的服务器平台或者开发环境作为服务进

Nginx做web服务器linux内核参数优化

关于Linux内核参数的优化: net.ipv4.tcp_max_tw_buckets = 6000 timewait的数量,默认是180000. net.ipv4.ip_local_port_range = 1024 65000 允许系统打开的端口范围. net.ipv4.tcp_tw_recycle = 1 启用timewait快速回收. net.ipv4.tcp_tw_reuse = 1 开启重用.允许将TIME-WAIT sockets重新用于新的TCP连接.

100513、nginx+tomcat集群+session共享(linux)

第一步:linux中多个tomcat安装和jdk安装(略) 第二步:nginx安装,linux中安装nginx和windows上有点不同也容易出错,需要编译,这里做介绍 一.安装依赖 gcc openssl-fips-2.0.2.tar.gz zlib-1.2.7.tar.gz pcre-8.21.tar.gz 下载linux版本的安装包,如果不下载安装包,可以在线安装命令: yum install gcc-c++ yum install -y pcre  pcre-devel yum inst

Nginx+Tomcat整合的安装与配置(win.linux)

//原帖 http://zyjustin9.iteye.com/blog/2017394 上面是windows系统,linux直接下拉到分割线. 相信很多人都听过nginx,这个小巧的东西慢慢地在吞食apache和IIS的份额.那究竟它有什么作用呢?可能很多人未必了解. 说到反向代理,可能很多人都听说,但具体什么是反向代理,很多人估计就不清楚了.摘一段百度百科上的描述: 反向代理(Reverse Proxy)方式是指以代理服务器来接受internet上的连接请求,然后将请求转发给内部网络上的服务

Linux(ubuntu12.04)下搭建Nginx+Tomcat

首先是安装包的准备nginx7.9:下载nginx  |tomcat7.0下载tomcat  |JDk下载JDK7.0 Nginx的优点太多太多,比apache好很多,更加稳定,功能更加强悍,越来越多的开发人员选择使用nginx来替代apache!! 具体查看这篇文章http://blog.csdn.net/a454211787/article/details/22494485 首先,我们配置jdk,下载好jdk之后,我的默认实在download下面,然后使用linux命令解压 $tar zxv

windows下nginx+tomcat+memcache负载均衡tomcat集群session共享搭建

使用nginx 做负载均衡 memcached处理session共享  环境 windows 7  X64  java : jdk-7windows-x64.rar  nginx : http://nginx.org/en/download.html ,这里我们推荐下载稳定版(stable versions),本文采用nginx-1.8.0  tomcat:apache-tomcat-7.0.63 在同一台电脑上配置多个tomcat(本次采用两个tomcat来示范),修改 conf/server

高性能Web服务之Nginx+Tomcat实现负债均衡反向代理及动静分离

在实际生产中,Tomcat服务器一般不单独使用在项目中,对于静态资源的响应Nginx表现的比较好,另外由于nginx是专门用于反向代理的服务器,所以很容易实现将java的请求转发到后端交给tomcat容器处理,而本身用来处理静态资源. 通常tomcat前端是nginx或apache,后端都为tomcat,也就意味着无论前端是什么角色都是以代理的方式进行工作的;但是要注意的是如果基于nginx做反向代理,转发请求到tomcat的时候是基于http协议进行转发的:但注意的是tomcat的连接器有ht

linux nginx + tomcat

linux下Nginx+tomcat整合的安装与配置 目的:搭建Nginx与tomcat整合,用Nginx代替apache 步骤:一.安装Tomcat和JDK 1.上传apache-tomcat-6.0.18.tar.gz和jdk-6u12-linux-i586.bin至/usr/local2.执行如下命令安装tomcat: 1.#cd /usr/local 2.#tar zxvf apache-tomcat-6.0.18.tar.gz 解压完成后将apache-tomcat-6.0.18重命名

基于nginx tomcat redis分布式web应用的session共享配置

一.前言 nginx 作为目前最流行的开源反向代理HTTP Server,用于实现资源缓存.web server负载均衡等功能,由于其轻量级.高性能.高可靠等特点在互联网项目中有着非常普遍的应用,相关概念网上有丰富的介绍.分布式web server集群部署后需要实现session共享,针对 tomcat 服务器的实现方案多种多样,比如 tomcat cluster session 广播.nginx IP hash策略.nginx sticky module等方案,本文主要介绍了使用 redis