标签:nginx+tomcat web站(linux) jsp 服务器
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:端口访问
后台管理页:
本文出自 “在路上” 博客,请务必保留此出处http://jdonghong.blog.51cto.com/3473478/1883338
Nginx+Tomcat web站(Linux) +windows
标签:nginx+tomcat web站(linux) jsp 服务器
原文地址:http://jdonghong.blog.51cto.com/3473478/1883338