linux下安装并配置nginx 多个域名 tomcat集群



一.安装nignx

解压 

tar -zxvf nginx-1.8.0.tar.gz

新加文件夹

mkdir /root/nginx

进入目录
     cd nginx-1.8.0

设置一下配置信息,或者不执行此步,直接默认配置

 ./configure --prefix=/root/nginx --with-http_stub_status_module --with-http_ssl_module--with-http_realip_module

编译

make

安装

make install 


配置两个项目的tomcat集群:

cd nginx/conf/

vim nginx.conf


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;

   upstream q1 {

       server127.0.0.1:8080 weight=5;

       server127.0.0.1:8081 weight=5;

       server127.0.0.1:8082 weight=5;

       server127.0.0.1:8083 weight=5;

   }

   upstream  q2 {

       server123.45.22.222:8080 weight=5;

       server123.45.22.222:8090 weight=5;

   }

   server {

       listen      80;

       server_name  localhost;

       #charsetkoi8-r;

       #access_log  logs/host.access.log  main;

       location/项目名1 {

           root   html;

           index  index.html index.htm;

           proxy_pass http://q1;

       }

      location /项目名2 {

           root   html;

           index  index.html index.htm;

           proxy_pass http://q2;

       }

       #error_page  404              /404.html;

80为监听的默认端口号,可以修改


二.启动nginx


三.修改server.xml端口号(4个)

cd /usr/local/tomcat04/conf

vim server.xml

注:每个配置文件修改3个端口号:8005 8009 8080


四.启4tomcat



-------------------------------------------------------------------------------------

启动停止重启与测试
    1) 启动
        #方法1  指定配置文件启动
        # /usr/local/nginx/sbin/nginx -c/usr/local/nginx/conf/nginx.conf
        #方法2  默认的配置文件
        # cd /usr/local/nginx/sbin
        # ./nginx

    2) 停止
        #查询nginx主进程号
        ps -ef | grep nginx
        #强制停止
        pkill -9 nginx
    3) 重启
        /usr/local/nginx/sbin/nginx -s reload
    4) 测试
       #测试端口
        netstat -na | grep 80
        #浏览器中测试
        http://ip:80

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值