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
Article Directory
- 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
-
- @ [Heel]
- 1. Install remote connection software on this machine (remote software is used to simplify operation, please ignore it)
- 2. Apply for Alibaba Cloud ECS
- 3. Set up ECS remote control
- Fourth, use Xshell to connect to remote Linuxs
- Five, configure Linuxs system (emphasis here)
-
- Six, migrate database files
Article Directory
- 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
-
- @ [Heel]
- 1. Install remote connection software on this machine (remote software is used to simplify operation, please ignore it)
- 2. Apply for Alibaba Cloud ECS
- 3. Set up ECS remote control
- Fourth, use Xshell to connect to remote Linuxs
- Five, configure Linuxs system (emphasis here)
- Six, migrate database files
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)
-
Download and install the final shell by yourself (connect to remote Linuxs system)
-
Download and install Navicat, follow the document tutorial (connect remote MySQL database)
2. Apply for Alibaba Cloud ECS
- Register an Alibaba Cloud account:
Alibaba Cloud Gift Package - Verified
- 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)
3. Set up ECS remote control
-
Find your ECS server
-
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)
-
Set your own instance password in the same way (for Linuxs system startup)
-
Enter detailed settings
-
Click remote connection
-
Enter account number: "root" Password: "instance password" to enter the system (no prompt when entering the password, just enter it directly)
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
-
Enter Xshell, create a new connection
-
Copy your ECS public network ip to the hostname and click "Test"
-
A pop-up reminder to log in account password (the instance account you set: root password: (instance password))
-
Successful login
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! !
Five, configure Linuxs system (emphasis here)
tips: Use "shift+insert" to paste the code
1. jdk installation and environment variable configuration
- Download or use the compressed package (.tar.gz file) in my package from the official website:
- After downloading, enter the following command in Xshell:
//在usr文件夹下新建java目录
mkdir /usr/java
//进入java目录
cd /usr/java
//激活上传操作
yum -y install lrzsz
- Activated successfully
- Enter the xftp visualization tool to transfer the downloaded jdk on windows
- Compress the package to Linuxs (directly drag and drop as shown and wait for upload)
- After uploading, unzip the installation package:
//在创建的/usr/java目录下执行ls,查看压缩包名
ls
//复制文件夹名填到下方压缩包名处,将压缩包解压
tar -zxvf 压缩包名
- Decompression is complete (can be viewed through xftp)
- 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” 回车
- Restart your Linuxs and type "reboot"
reboot
- View the configured environment variables
javac 回车
java -version 回车
-
javac configuration is successful
-
java -version configuration is successful
2. Tomcat installation and port configuration
- The same as decompressing tomcat, first create a tomcat folder
//在usr文件夹下新建java目录
mkdir /usr/tomcat
//进入java目录
cd /usr/tomcat
//激活上传操作
yum -y install lrzsz
- 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)
- After uploading, unzip the installation package:
//在创建的/usr/java目录下执行ls,查看压缩包名
ls
//复制文件夹名填到下方压缩包名处,将压缩包解压
tar -zxvf 压缩包名
//修改文件夹名称(注意版本对应你下载的)
mv apache-tomcat-8.5.45 tomcat8
- Unzip complete
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
- Start tomcat
//进入tomcat的bin目录
cd /usr/tomcat/tomcat8/bin
//启动tomcat,输入
./startup.sh 回车
- Browser access test
//ip和端口号换成你的
http://47.105.221.156:8080/
- Successful visit: complete tomcat installation
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":
-
Add port
-
The port range is filled in according to the port you set, and the authorized object is "0.0.0.0/0"
-
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!
-
Use eclipse to mark your project as a war package.
-
Upload to Linuxs "/usr/tomcat/tomcat8/webapps" directory; restart tomcat
//进入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
//使用kill命令杀死tomcat
kill -9 12778
//再次查看
ps -ef|grep java
//启动Tomcat
./startup.sh
- Found that there is already a project decompressed from the war package in our tomcat
- Visit your project, complete (no database project)!
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)
- 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
- 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
- Continue "y" and wait
- carry out
- set password
//当第一次启动MySQL服务器时,为MySQL根用户生成一个临时密码。 您可以通过运行以下命令找到密码:
sudo grep 'temporary password' /var/log/mysqld.log
- 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
-
Configure installation items
sudo mysql_secure_installation
-
Paste the password you copied and set a new password (must contain: password: uppercase, lowercase, numbers, characters)
- The options are all "Y", confirm. See All done! Complete the configuration.
- Try to visit, success
Six, migrate database files
- Use the visualization software Navicat to connect to the database
- New connection
- Connect according to your public network ip and the set mysql password
- The following window may appear (Don’t panic, I’ve stepped on this pit)
- 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.
- 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
- 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.
- Re-use the Navicat tool to connect to the database (after stepping on the pit, everyone applauds!)
-
Dump your project database sql file to the database on the Alibaba Cloud server.
-
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!)
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. 》