LInux installation and management java, tomcat, mysql

Application Basics

< img alt="" height="396" src="//i2.wp.com/img-blog.csdnimg.cn/fca42cac40274bccab094687a12b53eb.png" width="758">RPM software installation Method

(Red Hat company proposed that it is widely used and has certain tips on dependent packages)

  1. View installed rpm software: rpm -qa
  2. Install the downloaded rpm installation package: rpm -ivh installation package
  3. Uninstall the installed rpm application: rpm -e rpm application [–nodeps] –nodeps is a forced uninstallation
  4. Initialize and rebuild the rpm database: rpm –rebuilddb or rpm –initdb

tar.gz source code compression package installation method

(Newer. Easy to install, but troublesome to configure, requiring manual management of dependencies)

tar -zxvf installation package -C specifies the installation path

Zip green source code compression package installation method

(Provided on Windows platform or other platforms, with strong versatility)

unzip installation package

#Need to install unzip command in advance

yum online installation method

(Automatically handle dependencies, automatically install rpm packages, and have higher requirements on the network environment)

yum install -y list of applications to download

yum remove -y list of applications to be uninstalled

wget online download tool

(No installation, only downloading the software package, no wall, can bypass permission verification)

#Install wget command in advance

Formal installation process

java installation

1. Download the required resources

2. Drag the file to the /opt/ directory of the SSH tool

3. Use the tar command to install Java Development Tools (JDK)

tar -zxvf jdk installation package

This line of command is used to decompress a gzip-compressed (.gz) file;

  • -z: This is a tar command option that tells tar to use gzip for compression or decompression. In this case, it means that you want to decompress an archive that has been compressed using gzip.

  • -x: This is an option to the tar command, which instructs tar to perform an unpacking operation, that is, extract files from the archive.

  • -v: This is an optional option that means “verbose”, which means to display the detailed unpacking process so that you can see the list of files being unpacked.

  • -f: This is an option of the tar command, used to specify the name of the archive file to be operated on.

4. Configure environment variables: vi /etc/profile

(If you are an ordinary user, you should modify it to ~/.bashrc)

After installing the JDK, you need to set the Java environment variables so that the system can find the JDK installation path.

Enter the profile file and use the vi editor to add environment variables

export JAVA_HOME=jdk installation directory

export PATH=$PATH:$JAVA_HOME/bin

Press i to enter edit mode and add configuration at the end (# is followed by comments, environment variables and paths to add according to your actual situation)

“esc” exits the editing mode; “:” enters the last line and enters wq (save and exit).

5. Make the above configuration items take effect in time: source /etc/profile

6. Test whether the environment variables are configured successfully: java -version

If the version number is displayed, the addition is successful. If not, check the configuration path.

tomcat installation

1. Use the unzip command to install tomcat

Since unzip is not installed by default in the minimal installation environment, you need to install it with yum: yum install -y unzip, successed means successful installation.

2. Use unzip to decompress the tomcat compressed package: unzip tomcat package

Here, the file name is changed to tomcat8 through the mv command for ease of use.

After decompression, you can delete the compressed file, rm + file name

3.unzip does not provide additional authorization, so you need to manually authorize the sh script file, chmod + x bin/*.sh (give execution permissions at the end of sh in batches)

Before empowerment:

After empowerment:

4.bin/startup.sh starts the tomcat service, and the content will appear in the log file

5. Test connection

Enter the virtual machine IP: 8080 in the window browser, and you will find that it is intercepted by the firewall. You should relax the port restrictions or close the firewall. Here, choose to close the firewall (temporary solution, not recommended) systemctl stop firewalld, and then the page can be displayed normally.

6.bin/shutdown.sh shuts down the tomcat service

You can dynamically view tomcat’s running logs through the tail command: tail -f logs/catalina.out

For a more intuitive display, you can create another window to display the log.

mysql installation

1. Use the rpm command to install the client and server of mysql

There are several dependent packages that need to be installed in advance before installing the MYSQL client and server (directly yum will prompt you to install the dependent packages)

Install multiple dependency packages, separated by spaces: yum install -y perl net-tools autoconf

Install the client: rpm -ivh MySQL-client-5.6.46-1.el7.x86_64.rpm

When installing the server, because the mysql server conflicts with the mariabd that comes with the Linux system, the conflict must be uninstalled.

View conflicts: rpm -qa | grep mariadb

Uninstall conflict: rpm -e mariadb-libs-1:5.5.56-2.el7.x86_64 --nodeps (--nodeps ignores dependencies, forcibly uninstalls and performs server-side installation)

2. Start the mysql service: service mysql start (will start automatically after booting by default)

3. View the initial random password: cat ~/.mysql_secret

4. Use a random password to log in: mysql -uroot -p random password (-u is followed by the user name)

(It’s best to copy and paste the password, it’s too easy to get it wrong!)

5. In the mysql command line, initialize the password (change the password): set password=password(‘new password’);

set password=password('new password');

6. Exit the mysql command line: quit

7. Reuse the new password for verification: mysql -uroot -p new password