准备三台服务器
1.192.168.100.20 nginx
2.192.168.100.30 Java环境server1
3.192.168.100.40 Java环境server2
配置Java环境
解压压缩包
java.sh脚本导入到环境变量,使其生效并查看版本
写段Java小脚本,测试是否可以正常工作
执行:javac abc.java 编译后生成可执行文件
测试:java abc
原样输出则为成功!
下面安装tomcat:
启动tomcat ,监听8080端口
加入测试页面
创建web目录
优化启动时间
nginx配置
yum install pcre-devel zlib-devel openssl-devel gcc gcc-c++ make -y
groupadd www
useradd -g www www -s /bin/false
tar zxvf nginx-1.6.0.tar.gz -C /opt
cd /opt/nginx-1.6.0/
./configure \
--prefix=/usr/local/nginx \
--user=www \
--group=www \
--with-file-aio \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--with-http_flv_module \
--with-http_ssl_module
make && make install
vi /usr/local/nginx/conf/nginx.conf
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
upstream tomcat_server {
server 192.168.100.30:8080 weight=1;
server 192.168.100.40:8080 weight=1;
}
server {
listen 80;
.....省略
location / {
root html;
index index.html index.htm;
proxy_pass http://tomcat_server;
}
/usr/local/nginx/sbin/nginx -t //检测是否成功//
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/
nginx //启用nginx服务//
netstat -ntap | grep nginx
systemctl restart nginx // 重启nginx//