当前位置:网站首页>Production environment server environment setup + project release process

Production environment server environment setup + project release process

2022-06-23 08:03:00 Mysterious world

Production environment server environment setup ( install jdk+ File permissions +tomcat+Nginx+Postgres )+ Project release process

install jdk

install openjdk-8-jdk stay ubuntu-16.04 The following commands are used in the system :

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

Input java -version Check to see if it is installed correctly , 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 ( Servers and background folders )
  • home/beeoz/tmp ( Upload front-end folder )

Change document ownership chown

  • myfile Ownership of the document becomes username:sudo chown username myfile
  • Add parameters -R,work The ownership of the folder and all the files and subdirectories in the folder becomes username:chown -R username /files/work

Change file permissions chmod

  • sudo chmod 777 filename
  • sudo chmod -R 754 director
  • 4 Can be read ,
    2 Can write ,
    1 Executable
    0 No authority
    The sequential allocation of three numbers represents the user 、 User group 、 other . The first number 7 Indicates that the user's permission is read + Write + perform (4+2+1=7), The second number 5 Indicates that the permission of the user group is read + Executable (4+0+1=5), The third number 4 Indicates that the permission of others is to read (4+0+0=4)

install tomcat The server

The following can be added without configuration ( Change 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’

Be careful , This release will sites Medium tomcat-8.0.33 Renamed as wms

To 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/wms;

    # 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.taoware.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/wms/;
    }
  • sudo nginx -c /etc/nginx/nginx.conf start-up nginx
  • Open your website to watch , Note the ports of the firewall and the server security group
  • nginx -s stop Stop the order
  • nginx -s reload Download the configuration file again
  • sudo service nginx restart restart
  • service nginx {start|stop|status|restart|reload|configtest|}

install Postgres Database services

Management database

  • sudo -u postgres psql
  • postgres=# create database Library name ;
  • postgres=# create user user name ;
  • postgres=# alter user user name password ‘ password ’;
  • postgres=# alter user duye createrole createdb replication login;
  • postgres=# \l view the database
  • postgres=# \du View users and corresponding permissions

Project release

Preparation before project packaging

  • Change the data connection information before packaging the project ( Illustrate with examples :1. Change the database name to wms, User name changed to beeoz, Change the password to BeeOz2018), The specific editing position 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/wms125
    	username: beeoz
    	password: BeeOz2018

Project package

    1. Background project packaging command (cmd Enter the root directory file ):gradle --stacktrace -Pprod bootRepackage ; Store in APP In the project libs Under the document : The package file name is wms-0.0.1-SNAPSHOT.war
    1. Front end packaging command :cnpm run build ; The project is stored in dist In the folder , First, compress the two queries into a file in the resource directory dist.zip

Operating commands in the server

  • 1. Connect to server : Jump to /sites/wms Under the table of contents
  • 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 Yes, for 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. Go back to the previous Directory , Then enter logs Delete all items in the directory log: rm *
  • 9. return wms Under the table of contents , Start the server : ./bin/startup.sh
  • 10. Check the console log : tail -f logs/catalina.out

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

Modify the configuration file

  • 1. go in wms Folder
  • 2."./bin/shutdown.sh"
  • 3. function "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 of all to enter tmp Empty directory
  • 2. take dist.zip Copy the compressed file to this directory
  • 3. Run the command to unzip :unzip dist.zip
  • 4. Get into dist: cd dist
  • 5. Run the command to see :ls
  • 6. Run the command and copy it to the corresponding directory : mv * ~/sites/wms/webapps/wms/

Release process considerations

  • You can change the name of the server before it starts mv irengine-wms-app-0.0.1-SNAPSHOT.war wms.war
  • Can be dist Move the contents of to wms The original stage file should be saved before index.html File name is another name
  • Before releasing a new version webapps Backup of the original project in
  • If you need to update the version, you can logs Backup ; If not, please send logs Clear the log in and run the start server command
  • The foreground decompression needs to be installed unzip Tools ( install unzip: sudo apt install unzip)
  • Upload tools can be selected filezilla Tools such as , Before uploading, you need to confirm whether the modified folder has permission to receive

ln -s /etc/nginx/sites-available/dzk.unzone.com /etc/nginx/sites-enabled/dzk.unzone.com

To configure niginx File hyperlinks ln -s /etc/nginx/sites-available/dzk.unzone.com /etc/nginx/sites-enabled/dzk.unzone.com

原网站

版权声明
本文为[Mysterious world]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/174/202206230737045673.html