Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

First, 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 installation package name

two。 Download and extract JDK

(1) download the installation package

Go to the / usr/local directory and create a new java directory

Mkdir java

Use the wget directive in the Java directory 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 download and upload to linux locally.

(2) decompress the installation package

Use the command to decompress after the download is complete.

Tar-zxvf package name

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 to configure the .bash _ profile file (the environment variable configuration under the current user) and add the following configuration at the end of the file: (for fear of modification errors, use the ps command to back up the file)

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

Finally, don't forget to carry out the order.

Source / etc/profile

Make the configuration file effective.

Enter java-version to see if the JDK configuration is successful. When the version information appears, the JDK installation and configuration is complete.

Second, install tomcat

two。 Download and extract tomcat

(1) download the installation package

Go to the / usr/local directory and create a new mywork directory

Mkdir mywork

Use the wget directive in the mywork directory to download the installation package, 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 download and upload to linux locally.

(2) decompress the installation package

Use the command to decompress after the download is complete.

Tar-zxvf package name

3. Start tomcat

Go to 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

Service iptables status

(2) turn off linux Firewall

Systemctl stop firewalld

Use the command when the above command is invalid

Service iptables stop

(3) View the ip address information of linux

Ifconfig

(4) visit tomcat

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

Third, install mysql

1. Uninstall the database mariadb that comes with the system

Yum list installed | grep mariadb (check whether mariadb is installed on the system) yum-y remove application name (uninstall mariadb)

two。 Download and extract mysql

(1) download the installation package

Go to the / usr/local directory and download the installation package using the wget directive, as shown in

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 download and upload to linux locally.

(2) decompress the installation package

Use the command to decompress after the download is complete.

Tar-zxvf package name

Change the file name after the decompression is complete

Mv decompression file name mysql

3. Create a data warehouse directory

Mkdir / mysql/data (this directory stores database 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 (add mysql users to the group and specify mysql directories for users)

5. Specify the owner of the directory

Go to the mysql root directory cd / usr/local/mysql to change the directory owner, chown-R mysql. (don't forget the later.) chgrp-R mysql. Chown-R mysql/ mysql/data

6. Initialize mysql configuration parameters

Execute under the mysql root directory, bin/mysqld-- initialize-- user=mysql-- basedir=/usr/local/mysql-- datadir=/mysql/data Note: after the command is executed, the initial password is generated at the end and copied to notepad for the first login later. Set data encryption, bin/mysql_ssl_rsa_setup-- datadir=/mysql/data

7. Modify the system configuration file

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

8. Modify the password

Start mysql, / etc/init.d/mysql start-- version 5.0 is mysqld start login, mysql-h localhost-u root-p enter the password obtained in step (6). If it appears:-bash: mysql: commond not found, execute: ln-s / usr/local/mysql/bin/mysql / usr/bin-- create command soft connection to change password, set password=password ('password you want to set')

9. Modify the operation rights of the remote host to the root user

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 variabl

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 testing

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

Add:

View mysql running status

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 modifying / etc/my.cnf.

Note: the above are the steps to build a simple linux project running environment, if you find errors or inappropriate, please leave a message to correct and supplement.

Summary

The above is the editor to introduce to you linux (center OS7) installation of JDK, tomcat, mysql to build java web project operating environment, I hope to help you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report