linux (center OS7) Install JDK tomcat and mysql to build the running environment of java web project

  • 2021-07-10 21:18:41
  • OfStack

1. Install JDK

1. Uninstall the old version or the JDK that comes with the system

(1) List all installed JDK

   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 to create a new java directory

   mkdir java

From the Java directory, use the wget directive to download the installation package, 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 the shell tool to upload to linux locally.

(2) Unzip the installation package

After downloading, use the command to unzip,

  tar -zxvf 压缩包名称

3. Configure environment variables

Enter the/etc/folder to edit the profile file (Global Environment Variable Configuration) using the vim profile Command Editor. If there is no profile file, go to/root for configuration. bash_profile file (environment variable configuration under current user) Add the following configuration at the end of the file: (If you are worried about modification errors, you can use ps command to back up the file)


export JAVA_HOME=jdk Root directory of installation package 
    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 carry out orders

   source /etc/profile

Make the configuration file effective.

Enter java-version to see if the JDK configuration was successful. The JDK installation configuration is complete when the version information appears.

2. Install tomcat

2. Download and unzip tomcat

(1) Download the installation package

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

   mkdir mywork

From the mywork directory, download the installation package using the wget directive, 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 the shell tool to upload to linux locally.

(2) Unzip the installation package

After downloading, use the command to unzip,

   tar -zxvf 压缩包名称

3. Start tomcat

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

   bin/startup.sh

To see if tomcat started successfully (if the process exists), use the command

   ps -ef | grep tomcat

4. Check to see if tomcat is installed successfully

(1) View firewall status

   systemctl status firewalld

Use the command when the above command is invalid

    yum -y remove 安装包名称0

(2) Turn off the linux firewall

   systemctl stop firewalld

Use the command when the above command is invalid

   service iptables stop

(3) View ip address information for linux

   ifconfig

(4) Access tomcat

Browser input address, http://ip Address: 8080

3. Install mysql

1. Uninstall the system's own database mariadb


yum list installed | grep mariadb  (See if the system has installed mariadb ) 

    yum -y remove  Application name (uninstall mariadb ) 

2. Download and unzip mysql

(1) Download the installation package

Go to the/usr/local directory and use the wget instruction 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 the shell tool to upload to linux locally.

(2) Unzip the installation package

After downloading, use the command to unzip,

   tar -zxvf 压缩包名称

Change the file name after unzipping,

   mv 解压文件名 mysql

3. Create a data warehouse directory

   mkdir /mysql/data  (此目录存放数据库数据)

4. Create mysql users and user groups


    groupadd mysql  (Create User Groups) 
    useradd -r -s /sbin/nologin -g mysql mysql -d /usr/local/mysql (Will mysql Users are added to the group and specified for the user mysql Directory) 

5. Specify the owner of the directory


 Enter into mysql Root directory 
    cd /usr/local/mysql
 Change the directory owner, 
    chown -R mysql . (Don't forget the following . ) 
    chgrp -R mysql .
    chown -R mysql /mysql/data

6. Initialize mysql configuration parameters


 In mysql Root directory, 
    bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/mysql/data
 Note: After the command is executed, an initial password is generated at the end, which is copied to Notepad for later first login. 
 Set up data encryption, 
    bin/mysql_ssl_rsa_setup --datadir=/mysql/data

7. Modify the system configuration file


 Will mysql Configuration file is added to the system configuration file and entered into the directory 
    cd /usr/local/mysql/support-files
 Copy, 
    cp my-default.cnf /etc/my.cnf
    cp mysql.server /etc/init.d/mysql
 Edit mysql Configuration file, specifying the base directory and data directory, 
    vim /etc/init.d/mysql
 Modify the following properties: 
    basedir=/usr/local/mysql
    datadir=/mysql/data

8. Change your password


 Start mysql , 
    /etc/init.d/mysql start    --5.0 Version is  mysqld start
 Login, 
    mysql -h localhost -u root -p
 Enter the ( 6 ) Step to get the password. If it appears: -bash :mysql :commond not found  Execute: ln -s /usr/local/mysql/bin/mysql /usr/bin    -- Create command soft connection 
 Change the password, 
    set password=password(' The password you want to set ')

9. Modify remote host operation permissions for root users

Give all hosts all permissions


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 JAVA_HOME=jdk Root directory of installation package 
    export PATH=$JAVA_HOME/bin:$PATH
    export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/jre/lib/rt.jar    
0

Make the configuration file effective

  source /etc/profile

11. Remote Connection Testing

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

Additional:

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

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

The above is to build a simple linux project running environment steps, if you find errors or improper, welcome to comment correction, supplement.

Summarize

The above is the linux (center OS7) introduced by this site to install JDK, tomcat and mysql to build the running environment of java web project, hoping to help everyone!


Related articles: