Alibaba Cloud server configuration + Linuxs system installation jdk, tomcat, MySQL summary detailed tutorial + some small bug solutions in the online release of the project--Rookie Xiaohui

Alibaba Cloud server configuration + Linuxs system installation jdk, tomcat, MySQL summary detailed tutorial + some small bug solutions in the online release of the project--Rookie Xiaohui



Written in the front: After learning programming, I want to know how to release the project I wrote. But it always stays in the scope of LAN access...
Linuxs operating system does not, the online tutorials are too complicated, the cloud server needs money, and I am afraid that it will not succeed... and... repeatedly...
This time I finally made up my mind. Ask the great gods from all walks of life, run various blogs, check various encyclopedias, read various development documents... countless pits... and then... successfully released and launched
.

Project preview (compare low, don't spray ha...)

The foundation is too poor and it is not easy to write. In order to write this tutorial, there are no missing steps. After initializing the hard-configured server, reconfigure it and take screenshots step by step. There is even a little wordy. Please forgive me!


Required software packaging: final shell+navicat+tomcat+jdk extraction code: bdqj (all can go to the official website to download by yourself, tomcat and jdk pay attention to download under the Linuxs system!)


1. Install remote connection software on this machine (remote software is used to simplify operation, please ignore it)

  1. Download and install the final shell by yourself (connect to remote Linuxs system)

  2. Download and install Navicat, follow the document tutorial (connect remote MySQL database)


2. Apply for Alibaba Cloud ECS

  1. Register an Alibaba Cloud account:
    Alibaba Cloud Gift Package
  2. Verified
  3. Apply for cloud server ECS
  • Under the age of 24, you can go to the event page to buy discounts (location is as follows; local tyrants skip)
    enter description here
    enter description here
    enter description here

3. Set up ECS remote control

  1. Find your ECS server
    enter description here

  2. Set the remote connection password (for the first time log in with the default assigned password, pay attention to the default password prompted by the copy system)
    enter description here

  3. Set your own instance password in the same way (for Linuxs system startup)

  4. Enter detailed settings
    enter description here

  5. Click remote connection
    enter description here

  6. Enter account number: "root" Password: "instance password" to enter the system (no prompt when entering the password, just enter it directly)
    enter description here

To this, it means that your cloud server host can be used normally, but for rookies who don’t know Linuxs, you can use the remote connection tool to operate.

Fourth, use Xshell to connect to remote Linuxs

  1. Enter Xshell, create a new connection
    enter description here

  2. Copy your ECS public network ip to the hostname and click "Test"
    enter description here

  3. A pop-up reminder to log in account password (the instance account you set: root password: (instance password))
    enter description here
    enter description here

  4. Successful login
    enter description here
    Note: The following picture can be ignored. For obsessive-compulsive disorder, go to the upper left corner "File" -> "Properties" -> "Tunnel" -> "Tick to forward X11 connection to (X)" and log in again! !
    enter description here


Five, configure Linuxs system (emphasis here)

tips: Use "shift+insert" to paste the code

1. jdk installation and environment variable configuration

  1. Download or use the compressed package (.tar.gz file) in my package from the official website:
    enter description here
  2. After downloading, enter the following command in Xshell:
//在usr文件夹下新建java目录
mkdir /usr/java
//进入java目录
cd /usr/java
//激活上传操作
yum -y install lrzsz
  • Activated successfully
    enter description here
  1. Enter the xftp visualization tool to transfer the downloaded jdk on windows
    enter description here
  • Compress the package to Linuxs (directly drag and drop as shown and wait for upload)
    enter description here
  1. After uploading, unzip the installation package:
//在创建的/usr/java目录下执行ls,查看压缩包名
ls
//复制文件夹名填到下方压缩包名处,将压缩包解压
tar -zxvf 压缩包名

  • Decompression is complete (can be viewed through xftp)
    enter description here
  1. Configure jdk environment variables
//进入etc文件夹
cd /etc
//打开profile文件,按shift+i进入编辑模式
vi profile
//配置环境变量,在profile文件中添加如下内容,注意更换到你的版本
export JAVA_HOME=/usr/java/jdk1.8.0_221 
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib:$CLASSPATH
export JAVA_PATH=${JAVA_HOME}/bin:${JRE_HOME}/bin
export PATH=$PATH:${JAVA_PATH}
//按“esc”退出编辑模式,随后按“shift+:”进入命令模式,保存并退出
输入“wq” 回车

enter description here

  • Restart your Linuxs and type "reboot"
    reboot
    enter description here
  1. View the configured environment variables

javac 回车

java -version 回车

  • javac configuration is successful
    enter description here

  • java -version configuration is successful
    enter description here

2. Tomcat installation and port configuration

  1. The same as decompressing tomcat, first create a tomcat folder
//在usr文件夹下新建java目录
mkdir /usr/tomcat
//进入java目录
cd /usr/tomcat
//激活上传操作
yum -y install lrzsz
  1. Enter the xftp visualization tool to transfer the downloaded tomcat on windows
  • Compress the package to Linuxs (directly drag and drop as shown and wait for upload)
    enter description here
  1. After uploading, unzip the installation package:
//在创建的/usr/java目录下执行ls,查看压缩包名
ls
//复制文件夹名填到下方压缩包名处,将压缩包解压
tar -zxvf 压缩包名
//修改文件夹名称(注意版本对应你下载的)
mv apache-tomcat-8.5.45 tomcat8
  • Unzip complete
    enter description here

tips: The tomcat port number can be modified using xftp to go to server.xml under "/usr/tomcat/tomcat8/conf", the modification method is the same as on Windows
enter description here

  1. Start tomcat
//进入tomcat的bin目录
cd /usr/tomcat/tomcat8/bin
//启动tomcat,输入
./startup.sh 回车
  1. Browser access test
//ip和端口号换成你的
http://47.105.221.156:8080/
  • Successful visit: complete tomcat installation
    enter description here

After checking that the URL is correct, it still cannot be accessed

  • Don't panic, go back to the Alibaba Cloud console and find "Security Group for this instance" -> "Configuration Rules":
    enter description here

  • Add port
    enter description here

  • The port range is filled in according to the port you set, and the authorized object is "0.0.0.0/0"
    enter description here

  • After saving, restart your Linuxs and still cannot see the homepage after restarting . Please wait patiently for 20 minutes, and you can continue with other steps first, because the port opening process requires Ali some time to configure. This is only the first configuration! , Revisit the tomcat homepage, and solve it!

  1. Use eclipse to mark your project as a war package.
    enter description here

  2. Upload to Linuxs "/usr/tomcat/tomcat8/webapps" directory; restart tomcat
    enter description here

//进入bin文件夹
cd /usr/tomcat/tomcat8/bin
//关闭tomcat
./shutdown.sh
//查看是否成功关闭
ps -ef|grep java
//如果出现以下信息,则表示Tomcat已经关闭
root 19955 19757 0 17:48 pts/0 00:00:00 grep java
//启动Tomcat
./startup.sh
  • If the following similar information is displayed, it means that Tomcat has not been closed
    enter description here
//使用kill命令杀死tomcat
kill -9 12778 
//再次查看
ps -ef|grep java
//启动Tomcat
./startup.sh

enter description here

  • Found that there is already a project decompressed from the war package in our tomcat
    enter description here
  1. Visit your project, complete (no database project)!
    enter description here

Note: You need to replace the war package project, first close tomcat; delete the original war package and unzip the project; check whether there is a deployment project under the path "/usr/tomcat/tomcat8/work/Catalina/localhost", delete if there is . Import the new package and restart tomcat! (Carry over the pit...)


3. MySQL installation and configuration (not required, ignored for users without database)

  1. Xshell input command to download the installation package
//5.7版本
wget http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm
//8.0版本
wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
//其他版本自己去官网下yum安装栏找下载路径
//未安装wget的同学执行以下命令安装
sudo yum install wget
  1. installation:
//-ivh 后跟你装的对应版本mysql包
sudo rpm -ivh mysql57-community-release-el7-8.noarch.rpm
 
sudo yum install mysql-server
  • Enter "y" to confirm installation and wait
    enter description here
  • Continue "y" and wait
    enter description here
  • carry out
    enter description here
  1. set password
//当第一次启动MySQL服务器时,为MySQL根用户生成一个临时密码。 您可以通过运行以下命令找到密码:
sudo grep 'temporary password' /var/log/mysqld.log

  1. If this file is empty:
//1.删除原来安装过的mysql残留的数据
rm -rf /var/lib/mysql
//2.重启mysqld服务
systemctl restart mysqld
//3.再去找临时密码
sudo grep 'temporary password' /var/log/mysqld.log
  • localhost: there is a temporary password behind, copy hr?=;FsST2fc
    enter description here
  1. Configure installation items
    sudo mysql_secure_installation

  2. Paste the password you copied and set a new password (must contain: password: uppercase, lowercase, numbers, characters)
    enter description here

  • The options are all "Y", confirm. See All done! Complete the configuration.
    enter description here
  • Try to visit, success
    enter description here

Six, migrate database files

  1. Use the visualization software Navicat to connect to the database
  • New connection
    enter description here
  • Connect according to your public network ip and the set mysql password
    enter description here
  1. The following window may appear (Don’t panic, I’ve stepped on this pit)
    enter description here
  • Two steps:
    • Step 1: The old place "Security Group Rules" -> increase your 3306 port -> restart. I still cannot see the homepage after restarting. Please wait patiently for 20 minutes, you can continue with other steps first! Deploying the project to the tomcat server requires a certain waiting time, please wait.
      enter description here
      enter description here
    • Step 2: Enter your database in Xhell
    //1. 登录,-u账号 -p密码
     mysql -uroot -p521521
    //2. 查看数据库:
     show databases;
    //3. 进入mysql:
     use mysql;
    //4. 查看表:
    show tables;
    //5.更新user表数据,添加远程访问权限;
    update user set Host='%' where User='root';
    //重启mysql
    systemctl restart mysqld
    
    enter description here
  • Re-use the Navicat tool to connect to the database (after stepping on the pit, everyone applauds!)
    enter description here
  1. Dump your project database sql file to the database on the Alibaba Cloud server.
    enter description here
    enter description here

  2. Don't forget to modify your code and upload the war package again! ! !

  • The project is successfully launched online and your project can be accessed from any network through your website! (All rise!)
    enter description here

Note: There are no students who lack any steps but cannot access the project. Note: 1. Do you restart the instance after modifying the Linuxs port? 2. After modifying the war package, whether to restart tomcat (kill tomcat delete the cached item and reload if necessary, or even delete tomcat and unzip again.) 3. Check again whether the process is missing steps!

So far, the project went online successfully. In order to organize this tutorial, I worked three nights overtime. If it is helpful to everyone, please like and forward it. Thanks! If there are still questions and unsuccessful, just chat privately.
Note: Please indicate the source for reprinting! ! ! Continue to the
next article: "Modify the configuration file in the Linuxs system to access the java project directly through ip, remove the port number and project name.

Guess you like

Origin blog.csdn.net/qq_39231769/article/details/100587577