Linux (center OS7) installs JDK, tomcat, mysql to build a java web project running environment

Linux (center OS7) installs JDK, tomcat, mysql to build a java web project running environment

1. Install JDK

1. Uninstall the old version or the system's own JDK

(1) List all installed JDKs

rpm -qa | grep jdk

(2) Uninstall unnecessary JDK

yum -y remove 安裝包名稱

2. Download and unzip JDK

(1) Download the installation package

Enter the /usr/local directory and create a new java directory

mkdir java

, use the wget command to download the installation package in the Java directory, such as

wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u141-b15/336fa29ff2bb4ef291e347e091f7f4a7/jdk-8u141-linux-x64.tar.gz

Or use shell tools to download locally and upload to Linux.

(2) Unzip the installation package

After downloading, use the command to decompress it.

tar -zxvf 壓縮包名稱

3. Configure environment variables

Go to the /etc/ folder and use the vim profile command editor to edit the profile file (global environment variable configuration). If there is no profile file, go to /root and configure the .bash_profile file (environment variable configuration under the current user) and add the following configuration at the end of the file: (If you are worried about making mistakes in the modification, you can use the ps command to back up the file)

export JAVA_HOME=jdk installation package root directory export PATH=$JAVA_HOME/bin:$PATH
  export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/jre/lib/rt.jar

Finally, don't forget to execute the command

source /etc/profile

Make the configuration file effective.

Enter java -version to check whether the JDK configuration is successful. If the version information appears, the JDK installation and configuration is complete.

2. Install tomcat

2. Download and unzip tomcat

(1) Download the installation package

Enter the /usr/local directory and create a new mywork directory

mkdir mywork

, use the wget command to download the installation package in the mywork directory, such as

wget "http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-8/v8.5.49/bin/apache-tomcat-8.5.49.tar.gz"

Or use shell tools to download locally and upload to Linux.

(2) Unzip the installation package

After downloading, use the command to decompress it.

tar -zxvf 壓縮包名稱

3. Start tomcat

Enter the tomcat home directory, start tomcat, and use the command

bin/startup.sh

Check whether Tomcat is started successfully (whether the process exists), use the command

ps -ef | grep tomcat

4. Check whether tomcat is installed successfully

(1) Check the firewall status

systemctl status firewalld

If the above command is invalid, use the command

service iptables status

(2) Turn off the Linux firewall

systemctl stop firewalld

If the above command is invalid, use the command

service iptables stop

(3) View Linux's IP address information

ifconfig

(4) Access tomcat

Enter the address in the browser, http://ip address:8080

3. Install MySQL

1. Uninstall the system's own database mariadb

yum list installed | grep mariadb (check whether mariadb is installed on the system)

  yum -y remove application name (uninstall mariadb)

2. Download and unzip mysql

(1) Download the installation package

Enter the /usr/local directory and use the wget command to download the installation package, such as

wget "http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz"

Or use shell tools to download locally and upload to Linux.

(2) Unzip the installation package

After downloading, use the command to decompress it.

tar -zxvf 壓縮包名稱

After decompression is complete, change the file name.

mv 解壓文件名mysql

3. Create a data warehouse directory

mkdir /mysql/data (此目錄存放數據庫數據)

4. Create mysql user and user group

  groupadd mysql (create a user group)
  useradd -r -s /sbin/nologin -g mysql mysql -d /usr/local/mysql (add the mysql user to the group and specify the mysql directory for the user)

5. Specify the owner of the directory

