Home Java javaTutorial How to set up a Java Web project running environment on a Linux system?

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

Apr 26, 2023 am 08:07 AM
linux java web

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
Copy after login

​, 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  
Copy after login

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)
Copy after login

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目录)
Copy after login

5. Specify the owner of the directory

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

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
Copy after login

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
Copy after login

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('你要设置的密码')
Copy after login

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'; 
Copy after login

Make permissions effective

flush privileges; 

View user table permissions

 use mysql;
  select * from user;
Copy after login

10. Add system environment variables

vim /etc/profile 

Add at the end:


export path=/usr/local/mysql/bin:$path 
Copy after login

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 of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

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

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What computer configuration is required for vscode What computer configuration is required for vscode Apr 15, 2025 pm 09:48 PM

VS Code system requirements: Operating system: Windows 10 and above, macOS 10.12 and above, Linux distribution processor: minimum 1.6 GHz, recommended 2.0 GHz and above memory: minimum 512 MB, recommended 4 GB and above storage space: minimum 250 MB, recommended 1 GB and above other requirements: stable network connection, Xorg/Wayland (Linux)

Linux Architecture: Unveiling the 5 Basic Components Linux Architecture: Unveiling the 5 Basic Components Apr 20, 2025 am 12:04 AM

The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

PHP vs. Python: Use Cases and Applications PHP vs. Python: Use Cases and Applications Apr 17, 2025 am 12:23 AM

PHP is suitable for web development and content management systems, and Python is suitable for data science, machine learning and automation scripts. 1.PHP performs well in building fast and scalable websites and applications and is commonly used in CMS such as WordPress. 2. Python has performed outstandingly in the fields of data science and machine learning, with rich libraries such as NumPy and TensorFlow.

PHP's Impact: Web Development and Beyond PHP's Impact: Web Development and Beyond Apr 18, 2025 am 12:10 AM

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

How to run java code in notepad How to run java code in notepad Apr 16, 2025 pm 07:39 PM

Although Notepad cannot run Java code directly, it can be achieved by using other tools: using the command line compiler (javac) to generate a bytecode file (filename.class). Use the Java interpreter (java) to interpret bytecode, execute the code, and output the result.

vscode terminal usage tutorial vscode terminal usage tutorial Apr 15, 2025 pm 10:09 PM

vscode built-in terminal is a development tool that allows running commands and scripts within the editor to simplify the development process. How to use vscode terminal: Open the terminal with the shortcut key (Ctrl/Cmd). Enter a command or run the script. Use hotkeys (such as Ctrl L to clear the terminal). Change the working directory (such as the cd command). Advanced features include debug mode, automatic code snippet completion, and interactive command history.

How to check the warehouse address of git How to check the warehouse address of git Apr 17, 2025 pm 01:54 PM

To view the Git repository address, perform the following steps: 1. Open the command line and navigate to the repository directory; 2. Run the "git remote -v" command; 3. View the repository name in the output and its corresponding address.

Where to write code in vscode Where to write code in vscode Apr 15, 2025 pm 09:54 PM

Writing code in Visual Studio Code (VSCode) is simple and easy to use. Just install VSCode, create a project, select a language, create a file, write code, save and run it. The advantages of VSCode include cross-platform, free and open source, powerful features, rich extensions, and lightweight and fast.

See all articles