
第一步:申請伺服器與域名
申請伺服器:一般公司都會有自己的伺服器,但是如果你是自己私下學習或者開發的話,當然有自己的伺服器才是最好的。
1.雲伺服器:可以直接在阿里雲或者其他網站購買,這種伺服器一般都比較貴,但是靈活性和效能比較好,你可以根據自己的情況選擇性購買。


註冊域名:可以在阿里雲註冊域名,選什麼樣子的就看你自己的喜好了,域名註冊之後順便實名認證一下

第二步:申請HTTPS 證照
從阿里雲「產品與服務」裡面,找到「CA 證照服務」 購買免費的證照



第三步:配置伺服器
雲伺服器:
雲伺服器配置就相對比較麻煩了,安裝環境,繫結域名等等,在這裡就不一一細說了,如果不會可以另行百度,這裡預設的你的伺服器已經搭建好。(之後我會再寫一篇相關的雲服務環境搭建的文章)


( 1 ) 在Apache的安裝目錄下建立cert目錄,並且將下載的全部檔案拷貝到cert目錄中。如果申請證照時是自己建立的CSR檔案,請將對應的私鑰檔案放到cert目錄下並且命名為214497416760958.key; ( 2 ) 開啟 apache 安裝目錄下 conf 目錄中的 httpd.conf 檔案,找到以下內容並去掉“#”: LoadModule ssl_module modules/mod_ssl.so (如果找不到請確認是否編譯過 openssl 外掛) Include conf/extra/httpd-ssl.conf ( 3 ) 開啟 apache 安裝目錄下 conf/extra/httpd-ssl.conf 檔案 (也可能是conf.d/ssl.conf,與作業系統及安裝方式有關), 在配置檔案中查詢以下配置語句: 新增 SSL 協議支援協議,去掉不安全的協議 SSLProtocol all -SSLv2 -SSLv3 修改加密套件如下 SSLCipherSuite HIGH:!RC4:!MD5:!aNULL:!eNULL:!NULL:!DH:!EDH:!EXP:+MEDIUM SSLHonorCipherOrder on 證照公鑰配置 SSLCertificateFile cert/public.pem 證照私鑰配置 SSLCertificateKeyFile cert/214497416760958.key 證照鏈配置,如果該屬性開頭有 '#'字元,請刪除掉 SSLCertificateChainFile cert/chain.pem ( 4 ) 重啟 Apache。
雲虛擬主機:
1.點選進入主機列表,上面會有你未完成的事項按照要求處理,點選左側[域名管理]-[域名繫結],繫結你剛才註冊的域名。










這裡新增DNS解析的時候可能會出現衝突,一般來說如果你之前系統生成的有你可以直接讓A解析修改成CNAME解析,兩個是不能並存的,出現衝突的話可以參考下圖,排除衝突

第四步:上傳檔案
配置好伺服器和HTTPS證照之後就要上傳網頁和介面檔案才能訪問和請求介面



1.虛擬主機對應的檔案的位置(index為預設顯示頁,data.php為介面)

然後在主機管理控制檯選擇預設首頁設定就可以了訪問了。 (未備案前可用臨時域名訪問)

2.雲主機 上傳對應的域名配置目錄下

第五步:域名備案
點選備案 —— 進入備案系統(備案之前請確保以上步驟都完成,訪問域名(或臨時域名)能開啟你上傳的網址)


這裡要注意的是備案的網站名稱不要寫部落格,主頁這些的,貌似容易不過,我之前就寫的雨塵部落格,然後阿里的客服打電話給我說最好換下容易被拒,然後我化成了雨塵技術分享。過了的!還有就是《網站備案承諾書》裡面的地址要填寫現在所在的省份,不是原籍!備案資訊提交之後阿里的小哥會先初審,有什麼不合適的地方他會打電話給你讓你處理,初審之後就提交給對應的省份政府審了。具體稽核時間不定(我的是一個月)
第六步:小程式設定
等備案通過之後就可以到微信公眾平臺設定小程式的伺服器域名


然後就可以去小程式請求啦!


至此大工告成了!有什麼問題可以留言,唉唉,別走啊,給我點贊啊!