Home > Article > WeChat Applet > Introduction to setting up local debugging environment for WeChat development
The local debugging developed by WeChat only supports port 80. We have tried many methods. To summarize:
Method 1:
The company uses China Unicom ADSL, after completing port mapping on the router, I found that China Telecom/China Unicom blocked port 80, so this method will not work.
Method 2:
You can search it, you can use ngrok, download it quickly, and set it up. When filling in the ngrok URL into the WeChat settings, WeChat prompted that this kind of URL has security risks and is no longer supported.
Method 3:
This method requires you to have an external Linux server. WeChat requires that the domain name of this machine has been registered through ICP. You can use a subdomain name of your development domain name to point to this server. For example http://wechatdev.yourdomain.com
(1) First: close the service occupying port 80 of the Linux server;
(2) Turn on the remote forwarding function of the server and execute The following command:
sudo nano /etc/ssh/sshd_config
Add a sentence at the end of the /etc/ssh/sshd_config file:
GatewayPorts yes
Then Restart SSH: sudo service ssh restart
I tried Linux virtual machines of Alibaba Cloud and Azure. There are the following things to note:
Alibaba Cloud
Open the firewall and allow access to port 80
Azure:
Open the firewall and allow access to port 80
The special thing about Azure compared to Alibaba Cloud is that root It is not turned on by user default. All we need to do is open the root user
and log in with SSH. There should be a user when you create the virtual machine.
Execute the following command:
sudo nano /etc/ssh/sshd_config
Modify
PermitRootLogin without-password
is:
#PermitRootLogin without-password (comment out)
PermitRootLogin yes
Then restart SSH:
sudo service ssh restart
Then switch to the root user
sudo su
Check whether the root user is locked (LOCK means locked)
[root@Linux ~]# grep root /etc/shadow
root:*LOCK*:14600::::::
Give root a password to enable root
[root @Linux ~]# passwd
The last step is to set up port forwarding and run it on this machine (assuming you use MAC):
ssh -R 80:localhost: 9001 root@wechatdev.yourdomain.com (This sentence means that all traffic sent to wechatdev.yourdomain.com:80 is forwarded to the local 9001 port.
More local debugging environment for WeChat development For articles related to the construction introduction, please pay attention to the PHP Chinese website
##!