Construction of production environment and server environment

Time:2021-12-1

Construction of production environment and server environment

Install JDK

Install openjdk-8-jdk in ubuntu-16.04 system through the following command:

  • 1.sudo add-apt-repository ppa:jonathonf/openjdk
  • 2.sudo apt-get update
  • 3.sudo apt-get install openjdk-8-jdk

Enter Java – version to check whether the installation is correct. The output is as follows:

openjdk version "1.8.0_191"
OpenJDK Runtime Environment (build 1.8.0_191-8u191-b12-1~16.04.york0-b12)
OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode)

Create a publishing directory and give corresponding permissions

  • Home / beeoz / sites (server and background folders)
  • Home / beeoz / TMP (upload front-end folder)

Change file ownership chown

  • The ownership of the myfile file becomes Username: sudo chown username myfile
  • Add the parameter – R, and the ownership of the work folder and all files and subdirectories in the folder will be changed to Username: chown – R username / files / work

Change file permissions Chmod

  • sudo chmod 777 filename
  • sudo chmod -R 754 director
  • 4 readable,

2 writable,
1 executable
0 has no permission
The sequential allocation of three numbers represents users, user groups, and others. The first number 7 indicates that the user’s permission is read + Write + execute (4 + 2 + 1 = 7), the second number 5 indicates that the user group’s permission is read + executable (4 + 0 + 1 = 5), and the third number 4 indicates that the permission of others is read (4 + 0 + 0 = 4)

Install Tomcat server

  • 1. Installing tomcat8 cannot be installed in the system directory, but in the user directory. The operation commands in the system directory are inconsistent with those in the general directory
  • 2. Update sudo apt get update
  • 3. Download WGet http://ftp.riken.jp/net/apach…
    1. Unzip to the sites folder tar -zxvf ~ / apache-tomcat-8.0.33.tar.gz – C ~ / sites

The following can be added without configuration (changed to production environment)

  • cp catalina.sh catalina.sh.date
  • vi catalina.sh
  • JAVA_OPTS=’-Dspring.profiles.active=prod -Xms512m -Xmx2048m -XX:PermSize=256M -XX:MaxNewSize=256m -* XX:MaxPermSize=256m’

Note that tomcat-8.0.33 in sites will be renamed WMS in this release

Configure nginx service forwarding Tomcat

  • sudo apt-get install nginx
  • sudo vim /etc/nginx/sites-available/default

default

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    root /home/beeoz/sites/wms/webapps/xxx;

    # Add index.php to the list if you are using PHP
    index index.html index.htm index.nginx-debian.html;
    # server_name _;

    server_name vpshw1.xxxxx.com;

    location / {
            # First attempt to serve request as file, then
            # as directory, then fall back to displaying a 404.
            # try_files $uri $uri/ =404;
            # proxy_pass http://114.116.22.35:8080/wms;
            proxy_set_header X-Forwarded-Host $host;
            proxy_set_header X-Forwarded-Server $host;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

            proxy_pass http://localhost:8080/xxx/;
    }
  • Sudo nginx – C / etc / nginx / nginx.conf start nginx
  • Open your website to watch, and pay attention to the ports of firewall and server security group
  • Nginx – s stop stop command
  • Nginx – s reload to download the configuration file again
  • Sudo service nginx restart
  • service nginx {start|stop|status|restart|reload|configtest|}

Install Postgres database service

  • Please refer to the literature: https://www.cnblogs.com/zhaoj…

Management database

  • sudo -u postgres psql
  • Postgres = # create database database name;
  • Postgres = # create user name;
  • Postgres = # alter user username password ‘password’;
  • postgres=# alter user duye createrole createdb replication login;
  • Postgres = # l view database
  • Postgres = # Du view user and corresponding permissions

Project release

Preparation before project packaging

  • Change the data connection information before packaging the project (for example: 1. Change the database name to WMS, the user name to beeoz, and the password to beeoz2018). The specific editing location is as follows:

application-prod.yml

spring:
    devtools:
        restart:
               enabled: false
        livereload:
            enabled: false
    datasource:
        type: com.zaxxer.hikari.HikariDataSource
        url: jdbc:postgresql://localhost:5432/xxx
        username: xxx
        password: xxx2018

Pack Project

    1. Background project packaging command (CMD into the root directory file): gradle — stacktrace – pprod bootrepackage; Stored in the LIBS file in the app project: the name of the package file is wms-0.0.1-snapshot.war
    1. Front end packaging command: cnpm run build; The project is stored in the dist folder. First, compress the two bids into a file dist.zip in the resource directory

Operating commands in the server

  • 1. Connect to the server: jump to the / sites / WMS directory
  • 2. Run the command to shut down the server. / bin / shutdown.sh
  • 3. Backup under the same directory: MV webapps webapps. 9.5 (webapps. 9.5 is an example)
  • 4. Create a folder under the same directory: MKDIR webapps
  • 5. Jump to the new folder: CD webapps
  • 6. Put the local background items under this folder through the price inquiry transmission tool
  • 7. Run in the same directory: MV WMS – 0.0.1-snapshot.war wms.war generate wms.war file
  • 8. Return to the previous directory, and then enter the logs directory to delete all logs: RM*
  • 9. Return to the WMS directory and start the server:. / bin / startup.sh
  • 10. View console logs: Tail – f logs / catalina.out

If you want to modify the contents of the configuration file or related files

Modify profile

  • 1. Enter WMS folder
  • 2.”./bin/shutdown.sh”
  • 3. Run “VI. / WEB-INF / classes / config / application-prod.yml”
  • 4. Edit and save exit
  • 5. Restart:. / bin / startup.sh
  • 6. View console: Tail – f logs / catalina.out

Front end publishing project

  • 1. First enter the TMP empty directory
  • 2. Copy the dist.zip compressed file to this directory
  • 3. Run the command to unzip dist.zip
  • 4. Enter dist: CD dist
  • 5. Run the command to view: LS
  • 6. Run the command and copy it to the corresponding directory: MV * ~ / sites / WMS / webapps / WMS/

Release process considerations

  • The name MV irengine-wms-app-0.0.1-snapshot.war wms.war can be modified before the server is started
  • The contents in dist can be moved to WMS. Before moving the contents to WMS, the original stage file index.html file name should be renamed
  • Back up the original project in webapps before publishing the new version
  • If you need to update the version, you can back up the logs; If not, clear the logs in logs and run the start server command
  • Unzip tool needs to be installed for foreground decompression (install unzip: sudo apt install unzip)
  • You can select tools such as FileZilla for uploading. Before uploading, you need to confirm whether the changed folder has permission to receive