May 27, 2021 Web Cloud Development and Web Hosting Learning Guide
Cloud development static hosting is the ability to host static websites provided by cloud development, and the distribution of static resources (HTML, CSS, JavaScript, fonts, etc.) is supported by Tencent Cloud Object Storage COS and Tencent Cloud CDN with multiple edge outlets
Discuz is widely used in China because of its powerful performance.
However, Discuz is a dynamic system that has the potential to be cracked and attacked because it allows the user to enter. For businesses, using Discuz means placing their websites at the gun of the enemy, so static publishing is imperative.
In addition, one benefit of staticization is that the load on the server is significantly reduced, which can reduce the cost of paying for the server for the enterprise.
Home, we need to build the server locally (I recommend PhpStudy here)
You can go to PhpStudy official website: https://www.xp.cn download and install, after the installation is successful, open and click to start
Then download the Discuz https://gitee.com/3dming/DiscuzL/attach_files the code cloud and unzim locally when you're done
Finally open PhpStudy, under the site option, create a site domain name of discuz.cn pointing to the file just unziped, note that the file path here can not contain Chinese, you can change the file name.
Remember to point the discuz.cn 127.0.0.1 in Hosts
After the successful creation, we open the discuz.cn browser and the domain name will display the installation page
Under the 3rd step install database page, we fill in the administrator password, and then go to the next step, the database account number and password default is root.
After the installation is successful, we can see the following page, and then we log into the account to enter the Management Center
After the management side log-in was successful, we started generating HTML pages for deployment to the cloud development environment
Click on HTML management below the portal to set up HTML generation
Once the setting is successful, we click on the Build Home option and then click the Build button. If you want to generate additional HTML, add and publish articles from under the channel column.
Show the home page generation is complete, this time you can click on the home page to visit, after success you can see the following image
Below using cloud development to deploy this home page, other pages need to generate HTML pages after deployment.
Visit Tencent Cloud Development Console, create a new "Billing Cloud Development Environment", remember the cloud development environment ID, we need to use cloud development website hosting services, currently only the metered environment to support static hosting.
Go to the site hosting control page and open a static website hosting service
When you see an interface like this, it's already open.
npm install -g @cloudbase/cli
tcb login
This time you will be reminded that you need to authorize on the web page and confirm the authorization on the pop-up page
After confirming the authorization, you will see the console output the appropriate command
Now start deploying the generated home HTML, open the terminal, and go to the upload directory
This we use the code tool to open the index .html the upload folder and delete the selected paragraph
Start the deployment by executing the following commands in the terminal, and remember to replace the EnvID here with the environment ID of your own environment
tcb hosting:deploy index.html -e EnvID
tcb hosting:deploy data data -e EnvID
tcb hosting:deploy static/image/common/logo.png static/image/common/logo.png -e EnvID
The above command is to deploy the folders used in our generated HTML pages
tcb hosting:detail -e envId
This time we open the browser to visit the static website domain name, you can see the following effect map
Here is only the deployment of the home page, other pages need to add channel columns, add articles after the generation of HTML, the specific operation can be seen in the official introduction.