tomcat部署jspgou商城

tomcat和jdk部署jspgou商城

环境:
操作系统:CentOS 7
服务器:192.168.184.137
tomcat:apache-tomcat-7.0.82.tar.gz
jdk:jdk-8u191-linux-x64.tar.gz
jspgou:jspgouV6-ROOT.zip
数据库:mariadb
端口:
tomcat自身服务的端口:8005
tomcat和其他应用通信的端口:8009
tomcat给客户端浏览器访问页面使用的端口:8080

1、基础配置

(1)将机器的内存调高(linux默认1GB,在此实验中将机器调成3G)

调整内存的原因:因为要运行jdk(java环境),需要高的内存才能运行起来,所以调整内存。
2
(2)安装工具,关闭防火墙、selinux

[root@localhost ~]# yum -y install unzip net-tools vim lsof 
[root@localhost ~]# systemctl stop firewalld       # 关闭防火墙
[root@localhost ~]# systemctl disable firewalld    # 开机自动关闭防火墙
[root@localhost ~]# setenforce 0                   # 临时关闭selinux
[root@localhost ~]# vim /etc/selinux/config        # 永久关闭selinux,要重启机器才生效(reboot)
SELINUX=disabled                                   # 将enforcing修改为disabled 

2、安装jdk

下载 jdk-8u191-linux-x64.tar.gz

链接:https://pan.baidu.com/s/1UNZeX_igzXvaMQb6_qDGbw
提取码:ae3v

将文件上传到服务器上

[root@localhost ~]# ls
anaconda-ks.cfg  jdk-8u191-linux-x64.tar.gz
[root@localhost ~]# tar xf jdk-8u191-linux-x64.tar.gz 
[root@localhost ~]# ls
anaconda-ks.cfg  jdk1.8.0_191  jdk-8u191-linux-x64.tar.gz
[root@localhost ~]# mv jdk1.8.0_191/ java
[root@localhost ~]# mv java /usr/local/
[root@localhost ~]# vim /etc/profile       #在文件的最后添加下列内容
JAVA_HOME=/usr/local/java
PATH=$JAVA_HOME/bin:$PATH
export JAVA_HOME PATH
[root@localhost ~]# source /etc/profile    ##让配置文件生效
[root@localhost ~]# java -version          #能查到版本,说明java配置成功
java version "1.8.0_191"
Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)

3、安装tomcat

[root@localhost ~]# wget https://archive.apache.org/dist/tomcat/tomcat-7/v7.0.82/bin/apache-tomcat-7.0.82.tar.gz
[root@localhost ~]# ls
anaconda-ks.cfg  apache-tomcat-7.0.82.tar.gz  jdk-8u191-linux-x64.tar.gz
[root@localhost ~]# tar xf apache-tomcat-7.0.82.tar.gz 
[root@localhost ~]# ls
anaconda-ks.cfg  apache-tomcat-7.0.82  apache-tomcat-7.0.82.tar.gz  jdk-8u191-linux-x64.tar.gz
[root@localhost ~]# mv apache-tomcat-7.0.82  tomcat
[root@localhost ~]# mv tomcat /usr/local/
[root@localhost ~]# vim /etc/profile       #在文件的最后添加下列内容
CATALINA_HOME=/usr/local/tomcat
export CATALINA_HOME
[root@localhost ~]# source /etc/profile      ##让配置文件生效
[root@localhost ~]# /usr/local/tomcat/bin/version.sh    #能查到版本,说明tomcat配置成功  
Using CATALINA_BASE:   /usr/local/tomcat
Using CATALINA_HOME:   /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME:        /usr/local/java
Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Server version: Apache Tomcat/7.0.82
Server built:   Sep 29 2017 12:23:15 UTC
Server number:  7.0.82.0
OS Name:        Linux
OS Version:     3.10.0-693.el7.x86_64
Architecture:   amd64
JVM Version:    1.8.0_191-b12
JVM Vendor:     Oracle Corporation

4、启动Tomcat

