Linux configuration JavaEE environment
All the software required for the article has been packaged:
Link: https://pan.baidu.com/s/1vDPN2eHo3Ugmxj41AgIoFw
Extraction code: ku4s
copy this content and open the Baidu SkyDrive mobile app, which is more convenient to operate-from Baidu SkyDrive Super member V3 sharing
Article Directory
Linux install JDK 8
-
mkdir /opt/jdk
, This directory is used to put JDK installation files
-
Upload the JDK installation file to the above directory via XFTP
-
cd /opt/jdk
, Enter the directory where the installation file is located -
tar -zxvf jdk-8u261-linux-x64.tar.gz
To unzip the file to the current directory -
mkdir /usr/local/java
, This directory is used to store uncompressed files -
mv /opt/jdk/jdk1.8.0_261 /usr/local/java
, Move the decompressed files to the above directory -
vim /etc/profile
, Configure environment variables -
Enter the following two lines at the end of this file:
export JAVA_HOME=/usr/local/java/jdk1.8.0_261
export PATH=$JAVA_HOME/bin:$PATH
-
source /etc/profile
To make the new environment variable take effect -
carry out testing:
(1) cd ~
, switch to the home directory or other other directories
(2) java -version
If the following appears, it means success:
Linux install Tomcat 8.5
-
mkdir /opt/tomcat
, This directory is used to store Tomcat installation files and decompressed files
-
Use XFTP to upload the Tomcat installation file to the above directory
-
cd /opt/tomcat
, Enter the directory where the installation file is located -
tar -zxvf apache-tomcat-8.5.59.tar.gz
To unzip the file to the current directory -
Open port 8080:
(1) firewall-cmd --permanent --add-port=8080/tcp
, show success means success
(2) firewall-cmd --reload
Restart the firewall to take effect, and display success means success
(3) firewall-cmd --query-port=8080/tcp
, displaying yes means that port 8080 is successfully opened
-
cd /opt/tomcat/apache-tomcat-8.5.59/bin/
, Enter the bin directory of Tomcat -
./startup.sh
, Start the Tomcat service
-
./shutdown.sh
, Stop Tomcat service -
To check whether it starts normally, enter in the browser address bar: http://[your Linux ip address]:8080
Realize Tomcat service self-start
(1) cd /opt/tomcat/apache-tomcat-8.5.59/bin/
Enter the bin directory
(2) vim setenv.sh
Create the setenv.sh file and set additional environment variables, the content is as follows:
# 设置Tomcat的PID文件
CATALINA_PID="$CATALINA_BASE/tomcat.pid"
# 添加JVM选项
JAVA_OPTS="-server -XX:PermSize=256M -XX:MaxPermSize=1024m -Xms512M -Xmx1024M -XX:MaxNewSize=256m"
(3) vim /opt/tomcat/apache-tomcat-8.5.59/bin/catalina.sh
Add at the beginning:
export JAVA_HOME=/usr/local/java/jdk1.8.0_261
export JRE_HOME=/usr/local/java/jdk1.8.0_261/jre
(4) cd /usr/lib/systemd/system
Create a file vim tomcat.service in this directory, the content is as follows:
[Unit]
Description=Tomcat
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
TimeoutSec=0
PIDFile=/opt/tomcat/apache-tomcat-8.5.59/tomcat.pid
ExecStart=/opt/tomcat/apache-tomcat-8.5.59/bin/startup.sh
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
(5) systemctl daemon-reload
Reload the service file to make the above content effective
(6) systemctl enable tomcat.service
Add the Tomcat service to start automatically after booting
(7) reboot
Restart the system to complete all the above functions
(8) systemctl status tomcat
, check the Tomcat service status
(9) s ystemctl list-unit-files | grep tomcat
to check whether the Tomcat service is self-starting
Linux install MySQL 5.7
-
mkdir /opt/mysql
, This directory is used to store the mysql installation files and the decompressed content
-
Use XFTP to upload the mysql installation file to the above directory
Note: You can also wget http://dev.mysql.com/get/mysql-5.7.26-1.el7.x86_64.rpm-bundle.tar
download the mysql installation package from the network. If there is no wget command, use yum install -y wget to install the wget command
-
cd /opt/mysql
, Enter the directory where the installation file is located -
tar -xvf mysql-5.7.26-1.el7.x86_64.rpm-bundle.tar
, Unzip the installation package -
The database that comes with CentOS 7.6 is mariadb, which will conflict with mysql and should be deleted first:
(1) rpm -qa|grep mari
, check the installation package related to mariadb
(2) rpm -e --nodeps mariadb-libs
, uninstall
(3) rpm -e --nodeps marisa
, uninstall
- Run the following commands in sequence to complete the installation:
rpm -ivh mysql-community-common-5.7.26-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.26-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.26-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.26-1.el7.x86_64.rpm
-
systemctl start mysqld.service
, Start mysql -
Set the root user password:
(1) grep "password" /var/log/mysqld.log
Check the password automatically generated by the system
(2) mysql -u root -p
Use the above password to log in
(3) set global validate_password_policy=0;
Set password security level
0: Only the length is required (default 8 digits)
1: Requires numbers, upper and lower case, special character combinations
2: Requires numbers, upper and lower case, special character combinations, and dictionary file combinations
(4) set password for 'root'@'localhost' =password('要设置的密码');
Set a password
(5) flush privileges;
Make the password effective
(6) quit
, exit the database
- Make SQLyog connect to the Linux database:
(1) Log in to the database
(2) GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "root用户的密码";
Add remote login function
(3) set names utf8;
Set the database encoding to UTF-8
(4) Enter the quit command input after exiting the database service mysqld restart;
restart mysql service
(5) Open port 3306:
i. firewall-cmd --permanent --add-port=3306/tcp
, show success to indicate success
ii. firewall-cmd --reload
Restart the firewall to take effect, and display success means success
iii. firewall-cmd --query-port=3306/tcp
Displaying yes means that port 3306 is successfully opened
(6) Use SQLyog to connect to this database
Realize MySql database self-start
service mysqld status
To view the database startup status
Linux install IDEA 2020.3
-
mkdir /opt/idea
, This directory is used to store IDEA installation package and decompressed data
-
Upload the installation file to the above directory via XFTP
-
cd /opt/idea
, Enter the directory where the installation file is located -
tar -zxvf ideaIU-2020.3.tar.gz
To unzip the file to the current directory
Note: The following two steps to start IDEA need to be performed in the terminal of the Linux graphical interface, and xshell cannot be used
-
cd /opt/idea/idea-IU-203.5981.155/bin/
, Enter the bin directory of the decompressed folder -
./idea.sh
To start IDEA
Install Nginx on Linux
- Upload pcre dependent files to the /usr/src directory of Linux
-
Enter the above directory,
cd /usr/src
-
Unzip the pcre compressed file,
tar -zxvf pcre-8.37.tar.gz
-
Enter the unzipped directory,
cd pcre-8.37/
-
Followed by the implementation
./configure
,make && make install
to complete the installation -
Check whether the installation is successful,
pcre-config --version
- Install openssl, zlib, gcc dependencies
yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel
- Upload the Nginx installation package to the /usr/src directory of Linux
- Enter the above directory,
cd /usr/src
-
Unzip the Nginx installation file,
tar -zxvf nginx-1.12.2.tar.gz
-
Enter the unzipped directory,
cd nginx-1.12.2/
-
Followed by the implementation
./configure
,make && make install
to complete the installation -
Open port 80:
(1) firewall-cmd --permanent --add-port=80/tcp
, show success means success
(2) firewall-cmd --reload
Restart the firewall to take effect, and display success means success
(3) firewall-cmd --query-port=80/tcp
, displaying yes means that port 80 is successfully opened
- Start Nginx,
cd /usr/local/nginx/sbin
and execute./nginx
- Enter http://[Linux IP address]:80 in the browser address bar (Nginx uses port 80 by default)