Linux configuration JavaEE environment Linux installation JDK, Tomcat, mysql, IDEA, Nginx Linux settings Tomcat auto-start, Linux settings mysql auto-start

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

Linux install JDK 8

  1. mkdir /opt/jdk, This directory is used to put JDK installation files
    Insert picture description here

  2. Upload the JDK installation file to the above directory via XFTP

  3. cd /opt/jdk, Enter the directory where the installation file is located

  4. tar -zxvf jdk-8u261-linux-x64.tar.gzTo unzip the file to the current directory

  5. mkdir /usr/local/java, This directory is used to store uncompressed files

  6. mv /opt/jdk/jdk1.8.0_261 /usr/local/java, Move the decompressed files to the above directory

  7. vim /etc/profile, Configure environment variables

  8. 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
  1. source /etc/profileTo make the new environment variable take effect

  2. carry out testing:

(1) cd ~, switch to the home directory or other other directories

(2) java -versionIf the following appears, it means success:

Insert picture description here

Linux install Tomcat 8.5

  1. mkdir /opt/tomcat, This directory is used to store Tomcat installation files and decompressed files
    Insert picture description here

  2. Use XFTP to upload the Tomcat installation file to the above directory

  3. cd /opt/tomcat, Enter the directory where the installation file is located

  4. tar -zxvf apache-tomcat-8.5.59.tar.gzTo unzip the file to the current directory

  5. Open port 8080:

(1) firewall-cmd --permanent --add-port=8080/tcp, show success means success

(2) firewall-cmd --reloadRestart 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

  1. cd /opt/tomcat/apache-tomcat-8.5.59/bin/, Enter the bin directory of Tomcat

  2. ./startup.sh, Start the Tomcat service

Insert picture description here

  1. ./shutdown.sh, Stop Tomcat service

  2. To check whether it starts normally, enter in the browser address bar: http://[your Linux ip address]:8080

Insert picture description here

Realize Tomcat service self-start

(1) cd /opt/tomcat/apache-tomcat-8.5.59/bin/Enter the bin directory

(2) vim setenv.shCreate 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.shAdd 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/systemCreate 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-reloadReload the service file to make the above content effective

(6) systemctl enable tomcat.serviceAdd the Tomcat service to start automatically after booting

(7) rebootRestart the system to complete all the above functions

(8) systemctl status tomcat, check the Tomcat service status

Insert picture description here

(9) s ystemctl list-unit-files | grep tomcatto check whether the Tomcat service is self-starting
Insert picture description here

Linux install MySQL 5.7

  1. mkdir /opt/mysql, This directory is used to store the mysql installation files and the decompressed content
    Insert picture description here

  2. 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.tardownload the mysql installation package from the network. If there is no wget command, use yum install -y wget to install the wget command

  1. cd /opt/mysql, Enter the directory where the installation file is located

  2. tar -xvf mysql-5.7.26-1.el7.x86_64.rpm-bundle.tar, Unzip the installation package

  3. 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

Insert picture description here

(2) rpm -e --nodeps mariadb-libs, uninstall

(3) rpm -e --nodeps marisa, uninstall

  1. 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
  1. systemctl start mysqld.service, Start mysql

  2. Set the root user password:

(1) grep "password" /var/log/mysqld.logCheck the password automatically generated by the system

Insert picture description here

(2) mysql -u root -pUse 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

  1. 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 --reloadRestart the firewall to take effect, and display success means success

iii. firewall-cmd --query-port=3306/tcpDisplaying yes means that port 3306 is successfully opened

(6) Use SQLyog to connect to this database
Insert picture description here

Realize MySql database self-start

Insert picture description here

service mysqld statusTo view the database startup status

Linux install IDEA 2020.3

  1. mkdir /opt/idea, This directory is used to store IDEA installation package and decompressed data
    Insert picture description here

  2. Upload the installation file to the above directory via XFTP

  3. cd /opt/idea, Enter the directory where the installation file is located

  4. tar -zxvf ideaIU-2020.3.tar.gzTo 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

  1. cd /opt/idea/idea-IU-203.5981.155/bin/, Enter the bin directory of the decompressed folder

  2. ./idea.shTo start IDEA

Install Nginx on Linux

  1. Upload pcre dependent files to the /usr/src directory of Linux

Insert picture description here

  1. Enter the above directory,cd /usr/src

  2. Unzip the pcre compressed file,tar -zxvf pcre-8.37.tar.gz

  3. Enter the unzipped directory,cd pcre-8.37/

  4. Followed by the implementation ./configure, make && make installto complete the installation

  5. Check whether the installation is successful,pcre-config --version

Insert picture description here

  1. Install openssl, zlib, gcc dependencies
yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel
  1. Upload the Nginx installation package to the /usr/src directory of Linux

Insert picture description here

  1. Enter the above directory,
cd /usr/src
  1. Unzip the Nginx installation file,tar -zxvf nginx-1.12.2.tar.gz

  2. Enter the unzipped directory,cd nginx-1.12.2/

  3. Followed by the implementation ./configure, make && make installto complete the installation

  4. Open port 80:

(1) firewall-cmd --permanent --add-port=80/tcp, show success means success

(2) firewall-cmd --reloadRestart 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

  1. Start Nginx, cd /usr/local/nginx/sbinand execute./nginx

Insert picture description here

  1. Enter http://[Linux IP address]:80 in the browser address bar (Nginx uses port 80 by default)

Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_49343190/article/details/111657033