1. My server configuration


2. Preparation

① Download the package

  • Download JDK8:www.oracle.com/technetwork…

  • Or use my web disk link: pan.baidu.com/s/17sEwLhV-… Extraction code: E5WW

  • Download Redis5: redis. IO/Download

  • Or use my network backup link: pan.baidu.com/s/1LUGIHELh… Extraction code: EGW6

(2) download Xftp6

Xftp6 is a powerful software for SFTP and FTP file transfer, which can help users securely transfer files between UNIX/Linux and Windows PCS. We need to use this software to upload the compressed package to ali cloud server.

  • Please search for the installation package, download and install it.

3 Add security group rules

By default, the security group of the server does not have any custom permit rule. Therefore, the instance port cannot be accessed. To access the instance port, add the port corresponding to the security group rule.

  • We need to release common port numbers: 8080, 3306, 22, 6379, 80, etc.
  • Adding a security group rule:

4 Upload the compressed package to the server

  • Open the Xftp6 tool and clickfilenew.
  • Fill in the following information and connect to the server.

  • Then create a JavaWeb folder in /usr/local/ and upload the compressed package to this folder.

⑤ Set the firewall

Firewall is the first line of defense of the system, its function is to prevent illegal users from entering. By default, the firewall of the server does not set any custom permit rules. This will cause that the instance port cannot be accessed. If access is required, the port corresponding to the firewall permit is required. Note: CentOS7 uses firewalld as its firewall by default. Firewalld turns HTTP off by default.

Firewall-cmd --state # Check the firewall status systemctl start firewald. service # Check the firewall status systemctl stop firewald. service # Check the firewall status systemctl stop firewalld Systemctl enable firewalld. Service # enable firewalld. Service # disable firewalld. Service # disable firewalld --permanent --zone=public --add-port=8080/ TCP # Firewall - CMD --permanent --zone=public --add-port=22/ TCP # Firewall-cmd --permanent --zone=public --add-port=6379/ TCP # Firewall -- CMD --permanent --zone=public --add-port=80/ TCP # make the firewall permanently open on port 80 firewall-cmd --reload # Make the configuration valid firewall-cmd --permanent --zone=public --list-ports Firewall-cmd --permanent --zone=public --add-service= HTTP firewall -- CMD --reload Firewall-cmd --permanent --zone=public --list-serviceCopy the code


3. Install JDK8

Note: if the server version is CentOS7 series, try not to install the openJDK of the system (there will be a pit)!

1 Decompress the installation package

CD /usr/local/javaweb # go to the directory tar -zxvf jdK-8u201-linux-x64.tar. gz # decompress the package mv jdk1.8.0_201 jdk8 # rename the directoryCopy the code

② Configuration Environment

  • usevimCommand to open the file.
Vim /etc/profile # configure environment variablesCopy the code
  • And then pressiGo into edit mode and insert the following text.
Export JAVA_HOME=/usr/local/javaweb/jdk8 # Absolute directory where JDK is stored export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export PATH=$PATH:$JAVA_HOME/binCopy the code
  • Finally according to theEscAnd enter the:wqPress enter to exit.
Source /etc/profile # make the script file validCopy the code

③ Verify the configuration

javac
java -version
Copy the code

  • If the preceding information is displayed, the configuration is successful.

4. Install MySQL5.7

① Download and install

The RPM - the ivh http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm # download the installation package yum install -- y mysql server # MySQL systemctl start mysqld.service # start mysqld.service # start MySQL grep 'temporary Password '/var/log/mysqld.logCopy the code

(2) log in MySQL

SET PASSWORD = PASSWORD('Zxcvbnm10! ') _ '); The new password must contain uppercase and lowercase letters, digits, underscores (_), and exclamation marks (!). Eixt # Log out of MySQL again using the new passwordCopy the code

Ps: If the new password is too complex, modify the following two fields to lower the default password security level.

set global validate_password_policy=0; Set the password security level to LOW set global validate_password_length=6. Set the minimum password length to 6Copy the code

Ps: After the official launch of the project, it is better not to use too simple password, otherwise the server is likely to be attacked.

③ Remote Connection

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'new password' WITH GRANT OPTION; Flush PRIVILEGES; # Make the command execution take effectCopy the code

  • Use Navicat to access the database remotely.

  • Once connected, you can manage remote databases through Navicat.


5. Install Redis5

1 Decompress the installation package

CD /usr/local/javaweb # go to the directory tar -zxvf redis-5.0.4.tar.gz # decompress mv redis-5.0.4 redis5 # rename the directoryCopy the code

② Configuration Environment

