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 build API & WEB WebSocket Server

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

Share

Shulou(Shulou.com)05/31 Report--

Today, I will talk to you about how to build an API & WEB WebSocket server. Many people may not know much about it. In order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.

A brief introduction to the experiment

This lab details Mini Program and service number development environment and cloud software installation and deployment; through experimental operations to master Docker,

Use Git, Phabricator and other cloud software; master the creation and management of cloud resources.

Second, experimental objectives

Complete the construction of the development environment

Proficient in the use of Docker, Git and Phabricator software

Master the creation and management of various cloud resources.

Third, experiment step 1. Assign domain name & apply for SSL/TLS certificate

1.1 assign a domain name

Assign two second-level domain names to the development management platform and Web/WebSocket Server respectively.

Domain name IP address usage

Dev.appcook.cn pending development management platform

Wss.appcook.cn pending API & WEB & WebSocket server

1.2 apply for SSL/TLS certificate free of charge

In order to ensure that the data will not be stolen in transmission, Mini Program requires its server to enable SSL certificate to encrypt the data in transmission. Open

Private data such as internal documents and codes are saved in the hair management platform, so it is also necessary to enable SSL certificates for the transmission process.

Encrypt to prevent data from being stolen. We will introduce the principle of SSL/TLS certificate encryption in detail later.

Follow the tips in this section to request an SSL/TLS certificate for dev.appcook.cn and wss.appcook.cn.

Step 1: log in to Tencent Cloud SSL Certificate console, enter the certificate list, and click "apply for Certificate button"

Step 2: enter the domain name, set the password, and click OK

Step 3: set up the CNAME resolution record and verify all the information of the domain name according to the prompts.

Step 4: add a CNAME record

Step 5: after receiving the successful SMS message of the certificate application, log in to the certificate console and click the download button to download the relevant text of the certificate.

Pieces.

two。 Create a CDB MySQL instance

According to the method described in this section, create two MySQL instances for developing the management platform and Wechat O2O solution core, respectively.

Heart data storage.

2.1 create and initialize an instance

Step 1: enter the Tencent Cloud database management panel (https://console.qcloud.com/cdb) and click on the upper left corner.

[new] button.

Step 2: select the configuration of Guangzhou Zone 3, 1000MB memory, 25g hard disk, MySQL 5.6and confirm the reality after purchase.

For example.

Step 3: return to the list of cloud databases, click "initialize" instance, select UTF8 character set, and set password Root account.

Password to initialize the instance.

2.2 create a database

Step 1: click the database instance in the database console to enter the details page, and then click [log in to the database] in the upper right corner and click

Button, enter phpMyAdmin.

Step 2: enter the database root password to log in (the password set when initializing the database, see Lab 2)

Step 3: click the menu in the left column of phpMyAdmin, click the "New" button, and enter the database name in the main interface, for example:

Tuanduimao.com and select the database character set utf8_general_ci.

Step 4: display after successful creation

2.3 create a user

Step 1: go to the cloud database details page, click "account Management", and switch to the database instance account management panel.

Step 2: click the "create account" button, enter the root account password, and then click next.

Step 3: fill in the user name, password and other information and click "OK"

Step 4: select the database tuanduimao.com we just created on the left menu, and click Select all in the interface on the right.

Click [OK] later. The account has all the permissions of the database tuanduimao.com.

Step 5: created successfully, the user you just created will appear in the account list.

3. Create a CRS instance

Step 1: enter the Redis management panel (https://console.qcloud.com/redis) of Tencent Cloud Storage and click on the top left.

Corner [New] button

Step 2: select the configuration of Guangzhou Zone 3 (consistent with the CVM), master / slave version and capacity 1GB, and confirm the actual creation after purchase.

For example.

Step 3: return to the list of cloud storage Redis instances, click "initialize" instance, set password, and initialize the instance.

4. Create a CVM CVM instance

According to the method described in this section, create two CVM instances for the development of the management platform and Wechat O2O solution API

& WEB & WebSocket server.

4.1 create an instance

Step 1: enter Tencent Cloud https://console.qcloud.com/cvm and click * * New * * in the upper left corner.

Build] button.

Step 2: select the ordinary type, Guangzhou Zone 3, and standard model S1 host

Step 3: select Ubuntu Linux Server 14.04 LTS 64-bit image

Step 4: select 20g system disk and 20g data disk

Step 5: fill in the password and keep in mind that the security group is set to all ports by default, and create the master after confirming the purchase.

Machine.

Step 6: wait for the CVM to be created, and then log in to SSH for testing.

1. # when prompted for a password, enter the password 2. Ssh ubuntu@123.207.229.22 you set when you created the CVM

Authentication information: after a successful login, the following server summary information is displayed

4.2 Mount the data disk

Format data disk and mount to / host

1. # View disk device name 2. Sudo fdisk-l 3. 4. # format disk 5. Sudo fdisk / dev/vdb # enter n p 1 enter enter wq 6. 7. # View disk letter 8. Sudo fdiks-l 9.10. # create a file system 11. Sudo mkfs.ext4 / dev/vdb112.13. # Mount to / host14. Sudo mkdir / host15. Sudo mount / dev/vdb1 / host16.17. # View the result 18. Df-kh

The following information is returned, indicating that the mount is successful.

Set to auto mount

1. # add to fstab and automatically mount 2. Sudo sh-c 'echo "/ dev/vdb1 / host ext4 defaults 00" > / etc/fstab'''

4.3 install and configure Docker

After logging in to the CVM ssh ubuntu@123.207.229.22, run the following command

1.2. # install Docker3. Curl-sSL https://get.daocloud.io/docker | sh4.5. # enable accelerator 6. Sudo sh-c''echo "DOCKER_OPTS=\"\ $DOCKER_OPTS-- registrymirror= http://5382404c.m.daocloud.io\"" > > / etc/default/docker'''7.8. # restart Docker9. Sudo service docker restart10.11. # verify installation 12. Sudo docker run hello-world

The following information is returned, indicating that the installation was successful

5. Set up API & WEB & WebSocket server

5.1 install XpmJS-Server

Log in to the CVM ssh ubuntu@123.207.157.212 (you need to replace it with the public network IP of your Tencent Cloud CVM), and use the docker run command to create a file named

A container for xpmjs-server.

1.2. Docker run-d-name=xpmjs-server\ 3.-e "HOST=wss.appcook.cn" >

5.2 resolving domain names

With reference to example 4.2, resolve the domain name wss.appcook.cn to 123.207.157.212 (to be replaced by the public network IP of your Tencent Cloud CVM).

5.3 installation configuration

Visit http://wss.appcook.cn and refer to the XpmJS documentation according to the page prompt

(https://git.oschina.net/xpmjs/xpmjs) complete the API & WEB & WebSocket server configuration.

Step 1: enter the Redis address password, verify and save

Step 2: enter the MySQL account configuration, verify and save

Step 3: enter system information

Step 4: enter the default administrator password to start the installation

Step 5: team cat Dashboard (installed successfully)

After reading the above, do you have any further understanding of how to build an API & WEB WebSocket server? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

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

Servers

Wechat

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

12
Report