基于nginx+tomcat部署商城系统并连接数据库

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了基于nginx+tomcat部署商城系统并连接数据库相关的知识,希望对你有一定的参考价值。

需三台服务器
nginx 192.168.200.111
tomcat 192.168.200.112
tomcat 192.168.200.113

192.168.200.111
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
[root@localhost ~]# iptables -F
[root@localhost ~]# vim /usr/local/nginx/conf/nginx.conf
32 upstream tomcat_server {
33 ip_hash;
34 server 192.168.200.112:8080 weight=1;
35 server 192.168.200.113:8080 weight=1;
36 }
47 location / {
48 root html;
49 index index.html index.htm;
50 proxy_pass http://tomcat_server;
51 proxy_set_header Host $http_host;
52 }
[root@localhost ~]# killall -1 nginx
[root@localhost ~]# yum -y install mariadb mariadb-server
[root@localhost ~]# systemctl start mariadb
[root@localhost ~]# mysql
MariaDB [(none)]> grant all on slsaledb.* to admin@‘%‘ identified by ‘123456‘;
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> exit
[root@localhost ~]# mysql -uroot < slsaledb-2014-4-10.sql
[root@localhost ~]# systemctl restart mariadb

tomcat 192.168.200.112 / tomcat 192.168.200.113

[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# setenforce 0
[root@localhost ~]# iptables -F
[root@localhost ~]# mkdir /web/webapp -pv
[root@localhost ~]# tar fx SLSaleSystem.tar.gz -C /web/webapp
[root@localhost ~]# vim /usr/local/tomcat8/conf/server.xml
150 <Context docBase="/web/webapp/SLSaleSystem" path="" reloadable="flase"></Context>
[root@localhost ~]# vim /web/webapp/SLSaleSystem/WEB-INF/classes/jdbc.properties
driverClassName=com.mysql.jdbc.Driver
url=jdbc:mysql://192.168.200.111:3306/slsaledb?useUnicode=true&characterEncoding=UTF-8
uname=admin
password=123456
minIdle=10
maxIdle=50
initialSize=5
maxActive=100
maxWait=100
removeAbandonedTimeout=180
removeAbandoned=true
[root@localhost ~]# /usr/local/tomcat8/bin/shutdown.sh
[root@localhost ~]# /usr/local/tomcat8/bin/startup.sh

 

以上是关于基于nginx+tomcat部署商城系统并连接数据库的主要内容,如果未能解决你的问题,请参考以下文章

第二十期:基于tomcat部署jforum站点,并结合nginx实现动静分离

谷粒商城项目总结

Nginx之美多商城前台部署

Tomcat之Nginx+Tomcat实现负载均衡动静分离集群部署

单台主机nginx+tomcat+mencached部署测试

LNMT群集基于Redis实现Session共享