Java study notes-Day80 Maven project deployment to Linux
One, linux yum command
Yum (Yellow dog Updater, Modified) is a Shell front-end package manager in Fedora, RedHat and SUSE.
Based on RPM package management, it can automatically download and install RPM packages from a designated server, automatically handle dependencies, and install all dependent software packages at once, without the need for tedious downloading and installation again and again.
Yum provides commands to find, install, delete a certain package, a group or even all packages, and the commands are concise and easy to remember.
yum syntax:
yum [options] [command] [package ...]
- options: Optional, options include -h (help), -y (when prompted to select all yes when the installation process prompts), -q (do not display the installation process), and so on.
- command: The operation to be performed.
- package: The object of operation.
Two, install JDK
(1) Connect to the Linux centos7 server through Xshell6 software.
(2) by rpm -qa|grep jdk
whether the installation View JDK. If the installation can use the rpm -qa|grep java | xargs rpm -e --nodeps
batch uninstall all the files with Java.
(3) by yum search jdk
find the version you want to install, this installation is the java-1.8.0-openjdk-devel.x86_64 version, through yum -y install java-1.8.0-openjdk-devel.x86_64
the installation. The following interface will appear when the installation is successful.
Three, install Tomcat
(1) Transfer the apache-tomcat-9.0.44.tar.gz compressed package to the /usr/local file on the Linux server through the Xftp6 software.
(2) by cd /usr/local
entering the local folder, use tar zxvf apache-tomcat-9.0.44.tar.gz
decompression.
(3) by cd apache-tomcat-9.0.44/bin
entering the Tomcat's bin folder, use ./startup.sh
start Tomcat, use ./shutdown.sh
closed Tomcat. If the following interface appears, it means that Tomcat has started successfully.
(4) use systemctl status firewalld.service
to see if a firewall is started, if the firewall does not start, use systemctl start firewalld.service
Start the firewall. First use of firewall-cmd --permanent --add-port=8080/tcp
open firewall port 8080, then use systemctl restart firewalld.service
to restart the firewall.
(5) access ip地址:8080
will Tomcat home page appears.
Fourth, install Mysql
(1) rpm -qa|grep mysql
is installed to check Mysql.
(2) Use rpm to install the official Mysql warehouse:rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
(3) Check the Mysql warehouse information: yum info mysql-community-server
(4) Install Mysql through yum:, the yum -y install mysql-community-server
installation is successful and the following interface appears.
(5) Check and start Mysql: by systemctl status mysqld
Mysql start to see whether, if not started by systemctl start mysqld
start Mysql.
(6) by grep "password" /var/log/mysqld.log
default generated password to view Mysql.
(7) by mysqladmin -u root -p password
modifying a password, enter a password Mysql generated by default, and then enter the new password twice.
(8) through the firewall-cmd --permanent --add-port=3306/tcp
open firewall port 3306, and then by systemctl restart firewalld.service
restarting the firewall.
(9) Use mysql -u root -p
and enter the new password to enter Mysql.
(10) When using Navicat to connect to Mysql of the Linux server, a 1130 error will occur.
This is because the Mysql account does not allow remote login by default, and can only log in at localhost (local). Solution: Use use mysql;
switch to mysql database, then use update user set Host='%' where User='root';
to modify the user table localhost to the Host %
, updates will only allow local access is not limited to IP. Finally, use the flush privileges;
refresh.
(11) If you use Navicat to connect to the Linux server, a 1251 error will occur.
This is because the authentication plug-in version required by Mysql is inconsistent with the client. Workaround: Use the ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'Root@123';
root of the plugin will change mysql_native_password. This line of code has two meanings. The first is to change the root password to'root' and discard the original old password. The second is to use mysql_native_password to encode the new password. Finally, use the flush privileges;
refresh.
(12) After the above modification, successfully use Navicat to connect to the Mysql database of the Linux server.
Five, deployment project
To deploy the project, you only need to use Eclipse to export the war package of the project and put it in the webapps folder of Tomcat. Note: The project must have no problems before it can run in Tomcat.
(1) In the Eclipse project list, right-click the corresponding project and click Export -> Export... -> Web -> WAR file. Destination represents the location to be exported, click Browse to select the import location. Tick Optimize for a specific server runtime. Click Finsh to finish.
(2) Transfer the war to Tomcat's webapps folder via Xftp6, and the war package will automatically generate a folder.
(3) View Tomcat logs in real time (log files in Tomcat's logs file):tail -f ../logs/catalina.out