Enter the mysql root directory cd /usr/local/mysql
  Change the directory owner,
  chown -R mysql . (Don't forget the . at the end.)
  chgrp -R mysql .
  chown -R mysql /mysql/data

6. Initialize mysql configuration parameters

Execute in the mysql root directory,
  bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/mysql/data
  Note: After the command is executed, an initial password will be generated at the end. Copy it to Notepad for the first login later.
  Set up data encryption,
  bin/mysql_ssl_rsa_setup --datadir=/mysql/data

7. Modify system configuration files

Add the mysql configuration file to the system configuration file and enter the directory cd /usr/local/mysql/support-files
  copy,
  cp my-default.cnf /etc/my.cnf
  cp mysql.server /etc/init.d/mysql
  Edit the mysql configuration file and specify the base directory and data directory.
  vim /etc/init.d/mysql
  Modify the following properties:
  basedir=/usr/local/mysql
  datadir=/mysql/data

8. Change password

Start mysql,
  /etc/init.d/mysql start -- Version 5.0 is mysqld start
  Log in,
  mysql -h localhost -u root -p
  Enter the password obtained in step (6). If the following message appears: -bash :mysql :commond not found, execute: ln -s /usr/local/mysql/bin/mysql /usr/bin --Create a command soft link to change the password.
  set password=password('the password you want to set')

9. Modify the remote host's operating permissions for the root user

Grant all permissions to all hosts

grant all privileges on *.* to 'root'@'%' identified by 'root';

Make permissions effective

flush privileges;

View user table permissions

 use mysql;
  select * from user;

10. Add system environment variables

vim /etc/profile

Add at the end:


export PATH=/usr/local/mysql/bin:$PATH

Make the configuration file effective

source /etc/profile

11. Remote connection test

You can use the mysql client tool to connect remotely. If the connection fails, turn off the firewall and try again.

Replenish:

Check the running status of MySQL.
service mysql status --5.0 version is service mysqld status
Stop mysql,
service mysql stop --5.0 version is service mysqld stop
Start mysql
service mysql start --5.0 version is service mysqld start
Restart mysql
service mysql restart --5.0 version is service mysqld restart

mysql can be configured in detail by modifying /etc/my.cnf.

Note: The above are the steps to build a simple Linux project operating environment. If you find any errors or inappropriateness, please leave a message to correct or supplement it.

Summarize

The above is the editor's introduction to Linux (center OS7) installation of JDK, tomcat, mysql to build a java web project operating environment. I hope it will be helpful to everyone!

You may also be interested in:
  • How to deploy JavaWeb project to Tomcat server in IDEA
  • Server push chat room example based on Tomcat7, Java, and WebSocket
  • Detailed explanation of CentOS installation of tomcat and deployment of Java Web projects
  • Java backend Tomcat implements WebSocket example tutorial
  • Java Web uses simple batch operations (Notepad + Tomcat)
  • Learn how to configure Tomcat hot start in javaweb
  • How to get the contents of properties file on tomcat in java web development
  • Java Web project deployed in Tomcat running error and solution example
  • Java web project starts Tomcat error solution

<<:  Example of using rem to replace px in vue project

>>:  Problems encountered in the execution order of AND and OR in SQL statements

Recommend

How to implement line breaks in textarea text input area

If you want to wrap the text in the textarea input...

Introduction to the use of CSS3 filter attribute

1. Introduction When writing animation effects fo...

Analysis of MySQL's planned tasks and event scheduling examples

This article uses examples to describe MySQL'...

Detailed tutorial on installing Tomcat9 windows service

1. Preparation 1.1 Download the tomcat compressed...

Example of how to use CSS3 to layout elements around a center point

This article introduces an example of how CSS3 ca...

A brief analysis of mysql index

A database index is a data structure whose purpos...

Summary of commonly used SQL statements for creating MySQL tables

Recently, I have been working on a project and ne...

JavaScript implementation of magnifying glass details

Table of contents 1. Rendering 2. Implementation ...

How to use async and await in JS

Table of contents 1. async 2. await: 3. Comprehen...

jQuery implements form validation

Use jQuery to implement form validation, for your...

MySql 5.7.20 installation and configuration of data and my.ini files

1. First download from the official website of My...

Markup language - web application CSS style

Click here to return to the 123WORDPRESS.COM HTML ...

vue+tp5 realizes simple login function

This article example shares the specific code of ...