Server instance tutorial for building small program development based on Alibaba Cloud

零下一度
Release: 2017-05-19 15:15:09
Original
6012 people have browsed it

Originally I wanted to write about building a WeChat applet server based on Tencent Cloud. Unfortunately, Tencent Cloud gave me a bad experience, so I gave up using Tencent Cloud. So I registered a domain name on Alibaba Cloud and purchased a cloud server ECS.

The configuration of ECS is flexible. You can choose a reasonable configuration according to your own needs. If you are a beginner and want to learn, just choose the lowest configuration at the beginning.

Server instance tutorial for building small program development based on Alibaba Cloud

ECS configuration purchase interface

Because in the production environment of the mini program, for security reasons, when calling the server's REST API or WebSocket , the server must provide a secure link address (such as mydomain/myservice, wss://mydomian), that is, SSL needs to be used. So we need to purchase a CA certificate and domain name for our server.

It is very convenient to register a domain name on Alibaba Cloud. You can go to the wanwang.aliyun.com page to register one. As for CA certificates, many domestic and foreign institutions provide certificate issuance certification, domestic ones such as WoSign, and foreign ones such as Symantec. This certificate is still a bit expensive. The price varies greatly depending on the different functions of the certificate. The cheapest one is better. Hundreds a year. There are also free certificates available now, such as Let's Encrypt. However, Alibaba Cloud also provides free certificates, which are very convenient to apply for. Let’s take a look at how to apply for a free certificate in Alibaba Cloud.

From the "Products and Services" menu at the top of the Alibaba Cloud page, you can see "CA Certificate Service":

Server instance tutorial for building small program development based on Alibaba Cloud

CA Certificate Service Menu

After entering the page, click the "Purchase Certificate" button in the upper right corner of the page to enter the certificate selection interface:

Server instance tutorial for building small program development based on Alibaba Cloud

Certificate Selection

Here you can choose the "Free DV SSL" certificate. This kind of certificate can only be valid for one detailed domain name. That is to say, if you have several sub-domain names, such as blog.mydomain.com, www For .mydomain.com and shop.mydomain.com, you need to purchase 3 certificates respectively. After the purchase is completed, you can click "Complete" information in the order list you purchased, enter the domain name to be bound to this certificate, your personal details, etc., and submit it to the issuing agency for review. After the review is completed, you You will also receive an email in the email address filled in with instructions on how to set it up (this email is mainly a setup guide for users whose domain name is not registered with Alibaba Cloud. If the domain name is registered with Alibaba Cloud, a resolution record will be automatically added to your domain name. You don’t need to add it manually).

Then, please click the "Download" certificate file button in the order list to download the certificate file, which contains some certificates for different http servers, such as apache, nginx, IIS, etc., which are used Configure the http server installed on your server.

I installed CentOS on ECS, installed nginx through yum:

yum install nginx
Copy after login

Then uploaded the server certificate to the server, and then configured the nginx.conf file (change the configuration file in /etc/ nginx directory) to support https url access:

    server {
        listen       443 ssl http2 default_server;
        listen       [::]:443 ssl http2 default_server;
        server_name  _;

        root         /usr/share/nginx/html;

        ssl on;
        ssl_certificate "xxxxxx.pem";  #你的证书文件中的pem文件
        ssl_certificate_key "xxxxxx.key"; #你的证书文件中的key文件
        ssl_session_timeout  5m;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers AESGCM:ALL:!DH:!EXPORT:!RC4:+HIGH:!MEDIUM:!LOW:!aNULL:!eNULL;
        ssl_prefer_server_ciphers on;

        include /etc/nginx/default.d/*.conf;

        location / {
        }
    }
Copy after login

In this way, your http server is configured. Then, in Alibaba Cloud's domain name resolution console, add an A resolution record for your domain name, point your domain name to the public IP address of your ECS server, and that's it.

Then, you can use the URL starting with https to access your http service! This is just a simple start, there are many server-side development and configuration things waiting for you!

If you have any questions during the configuration process, you can communicate with me. Thank you everyone for reading this article. Don’t hesitate to teach me and correct me if I’m wrong~~

[Related recommendations]

1. WeChat applet complete source code download

2. WeChat Mini Program Game Demo Select Different Color Blocks

3. WeChat Mini Program Demo: Zhihu Daily

The above is the detailed content of Server instance tutorial for building small program development based on Alibaba Cloud. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template