CD/usr/local/javaweb/redis5 # # into the unzipped directory make to compile the mkdir -p/usr/local/javaweb/redis store redis cp # the newly created directory / usr/local/javaweb/redis5 / SRC/redis server/usr/local/javaweb/redis/cp # copy redis - server to the new directory / usr/local/javaweb/redis5 / SRC/redis - cli/usr/local/javaweb/redis/copy # redis - cli cp to the new directory / usr/local/javaweb/redis5 / redis. Conf/usr/local/javaweb/redis / # reproduction redis. Conf to the new directory CD/usr/local/javaweb/redis / # to enter a new directoryCopy the code
  • usevimCommand to open the file.
Vim/usr/local/javaweb/redis/redis. Conf # edit the configuration fileCopy the code
  • And then pressiGo into edit mode and edit the following fields.
Bind 127.0.0.1 -- > # bind 127.0.0.1 -- > # bind 127.0.0.1 Requirepass foobared -- > requirepass 123456Copy the code
  • Finally according to theEscAnd enter the:wqPress enter to exit.
  • usevimCommand to open the file.
Vim /etc/init.d/redisCopy the code
  • And then pressiGo into edit mode and insert the following text.
#! /bin/sh # chkconfig: 2345 80 90 # description: Start and Stop redis #PATH=/usr/local/bin:/sbin:/usr/bin:/bin REDISPORT=6379 EXEC=/usr/local/javaweb/redis/redis-server REDIS_CLI=/usr/local/javaweb/redis/redis-cli PIDFILE=/var/run/redis_6379.pid CONF="/usr/local/javaweb/redis/redis.conf" AUTH="123456" case "$1" in start) if [ -f $PIDFILE ] then echo "$PIDFILE exists, process is already running or crashed" else echo "Starting Redis server..." $EXEC $CONF fi if [ "$?"="0" ] then echo "Redis is running..." fi ;; stop) if [ ! -f $PIDFILE ] then echo "$PIDFILE does not exist, process is not running" else PID=$(cat $PIDFILE) echo "Stopping ..." $REDIS_CLI -p $REDISPORT SHUTDOWN while [ -x ${PIDFILE} ] do echo "Waiting for Redis to shutdown ..." sleep 1 done echo "Redis stopped" fi ;; restart|force-reload) ${0} stop ${0} start ;; *) echo "Usage: /etc/init.d/redis {start|stop|restart|force-reload}" >&2 exit 1 esacCopy the code
  • Finally according to theEscAnd enter the:wqPress enter to exit.
  • usevimCommand to open the file.
Vim /etc/rc.localCopy the code
  • And then pressiGo into edit mode and insert the following text.
service redis start
Copy the code
  • Finally according to theEscAnd enter the:wqPress enter to exit.

(3) login redis

Chmod 755 the/etc/init. Set the permissions on the d/redis # the chkconfig -- add redis # registration system service service redis start # start redis service ps - ef | grep redis # View the current state of ln -s/usr/local/javaweb/redis/redis - cli/usr/bin / # redis creating redis command soft connection CD / # redis into redis auth # 123456 password authentication Set name wiy # add user get nameCopy the code

④ Verifying the Configuration

  • If no error message is displayed, the configuration is successful.

⑤ Remote Connection

  • Access the database remotely using Redis Desktop Manager.

  • After connecting, you can manage remote databases through Redis Desktop Manager.

⑥ Refer to blogs

  • Blog.csdn.net/lc101007842…

6. Install Nginx

Nginx is a high-performance HTTP and reverse proxy server.

① Download and install

rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm # # yum repolist # yum install nginx # yum install nginx # yum install nginxCopy the code

(2) to start

Nginx systemctl reload nginx systemctl status Nginx # Check the startup status of nginxCopy the code

③ Verify the configuration

  • Access public IP address :80.

  • If the preceding information is displayed, the configuration is successful.

4 Directory structure after installation

RPM -ql nginx Start nginx: /usr/sbin/nginx Main configuration file: /etc/nginx/nginx.conf HTML page: /usr/share/nginx/html Cache directory: /var/cache/nginx/fastcgi_temp proxy directory: /var/cache/nginx/proxy_temp...Copy the code


7. Deploy the Springboot project

① Package items

Local command line: CD project root directory # go to this directory MVN package # Package the projectCopy the code

② Upload the JAR package

  • Use Xftp6 to upload the JAR package to the server.

③ Run the JAR package

  • Method 1: Run the JAR package in the current window.
CD/usr/local/javaweb/springboot # into the Java jar luckymoney - 0.0.1 - the SNAPSHOT. Jar # run the jar packageCopy the code

  • Method 2: Keep the JAR package running in the background.
CD/usr/local/javaweb/springboot # into the directory nohup Java jar luckymoney - 0.0.1 - the SNAPSHOT. Jar & # run the jar package cat nohup. Out # This file holds the real-time output of the consoleCopy the code

④ Verifying the Configuration

  • As shown above, we have successfully accessed the SpringBoot project, which indirectly indicates that the configuration is correct!
  • Ctrl + V: Stop running the project.

The appendix

  • My personal blog is Messiwjy.top
  • If you have any errors or doubts, please contact [email protected]