search
HomeJavajavaTutorialHow to set up a Java Web project running environment on a Linux system?

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

2. Download and decompress jdk

(1) Download the installation package

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

mkdir java

​, use the wget command 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 upload it locally to Linux.

(2) Decompress the installation package

After downloading, use the command to decompress,

tar -zxvf compressed package name

3 .Configure environment variables

Enter 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 (environment variable configuration under the current user) and add the following configuration at the end of the file: (If you are worried about modification errors, you can use the ps command to back up the file)

export java_home=jdk安装包的根目录
  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

to make the configuration file take effect.

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

2. Install tomcat

2. Download and decompress tomcat

(1) Download the installation package

Enter /usr Create a new mywork directory in the /local directory

  mkdir mywork

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

 wget "" 

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

(2) Decompress the installation package

After downloading, use the command to decompress,

 tar -zxvf compressed package name

3 .Start tomcat

Enter the main directory of tomcat, start tomcat, use the command

 bin/startup.sh

Check whether tomcat is started Success (whether the process exists), use the command

 ps -ef | grep tomcat

4. Check whether tomcat is installed successfully

(1) Check Firewall status

 systemctl status firewalld

Use the command if the above command is invalid

 service iptables status

(2) Turn off the linux firewall

 systemctl stop firewalld

Use the command if the above command is invalid

 service iptables stop

(3) Check the ip address information of linux

  ifconfig

(4) Visit tomcat

Enter the address in the browser, address: 8080

3. Install mysql

1. Uninstall the system’s own database mariadb

yum list installed | grep mariadb (查看系统是否安装了mariadb)

  yum -y remove 应用名称  (卸载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 the shell tool to upload it to Linux locally.

(2) Decompress the installation package

After downloading, use the command to decompress,

tar -zxvf compressed package name

Decompress After completion, change the file name,

 mv decompress the file name mysql

3. Create the data warehouse directory

 mkdir /mysql/data ( This directory stores database data)

4. Create mysql user and user group

  groupadd mysql (创建用户组)
  useradd -r -s /sbin/nologin -g mysql mysql -d /usr/local/mysql  (将mysql用户添加至组中并为用户指定mysql目录)

5. Specify the owner of the directory

进入到mysql根目录
  cd /usr/local/mysql
  改变目录所有者,
  chown -r mysql .  (不要忘记后面的.)
  chgrp -r mysql .
  chown -r mysql /mysql/data

6. Initialize mysql configuration parameters

在mysql根目录下执行,
  bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/mysql/data
  注意:命令执行后在末尾处会生成初始密码,将其复制到记事本中用于后面首次登录。
  设置数据加密,
  bin/mysql_ssl_rsa_setup --datadir=/mysql/data

7. Modify the system configuration file

将mysql配置文件添加到系统配置文件中,进入目录
  cd /usr/local/mysql/support-files
  复制,
  cp my-default.cnf /etc/my.cnf
  cp mysql.server /etc/init.d/mysql
  编辑mysql配置文件,指定基础目录和数据目录,
  vim /etc/init.d/mysql
  修改如下属性:
  basedir=/usr/local/mysql
  datadir=/mysql/data

8. Modify the password

启动mysql,
  /etc/init.d/mysql start  --5.0版本是 mysqld start
  登录,
  mysql -h localhost -u root -p
  输入第(6)步拿到的密码。如果出现:-bash :mysql :commond not found 就执行:ln -s /usr/local/mysql/bin/mysql /usr/bin  --创建命令软连接
  修改密码,
  set password=password('你要设置的密码')

9. Modify the operation of the remote host for the root user Permissions

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 path=/usr/local/mysql/bin:$path 

Make the configuration file effective

source /etc/profile<br>

11. Remote connection test

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

Supplement:

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 --The 5.0 version is service mysqld start
Restart mysql
service mysql restart --The 5.0 version is service mysqld restart

mysql can be passed Modify /etc/my.cnf for detailed configuration.

The above is the detailed content of How to set up a Java Web project running environment on a Linux system?. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:亿速云. If there is any infringement, please contact admin@php.cn delete
How does the JVM handle differences in operating system APIs?How does the JVM handle differences in operating system APIs?Apr 27, 2025 am 12:18 AM

JVM handles operating system API differences through JavaNativeInterface (JNI) and Java standard library: 1. JNI allows Java code to call local code and directly interact with the operating system API. 2. The Java standard library provides a unified API, which is internally mapped to different operating system APIs to ensure that the code runs across platforms.

How does the modularity introduced in Java 9 impact platform independence?How does the modularity introduced in Java 9 impact platform independence?Apr 27, 2025 am 12:15 AM

modularitydoesnotdirectlyaffectJava'splatformindependence.Java'splatformindependenceismaintainedbytheJVM,butmodularityinfluencesapplicationstructureandmanagement,indirectlyimpactingplatformindependence.1)Deploymentanddistributionbecomemoreefficientwi