[root@localhost ~]# /usr/local/tomcat/bin/startup.sh  
Using CATALINA_BASE:   /usr/local/tomcat
Using CATALINA_HOME:   /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME:        /usr/local/java
Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.

### 关闭tomcat: /usr/local/tomcat/bin/shutdown.sh
[root@localhost ~]# netstat -tnlp | grep java      #检查是否java启动成功
tcp6     0      0 :::8080                :::*              LISTEN      1895/java     
tcp6     0      0 127.0.0.1:8005         :::*              LISTEN      1895/java      tcp6     0      0 :::8009                :::*              LISTEN      1895/java 

netstat的参数讲解:
1

在浏览器测试tomcat是否配置成功 ----192.168.184.137:8080

2
出现以上页面,即tomcat配置安装成功。

5、安装数据库 — 使用mariadb

[root@localhost ~]# yum -y install mariadb mariadb-server mariadb-libs
[root@localhost ~]# systemctl restart mariadb
[root@localhost ~]# systemctl enable mariadb
[root@localhost ~]# mysqladmin -uroot password '123'      #重置密码
[root@localhost ~]# mysql -uroot -p123
MariaDB [(none)]> create database jspgou default charset=utf8;   #建库,设置编码为utf8
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> \q
Bye
[root@localhost ~]# systemctl restart mariadb

6、部署jspgou

上传jspgou文件(使用的是jspgouV6-ROOT.zip,文件在网上自行下载)

[root@localhost ~]# /usr/local/tomcat/bin/shutdown.sh 
[root@localhost ~]# rm -rf /usr/local/tomcat/webapps/ROOT       #删除tomcat原默认文件 
[root@localhost ~]# mkdir jspgou
[root@localhost ~]# unzip jspgouV6-ROOT.zip -d jspgou           #解压jspgou
[root@localhost ~]# ls jspgou
DB  ROOT  必读.txt
[root@localhost ~]# cp -r jspgou/ROOT/ /usr/local/tomcat/webapps/   #jspguo的网站页面       

7、修改配置文件(修改文件/usr/local/tomcat/webapps/ROOT/WEB-INF/config/jdbc.properties)

[root@localhost ~]# vim /usr/local/tomcat/webapps/ROOT/WEB-INF/config/jdbc.properties
#mysql\u914d\u7f6e 
jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://127.0.0.1:3306/jspgou?characterEncoding=UTF-8
jdbc.username=root
jdbc.password=123          #修改此处,填写上密码

8、将页面数据导入数据库

[root@localhost ~]# mysql -uroot -p123 -D jspgou < jspgou/DB/jspgou.sql
[root@localhost ~]# mysql -uroot -p123 -e "use jspgou;show tables;"    #-e参数是在数据库中执行的语句
+------------------------------+
| Tables_in_jspgou             |
+------------------------------+
| jc_address                   |
| jc_api_account               |
| jc_api_info                  |
| jc_api_record                |
| jc_api_user_login            |
....

9、启动tomcat,并测试 — http://192.168.184.137:8080/

[root@localhost ~]# /usr/local/tomcat/bin/startup.sh  
Using CATALINA_BASE:   /usr/local/tomcat
Using CATALINA_HOME:   /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME:        /usr/local/java
Using CLASSPATH:       /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat started.

访问浏览器 (管理员默认登录信息:用户名admin 密码123456)
4如果出现报错,请看下边的报错讲解。

报错:

1、500错误
5
(1)首先先停止tomcat,再重新启动

[root@localhost ~]# /usr/local/tomcat/bin/shutdown.sh  
[root@localhost ~]# /usr/local/tomcat/bin/startup.sh  

如果没有解决,查看是否是数据库的原因,见第(2)步

(2)查看数据库是否启动

[root@localhost ~]# netstat -nltp |grep 3306
[root@localhost ~]# systemctl restart mariadb

wn.sh
[root@localhost ~]# /usr/local/tomcat/bin/startup.sh


如果没有解决,查看是否是数据库的原因,见第(2)步

(2)查看数据库是否启动

```bash
[root@localhost ~]# netstat -nltp |grep 3306
[root@localhost ~]# systemctl restart mariadb

再次访问即可。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值