Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to merge session management and business servers in Mini Program

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the relevant knowledge of "how to merge session management and business servers in Mini Program". The editor shows you the operation process through an actual case, and the operation method is simple, fast and practical. I hope this article "how to merge session management and business servers in Mini Program" can help you solve the problem.

File migration

Because the images of the two servers are different, the environment inside is also different. The business server is the environment of nginx+php-fpm, while the session server is LAMP (Apache).

First log in to the session server and transfer the files to the business server.

Session server (172.16.0.15) / opt/lampp/htdocs/mina_auth migrates to-> business server (172.16.0.8) / data/release/session-wafer/mina_ auth[ root @ VM_0_15_centos htdocs] # pwd/opt/lampp/ htdocs [root @ VM_0_15_centos htdocs] # lsmina_auth update_ mina.sh [root @ VM_0_15_centos htdocs] # tar czvf session.tar.gz mina_auth

When the package is complete, copy the file through scp.

Scp / opt/lampp/htdocs/session.tar.gz root@172.16.0.8:/data/release/

File copy

Then, log in to the business server

Stop the php-fpm service and command:

Kill-QUIT cat / run/php-fpm/php-fpm.pid

Stop the nginx service and command:

Nginx-s stop

Extract session.tar.gz command: tar xzvf session.tar.gz

Create the mina_auth to the correct directory.

Set up nginx

Because the business server is already running on port 80, it would be more reasonable for us to configure the session server to port 8080 now. So we are making a nginx support multiple ports at the same time.

The default nginx has two configuration files

/ etc/nginx/nginx.conf this is the main configuration file. If you open it, you can find that it references all the configuration files in the directory / etc/nginx/conf.d at the end.

/ etc/nginx/conf.d/php-weapp-demo.conf this is the configuration of the 80-port business server; (I personally renamed it application-wafer.conf)

Make a copy of the application-wafer.conf, name it session-wafer.conf, and modify the following.

At this time, it seems that the configuration of the admixture has been modified, but if it cannot be run yet, some changes must be made in the program. Especially the encryption and decryption part, but it took Brother Zan all day to find out.

Modify Mini Program sdk configuration

Location: / etc/qcloud/sdk.config

Change this address to your business server's local address. For example, I changed from 172.16.0.15 to 172.16.0.8purl 8080

Modify decryption algorithm

I've been looking for this problem all day, and I'm very depressed.

Location: / data/release/session-wafer/minaauth/system/wxdecrypt_data/new/pkcs7Encoder.php

Problem description:

In the session server, the mcrypt plug-in is already installed with LAMP, while in the business server, it is not available. Please look at the phpinfo below. (you need to produce phpinfo in php.ini before you can check it)

The mcrypt in the session server is enabled

It was originally intended to install the mcrypt plug-in on the business server, but after checking the official website of php, especially php 7.1, mcrypt is particularly not recommended and can be replaced by openssl.

$decrypted = openssldecrypt (aesCipher,'aes?128?cbc',this- > key, OPENSSLRAW_DATA, $aesIV)

Restart the server

Start nginx and php-fpm, and direct high point commands nginx and php-fpm

Start two services

Testing work

Curl https://localhost/

Curl https://localhost:8080/mina_auth/

Note: Port 8080 cannot be accessed through the public network by default, but only through the private network of VPC.

This is the end of the content about "how to merge session management and business servers in Mini Program". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report