“This is the 28th day of my participation in the Gwen Challenge in November. Check out the details: The Last Gwen Challenge in 2021.”

preface

The previous chapter briefly introduced the process of creating a wechat applet based on Spring Boot. Today, I will briefly introduce the deployment of the project to the server and submit the front-end code to wechat for review. Let’s get straight to the point. 21, based on Spring Boot to develop a micro channel small program

Start the project

All interfaces for the back-end Springboot-based wechat applets service have been developed, so now it’s time to deploy the service to the cloud server and log in to the server.Using Maven to package the project,

Package the project’s files and upload them to the server

Run the ls command to see that the file has been uploaded to the server. Run the Java -jar BootWxTool-0.0.1 -snapshot. jar command to start the Spring Boot project. The startup process is shown in the following figure.

java -jar BootWxTool-0.01.-SNAPSHOT.jar
Copy the code

After the project is started, the service cannot be accessed because the security group is not configured. If the security group is not configured on the server, configure the ports used in the project in the server security group.

Configure Nginx

After configuring the security group, you need to configure Nginx for forwarding. Port 80 is not used this time. Locate the Nginx configuration file:

/www/server/nginx/conf
Copy the code

Run the vim nginx.conf command to check the path of the configuration file: Therefore, you need to configure the service in this path.

include /www/server/panel/vhost/nginx/*.conf;

Copy the code

Go to the folder where the configuration file resides

cd /www/server/panel/vhost/nginx/
Copy the code

Create a new file

mkdir wxtool.conf
Copy the code

Enter the following information: Listen indicates the information about the port to listen, and server_name indicates the information about the domain name to be configured. Root is followed by the path information for the project. Be careful to include proxy information. Otherwise, the project path may not be accessible. The information after proxy_*** is the proxy information to be configured. Ssl_certificate and SSL_certificate_key are the path information of the applied SSL file.

server
{
    listen 80;
    listen 443 ssl http2;
    server_name weixin.******.com;
    index index.php index.html index.htm default.php default.htm default.html;
    root /java/springboot;
    if($server_port ! ~443){
        rewrite ^(/.*)$ https://$host$1 permanent; } location / {
    proxy_pass http:/ / 127.0.0.1:8080;
    proxy_set_header Host $host:80;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
	}
    #HTTP_TO_HTTPS_END
    ssl_certificate    /etc/letsencrypt/live/weixin/6199589_weixin.ruankaoti.com.pem;
    ssl_certificate_key    /etc/letsencrypt/live/weixin/6199589_weixin.ruankaoti.com.key;
    ssl_protocols TLSv1 TLSv11. TLSv12.; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:! aNULL:! MD5:! RC4:! DHE; ssl_prefer_server_ciphers on; ssl_session_cache shared:SSL:10m; ssl_session_timeout 10m; error_page497  https://$host$request_uri;

    #SSL-END
    
  
    error_page 404 /404.html;
    error_page 502 /502.html; # # ERROR PAGE - END blocking access to the file or directory location ~ ^ / (\. User. Ini | \. Htaccess file | \. Git | \. SVN | \. Project | LICENSE | README. Md) {return 404; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; error_log off; access_log off; } location ~ .*\.(js|css)? $ { expires 12h; error_log off; access_log off; } access_log /www/wwwlogs/weixin.*****.com.log; error_log /www/wwwlogs/weixin.*****.com.error.log; }Copy the code

After the configuration file and the REQUESTED SSL certificate are configured, click Reload Configuration in the Pagoda page Nginx console.

Test project

Enter the domain name information https://weixin.****.com in the browser and you can see that the web page can be accessed normally.

Open the wechat developer tool, configure the domain name information into the file, and the test can be accessed normally. The screenshot is as follows:

Then upload the front-end code to the test version and submit it for review before it can be released normally. The whole audit process is expected to take about a day. After the completion of the audit, managers need to log in to the background of wechat public platform for online, online, we can access the project in the small program. I want to give you a screenshot of the project that has been published online.

conclusion

Well, the above is to record a deployment of micro channel small program process and online micro channel small program, thank you for reading, I hope you like it, if it is helpful to you, welcome to like collection. If there are shortcomings, welcome comments and corrections. See you next time.

About the author: [Little Ajie] a love tinkering with the program ape, JAVA developers and enthusiasts. Public number [Java full stack architect] maintainer, welcome to pay attention to reading communication.