部署项目到Linux服务器步骤

2 篇文章 0 订阅
2 篇文章 0 订阅

2.3.2.服务器规划




项目                      服务器数量                       虚拟机         ip
----------------------------------------------------------------------------------------------------------------------
Mysql                   2                               1               134
Solr                    7                               1               154
Redis                   6                               1               153
图片服务器               2                               1               133
Nginx                   2                               1               141
注册中心                    3                               1               167
Activemq                2                               1               168
                    服务器端口               工具端口
e3-manager            8080                   8080
e3-content            8081                   8083
e3-search             8082                   8084                           
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  1           135
e3-sso                8080                   8087
e3-cat                8081                   8089
e3-order              8082                   8091
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  1           136
e3-manager-web        8080                   8081
e3-portal-web         8081                   8082
e3-search-web         8082                   8085
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  1           137
e3-item-web           8080                   8086
e3-sso-web            8081                   8088
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  1           138
e3-cart-web           8080                   8090
e3-order-web          8081                   8092
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  1           139

2.3.3.域名规划
序号  工程名 域名
1   e3-manager-web      manager.e3mall.cn
2   e3-portal-web       www.e3mall.cn
3   e3-search-web       search.e3mall.cn
4   e3-item-web         item.e3mall.cn
5   e3-sso-web          sso.e3mall.cn
6   e3-cart-web         cart.e3mall.cn
7   e3-order-web        order.e3mall.cn

一:首先部署好Mysql Solr Redis 图片服务器 Nginx 注册中心 Activemq 等服务器

二:把taotaotomcat 服务器部署到135,136,137,138,139这三个服务器上,并且打开端口8080,8081,8082
其中135,服务器记得打开dubbo中的20880,20881,20882这三个端口,
136,服务器记得打开dubbo中的20884,20885,20886这三个端口,具体情况具体操作
如果没有打开这几个端口,消费者就没法消费这几个服务,导致500异常

三:然后把这些服务分别使用maven跟Tomcat热部署到服务器
第一步:需要修改tomcat的conf/tomcat-users.xml配置文件。添加用户名、密码、权限。

    <role rolename="manager-gui" />
        <role rolename="manager-script" />
    <user username="tomcat" password="tomcat" roles="manager-gui, manager-script"/>
第二步:重新启动tomcat。
使用maven的tomcat插件实现热部署:
第一步:配置tomcat插件,需要修改工程的pom文件。
<build>
        <plugins>
            <!-- 配置Tomcat插件 -->
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <configuration>
                    <port>8081</port>
                    <path>/</path>
                    <url>http://192.168.25.135:8080/manager/text</url>
                    <username>tomcat</username>
                    <password>tomcat</password>
                </configuration>        
            </plugin>
        </plugins>
    </build>
第二步:使用maven命令进行部署。
tomcat7:deploy
tomcat7:redeploy
部署的路径是“/”会把系统部署到webapps/ROOT目录下。
部署工程跳过测试:
clean tomcat7:redeploy -DskipTests

四: 这个时候虽然可以使用ip地址的方式访问服务器,但是会发现Cookie有关的服务都会失效,
此时就需要反向代理的配置,因为使用Cookie必须要识别有www.e3mall.cn这种地址形式才会形成Cookie
切记要把web项目下面的所有内容全部改为域名的形式,这样才会事Cookie生效!

五: 反向代理的配置,
测试时使用域名访问网站,需要修改host文件。所有的域名应该指向反向代理服务器。
配置hosts文件:

    192.168.25.128 manager.e3mall.cn
    192.168.25.128 www.e3mall.cn
    192.168.25.128 search.e3mall.cn
    192.168.25.128 item.e3mall.cn
    192.168.25.128 sso.e3mall.cn
    192.168.25.128 cart.e3mall.cn
    192.168.25.128 order.e3mall.cn

六:配置nginx中cof下面的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;

    upstream manager.e3mall.cn {
    server 192.168.25.137:8080;
    }
    upstream www.e3mall.cn {
    server 192.168.25.137:8081;
    }
    upstream search.e3mall.cn {
    server 192.168.25.137:8082;
    }
    upstream item.e3mall.cn {
    server 192.168.25.138:8080;
    }
    upstream sso.e3mall.cn {
    server 192.168.25.138:8081;
    }
    upstream cart.e3mall.cn {
    server 192.168.25.139:8080;
    }
    upstream order.e3mall.cn {
    server 192.168.25.139:8081;
    }

   server {
        listen       80;
        server_name  manager.e3mall.cn;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            proxy_pass   http://manager.e3mall.cn;
            index  index.html index.htm;
        }
    }
    server {
        listen       80;
        server_name  www.e3mall.cn;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            proxy_pass   http://www.e3mall.cn;
            index  index.html index.htm;
        }
    }
    server {
        listen       80;
        server_name  search.e3mall.cn;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            proxy_pass   http://search.e3mall.cn;
            index  index.html index.htm;
        }
    }
    server {
        listen       80;
        server_name  item.e3mall.cn;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            proxy_pass   http://item.e3mall.cn;
            index  index.html index.htm;
        }
    }
    server {
        listen       80;
        server_name  sso.e3mall.cn;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            proxy_pass   http://sso.e3mall.cn;
            index  index.html index.htm;
        }
    }
    server {
        listen       80;
        server_name  cart.e3mall.cn;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            proxy_pass   http://cart.e3mall.cn;
            index  index.html index.htm;
        }
    }
    server {
        listen       80;
        server_name  order.e3mall.cn;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            proxy_pass   http://order.e3mall.cn;
            index  index.html index.htm;
        }
    }
}

七:此时项目基本配置完成,剩下的就是把项目里面的所有ip地址都改为域名,记得改resources中的配置文件也要改为域名的形式!
比如:e3-order-web中的conf/resource.properties文件中的SSO_URL=http://sso.e3mall.cn

此时就大功告成了,项目完美的跑起来吧!

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值