What is bytecode, and how does it relate to Java's platform independence?What is bytecode, and how does it relate to Java's platform independence?Apr 27, 2025 am 12:06 AM

BytecodeinJavaistheintermediaterepresentationthatenablesplatformindependence.1)Javacodeiscompiledintobytecodestoredin.classfiles.2)TheJVMinterpretsorcompilesthisbytecodeintomachinecodeatruntime,allowingthesamebytecodetorunonanydevicewithaJVM,thusfulf

Why is Java considered a platform-independent language?Why is Java considered a platform-independent language?Apr 27, 2025 am 12:03 AM

JavaachievesplatformindependencethroughtheJavaVirtualMachine(JVM),whichexecutesbytecodeonanydevicewithaJVM.1)Javacodeiscompiledintobytecode.2)TheJVMinterpretsandexecutesthisbytecodeintomachine-specificinstructions,allowingthesamecodetorunondifferentp

How can graphical user interfaces (GUIs) present challenges for platform independence in Java?How can graphical user interfaces (GUIs) present challenges for platform independence in Java?Apr 27, 2025 am 12:02 AM

Platform independence in JavaGUI development faces challenges, but can be dealt with by using Swing, JavaFX, unifying appearance, performance optimization, third-party libraries and cross-platform testing. JavaGUI development relies on AWT and Swing, which aims to provide cross-platform consistency, but the actual effect varies from operating system to operating system. Solutions include: 1) using Swing and JavaFX as GUI toolkits; 2) Unify the appearance through UIManager.setLookAndFeel(); 3) Optimize performance to suit different platforms; 4) using third-party libraries such as ApachePivot or SWT; 5) conduct cross-platform testing to ensure consistency.

What aspects of Java development are platform-dependent?What aspects of Java development are platform-dependent?Apr 26, 2025 am 12:19 AM

Javadevelopmentisnotentirelyplatform-independentduetoseveralfactors.1)JVMvariationsaffectperformanceandbehavioracrossdifferentOS.2)NativelibrariesviaJNIintroduceplatform-specificissues.3)Filepathsandsystempropertiesdifferbetweenplatforms.4)GUIapplica

Are there performance differences when running Java code on different platforms? Why?Are there performance differences when running Java code on different platforms? Why?Apr 26, 2025 am 12:15 AM

Java code will have performance differences when running on different platforms. 1) The implementation and optimization strategies of JVM are different, such as OracleJDK and OpenJDK. 2) The characteristics of the operating system, such as memory management and thread scheduling, will also affect performance. 3) Performance can be improved by selecting the appropriate JVM, adjusting JVM parameters and code optimization.

What are some limitations of Java's platform independence?What are some limitations of Java's platform independence?Apr 26, 2025 am 12:10 AM

Java'splatformindependencehaslimitationsincludingperformanceoverhead,versioncompatibilityissues,challengeswithnativelibraryintegration,platform-specificfeatures,andJVMinstallation/maintenance.Thesefactorscomplicatethe"writeonce,runanywhere"

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use