部署tomcat http server
环境6-8G内存
[root@dell710 ~]# systemctl stop firewalld
[root@dell710 ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.
[root@dell710 ~]# vim /etc/selinux/config
将SELINUX=enforcing改为SELINUX=disabled
[root@dell710 ~]# setenforce 0
1、部署java环境
提示:建议卸载默认安装openjdk软件
官网下载jdk
1)解压安装包
[root@dell710 ~]# tar xf jdk-8u151-linux-x64.tar.gz -C /usr/local #8u版本均可
2)多版本部署java
[root@dell710 local]# ln -s /usr/local/jdk1.8.0_151/ /usr/local/java
3)配置环境变量
[root@dell710 ~]# vim /etc/profile
JAVA_HOME=/usr/local/java
PATH=$JAVA_HOME/bin:$PATH
export JAVA_HOME PATH
[root@dell710 ~]# env |grep JAVA
JAVA_HOME=/usr/local/java
4)测试java
[root@dell710 ~]# java -version
java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)
2、安装tomcat
[root@dell710 ~]# tar xf apache-tomcat-8.5.11.tar.gz -C /usr/local/
[root@dell710 ~]# ln -s /usr/local/apache-tomcat-8.5.11/ /usr/local/tomcat
#定义Tomcat所需环境变量:
[root@dell710 ~]# vim /etc/profile
CATALINA_HOME=/usr/local/tomcat #Tomcat安装目录
export CATALINA_HOME
[root@dell710 ~]# source /etc/profile
3、启动tomcat
1)启动tomcat
[root@dell710 ~]# bash /usr/local/tomcat/bin/startup.shUsing CATALINA_BASE: /usr/local/tomcatUsing
CATALINA_HOME: /usr/local/tomcatUsing
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.
2)检查端口
[root@dell710 ~]# netstat -tnlp |grep java
tcp6 0 0 :::8080 :::* LISTEN 4488/java
tcp6 0 0 127.0.0.1:8005 :::* LISTEN 4488/java
tcp6 0 0 :::8009 :::* LISTEN 4488/java
关于tomcat端口:
8005:是tomcat本身的端口
8080:tomcat负责建立HTTP连接。在通过浏览器访问Tomcat服务器的Web应用时,使用的就是这个连接器。
8009:tomcat负责和其他的HTTP服务器建立连接。(如nginx和apache互通时使用)
关闭tomcat方法
#bash /usr/local/tomcat/bin/shutdown.sh
3)访问
http://10.18.45.133:8080/ 注意:服务器地址,注意端口
4)关于tomcat
默认网站的工作目录:
[root@dell710 ~]# ls /usr/local/tomcat/webapps/
docs examples host-manager manager ROOT
默认网站的主目录(主页)
[root@dell710 ~]# ls /usr/local/tomcat/webapps/ROOT
asf-logo-wide.svg bg-middle.png bg-nav.png favicon.ico RELEASE-NOTES.txt tomcat.gif tomcat-power.gif WEB-INF
bg-button.png bg-nav-item.png bg-upper.png index.jsp tomcat.css tomcat.png tomcat.svg
安装MySQL
创建数据库
创建jspgou数据库,字符集为utf-8
[root@dell710 ~]# yum install -y mariadb-server mariadb
[root@dell710 ~]# systemctl start mariadb
[root@dell710 ~]# systemctl enable mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to
/usr/lib/systemd/system/mariadb.service.
[root@dell710 ~]# mysqladmin -u root password 123
[root@dell710 ~]# mysql -u root -p123
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 3Server version: 5.5.60-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> create database jspgou character set = utf8;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]>
部署jsgou(电子商城)
1、解压源码
[root@dell710 ~]# unzip jspgouV6-ROOT.zip
2、更改数据库链接
提示:在解压缩后的文件中,修改连接数据库的信息
[root@dell710 ~]# vim jspgouV6-ROOT/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
3、导入数据
[root@dell710 ~]# cd jspgouV6-ROOT/
[root@dell710 jspgouV6-ROOT]# lsDB ROOT 必读.txt
[root@dell710 jspgouV6-ROOT]# mysql -u root -p123 -D jspgou < DB/jspgou.sql
错误
使用mysql作为数据库时,如果导入数据失败
1.修改mysql配置文件
my.cnf中max_allowed_packet参数为64m,默认为1m
2.DB/jspgou.sql里面的默认值改一下
把所有datetime类型的字段默认值改成CURRENT_TIMESTAMP
4、部署网站
1)将程序解压后的ROOT文件夹,拷贝到tomcat安装目录下的webapps文件夹下
[root@dell710 jspgouV6-ROOT]# \cp -r ROOT /usr/local/tomcat/webapps/
[root@dell710 jspgouV6-ROOT]# bash /usr/local/tomcat/bin/startup.sh
2)访问
http://10.18.45.133:8080/jeeadmin/jspgou/index.do 注意:服务器地址
用户名:admin
密 码:123456
点击上图右上角浏览器图标访问网站首页