项目文件:
jdk-8u221-linux-x64.tar.gz
apache-tomcat-7.0.104.tar.gz
mysql-5.7.27-1.el7.x86_64.rpm-bundle.tar
以上软件下载安装就不在这里演示了
搭建项目测试环境
1、在Vmware虚拟机最小安装CentOS7(安装好linux系统可忽略)
2、配置Java运行环境
mkdir /usr/local/java
tar -xzvf jdk-8u221-linux-x64.tar.gz -C /usr/local/java/
vim /etc/profile
export JAVA_HOME=/usr/local/java/jdk1.8.0_221
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=. (最后的那个点不要忘了)
source /etc/profile (配置好环境变量刷新一下即可生效)
java -version, javac (查看java版本信息)
3、安装Tomcat并启动服务器
tar -xzvf apache-tomcat-7.0.104.tar.gz -C /usr/local/ (解压到指定位置)
mv /usr/local/apache-tomcat-7.0.104/ /usr/local/tomcat (重命名)
/usr/local/tomcat/bin/startup.sh (运行tomcat)
4、安装 MySQL数据库服务器
mkdir mysqlrpms
tar -xvf mysql-5.7.27-1.el7.x86_64.rpm-bundle.tar -C mysqlrpms
cd mysqlrpms/
yum install mysql-community-server-5.7.27-1.el7.x86_64.rpm
yum install mysql-community-common-5.7.27-1.el7.x86_64.rpm
原因是:mysql-community-common 与 mariadb-libs冲突
rpm -qa |grep mariadb
yum remove mariadb-libs #卸载后即可解决冲突
yum install mysql-community-common-5.7.27-1.el7.x86_64.rpm
yum install mysql-community-client-5.7.27-1.el7.x86_64.rpm
yum install mysql-community-libs-5.7.27-1.el7.x86_64.rpm
yum install mysql-community-client-5.7.27-1.el7.x86_64.rpm
yum install mysql-community-server-5.7.27-1.el7.x86_64.rpm
启动数据库
systemctl start mysqld
查看数据库临时密码
grep 'temporary password' /var/log/mysqld.log
登录后修改密码:
mysql -u root -p
mysql> mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
或者
mysql> set password for 'root'@'localhost'=password('MyNewPass4!');
修改数据库密码安全策略 vim /etc/my.cnf
添加 validate_password = off 禁用密码安全策略
systemctl restart mysqld 重启
5、在以上步骤都完成之后,部署项目war包到tomcat项目目录(此b2c指的是自己项目文件夹的名字)
cp b2c.war /usr/local/tomcat/webapps/
lynx http://localhost:8080测试
修改selinux设置
/etc/selinux/config
查看当前所有启动的服务
systemctl list-unit-files |grep enabled
systemctl list-unit-files |grep fire
关闭防火墙
systemctl stop firewalld
6、浏览器访问项目并完成初始设置
http://ip:8080/b2c
等待2分钟左右即可完成页面的初次加载,随后根据相应的页面提示进行操纵即可。