How to build a JavaWeb development environment

Preface

Build a javaweb development environment on the server, hereby record

One, install JDK

View the default JDK

java -version
rpm -qa|grep java

Use yum remove to uninstall the default JDK

yum remove 包名

Such as

yum remove java-1.8.0-openjdk-headless-1.8.0.262.b10-0.el7_8.x86_64

Create a directory

mkdir usr/java

Download the JDK on the Oracle official website and upload it to the server /usr/java directory

Unzip

tar -xzvf jdk-8u261-linux-x64.tar.gz

Configure environment variables

vim /etc/profile

Add at the end

#java environment
export JAVA_HOME=/usr/java/jdk1.8.0_261
#PATH
export PATH=$PATH:$JAVA_HOME/bin

Make the configuration effective

source /etc/profile

Verification is successful

java -version
javac -version

Success if the corresponding version number appears

Two, install Tomcat

Create a directory

mkdir /usr/tomcat

Download and unzip tomcat

cd usr/tomcat

wget https://mirror.bit.edu.cn/apache/tomcat/tomcat-9/v9.0.37/bin/apache-tomcat-9.0.37.tar.gz

tar -xzvf apache-tomcat-9.0.37.tar.gz

Enter tomcat directory

cd apache-tomcat-9.0.37/bin

Give all script permissions

chmod 777 *.sh

Start tomcat

./startup.sh

"Tomcat started." appears in the last line, then it is successful. After the server opens port 8080, enter IP:8080 in the browser address bar to see the tomcat page

To make tomcat boot up automatically, edit the following files

vim /etc/rc.d/rc.local

Add content as

touch /var/lock/subsys/local
export JAVA_HOME=/usr/java/jdk1.8.0_261
export PATH=$PATH:$JAVA_HOME/bin
export CATALINA_HOME=/usr/tomcat/apache-tomcat-9.0.37
/usr/tomcat/apache-tomcat-9.0.37/bin/startup.sh

Grant execution permissions

chmod +x /etc/rc.d/rc.local

Wait for a while after restarting the server, enter the server's public network IP in the browser: 8080 to check whether tomcat is started

Three, install MySQL

Download and apply the yum resource package of mysql

cd ~
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum update
yum install mysql-server

Change file owner and group

chown mysql:mysql -R /var/lib/mysql

Initialize and start mysql

mysqld --initialize
service mysqld start

Modify the mysql administrator password and log in to mysql

mysqladmin -u root password "your-password"

mysql -u root -p

Enter the password to log in, if "mysql>" appears, the login is successful

Guess you like

Origin blog.csdn.net/a159357445566/article/details/108601729