Ali cloud server deployment ultra-detailed java web project

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/liu_Yudong/article/details/88952861

Ali cloud server deployment ultra-detailed java web project


We recorded the following project deployment issues encountered and the deployment process
1. buy server
2. set up a server environment
3. Deploy your project server

1. Purchase server

    I purchased Ali cloud server, recommended purchase entry-level service ECS first time under a cloud (in the student body as well as 9.5 a month, as long as the real-name authentication and certification of students, student information to be queried certified letter to the school online ), after the student certification click on "View Yun Yi program" in the student buy a server.
After certification
Select the operating system is centos remember when buying services
Here Insert Picture Description
were followed by setting password. After the opening there will be an instance, you can see it, and there will be a public IP network.
Here Insert Picture Description
When you click on the far right of the remote connection, will enter the server's console, for the first time there will be a password, you must remember this, because only once and can not be modified. (Of course, I do not recommend this connection, the following will say)

2. set up a server environment

Server environment we buy and we do not run the code, so we need to install one by one. (The following is for windows system)

Package

(1) JDK(我选择的是1.8)
下载地址是:
https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
选择的是jdk-8u201-linux-x64.rpm
(2)Tomcat8.5
下载地址:https://tomcat.apache.org/download-80.cgi
选择的是apache-tomcat-8.5.39.tar.gz
(3)Mysql
选择的是mysql57-community-release-el7-11.noarch.rpm
我们先下载到本地,同时安装filezilla可视化上传工具上传到服务器,当然你也可以选择其他方法。
上传结束后,点击服务器的远程连接,输入ls便能看到刚刚上传的文件。这里推荐的是通过xshell连接服务器,这样会好操作的多。

接下来安装软件,搭建教程(均在安装包所在的路径下)

1.JDK

chmod +x jdk-8u144-linux-x64.rpm
安装后输入java -version,
若出现版本信息,则安装成功。
Here Insert Picture Description

2.Mysql

(1) 安装用来配置mysql的yum源的rpm包:rpm -Uvh mysql57-community-release-el7-11.noarch.rpm
(2) 安装Mysql:yum install mysql-community-server
配置Mysql
开启Mysql:serive mysqld start(注意:是mysqld,不是mysql)
查看原始密码:grep ‘temporary password’ /var/log/mysqld.log
使用原始密码登陆mysql:mysql -uroot -p
修改登陆密码:ALTER USER ‘root’@‘localhost’ IDENTIFIED BY ‘你的密码’;
开启远程连接:
  通过阿里云控制台开放3306端口
  在阿里云控制台咱们的实例页面下面选择安全组->配置规则
 Here Insert Picture Description
Here Insert Picture Description
配置一个可以远程登陆数据库的账号(用于项目连接数据库):
mysql -u root -p
use mysql;
grant SELECT,UPDATE,INSERT,DELETE on . to ‘work(登录名)’@’%’ identified by ‘密码’;//创建work帐号并授权,同时设置密码

生效配置:flush privileges
测试配置生效否:mysql -u(你的账号,如我们刚刚设置的work) -P3306 -h47.104.1.235 –p

3.Tomcat8

安装:tar -zxvf apache-tomcat-8.0.46.tar.gz
启动:在Tomcat文件下的bin目录下运行./startup.sh
修改tomcat默认启动端口,从8080修改为80端口
Here Insert Picture Description
重启Tomcat:.shutdown.sh 和./startup.sh,分别是停止和启动
这时候打开浏览器输入公网IP应该会出来Tomcat的页面。

4.修改代码配置

修改项目的jdbc文件:
Here Insert Picture Description
说明:url下改成自己服务器的公网IP,就是上图的47.100.200.162;账号密码就是刚刚配置Mysql的远程登陆账号密码

3.在服务器部署自己的项目

1、在编辑器上打包自己项目的war包
2、上传到服务器的webapps的文件夹下面,Tomcat会自动解压,如果没有解压,有可能是Tomcat启动失败,这是输入jps,出现Bootstrap表示启动成功的,这时候等一等。如果没有出现,进入tomcat文件夹下的logs文件夹下,查看catalina.out文件,vim catalina.out
Here Insert Picture Description
3、之后通过ip+请求路径的形式便能访问到自己的项目(因为已经设置成80端口,这是http默认访问的端口,所以不需要在URL里添加端口信息了),如:47.100.200.162/denny/frontend/shoplist
这时候如果没有出现数据或者图片不要慌,我们接下来配置。

配置数据:
1、将本地数据库打包成.sql文件
2、将.sql文件上传到服务器
3、进入.sql文件存放的文件夹,进入mysql模式
3、创建数据库,如果已经存在就不用了,数据库的名字最好也项目在本地时使用的一样,即使.sql文件的前缀。
查看数据库:show databases;(记得分号;)
创建数据库:CREATE DATABASE 数据库名;(记得分号;)
4、use 数据库名
5、source .sql文件(如:source denny.sql)
这是你可以输入一些查询语句验证下或者show tables查看表是否都创建成功;

The picture did not come out at that time because the pictures are saved to a local project, so we need to be uploaded to the server
1, the picture folder into a .zip file
2, create a folder (such as: m KDIR -p / Home / Denny / image ), which is the directory we set in the project file PathUtil.java
3, upload compressed file into the server we just created folder, that is, the above image folder
4, extract the compressed package, the unzip .zip ; If not unzip instructions need to install: yum ZIP unzip the install -Y

This time you can go directly to the remote access, as domain name resolution depends on individual needs, and will not be described here.

This article is a personal record after personal learning online tutorials to learn drawing, any similarity, please contact the author, thank you.

Guess you like

Origin blog.csdn.net/liu_Yudong/article/details/88952861