一、先安装jdk和jboss
3、安装配置nginx
a、安装nginx所需的pcre库
tar -zvxf pcre-7.9.tar.gz
./configure
make && make install
b、安装nginx
tar -zvxf nginx-0.7.61.tar.gz
cd nginx-0.7.61
首先创建nginx目录
mkdir /usr/local/nginx
./configure --prefix=/usr/local/nginx --with-http_stub_status_module
make && make install
c、创建日志文件
mkdir -p /webserver/logs
chmod +w /webserver/logs
d、nginx的配置文件
vi /usr/local/nginx/conf/nginx.conf
以下是nginx.conf文件的内容
#user nobody;
worker_processes 8;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
error_log logs/error.log crit
pid logs/nginx.pid;
#Specifies the value for maximum file descriptors thar can be opened by this process.
worker_rlimit_nofile 51200;
events {
use epoll;
worker_connections 51200;
}
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;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 8m;
sendfile on;
tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 60;(这里最好加上)
tcp_nodelay on;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
server {
listen 80;
server_name 192.168.7.251;
index index.html index.jsp;
root /webserver/national_project;
#charset koi8-r;
#access_log logs/host.access.log main;
location /national_project {
# ssi on;
# ssi_silent_errors on;
# ssi_types text/shtml;
root /webserver/national_project;
index index.html index.jsp;
proxy_pass ;
}
location ~*\national_project(htm|html|gif|jpg|jpeg|png|bmp|ico|rar|css|js|zip|java|jar|txt|flv|swf|wma)$ {
root /webserver/national_project;
# expires 24h; (这里和下面的expires,为了传值,网上很多人说关闭)
}
location ~^/national_project(images|common|expert|home|image|js|organization|post|project)/{
root /webserver/national_project;
# expires 30d;
}
location ~*\national_project(jsp|do|spring)$ {
root /webserver/national_project;
index index.jsp index.html;
include /usr/local/nginx/conf/proxy.conf;
proxy_pass ;
proxy_set_header X-Real-IP $remote_addr;
}
}
server { (这个站点是做监控nginx服务连接的NginxStatus)
listen 802;
server_name 192.168.7.251:802;
location / {
stub_status on;
access_log off;
}
}
# server { (多虚拟站点的设置)
# listen 80;
# server_name ie.haish.com;
# index index.html;
# root /webserver/ie/;
#
# location /icme {
# root /webserver/ie/;
# index index.html index.jsp index.do;
# proxy_pass ;
# }
# location ~*\ie(htm|html|gif|jpg|jpeg|png|bmp|ico|rar|css|js|zip|java|txt|flv|swf|wma)$ {
# expires 24h;
# }
# location ~*/icme(baseInfo|card|common|css|dwrdemo|images|js|learner|login|organization|password|project|purview|qastandard|qualify|report|role|score|student|system|test|uploadfiles|verify)/ {
# root /webserver/icme/;
# expires 30d;
# }
# location ~*\icme(jsp|do)$ {
# root /webserver/icme/;
# index index.jsp index.do;
# include /usr/local/nginx/conf/proxy1.conf;
# proxy_pass ;
# proxy_set_header X-Real-IP $remote_addr;
# }
# }
e、连接jsp的文件
vi /usr/local/nginx/conf/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 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffers 32 4k;
f、启动服务
首先启动jboss
然后启动nginx
/usr/local/nginx/sbin/nginx -t
如果不报错说明配置安装没有问题
启动/usr/local/nginx/sbin/nginx
查看是否启动 ps -ef |grep nginx
如果要开启多个虚拟站点,就需要通过跳转页面来做,同我上面写的apache和jboss的动静分离一样.
NginxStatus功能说明如下:
Active connections: 9
server accepts handled requests
14 14 150
Reading: 0 Writing: 1 Waiting: 8
active connections -- 对后端发起的活动连接数
server accepts handled requests -- nginx 总共处理了 14 个连接, 成功创建 14 次握手 (证明中间没有失败的), 总共处理了 150 个请求
reading -- nginx 读取到客户端的 Header 信息数。
writing -- nginx 返回给客户端的 Header 信息数。
waiting -- 开启 keep-alive 的情况下,这个值等于 active - (reading + writing),意思就是 Nginx 已经处理完正在等候下一次请求指令的驻留连接
访问出现解析后的jsp页面,ok说明我们配置成功。
阅读(4179) | 评论(0) | 转发(0) |