Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Cloud development Discuz static deployment


May 27, 2021 Web Cloud Development and Web Hosting Learning Guide


Table of contents


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

Why static publishing?

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.

Install test Discuz

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

Cloud development Discuz static deployment

Then download the Discuz https://gitee.com/3dming/DiscuzL/attach_files the code cloud and unzim locally when you're done

Cloud development Discuz static deployment

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.

Cloud development Discuz static deployment

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.

Cloud development Discuz static deployment

After the installation is successful, we can see the following page, and then we log into the account to enter the Management Center

Cloud development Discuz static deployment

After the management side log-in was successful, we started generating HTML pages for deployment to the cloud development environment

Cloud development Discuz static deployment

Click on HTML management below the portal to set up HTML generation

Cloud development Discuz static deployment

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.

Cloud development Discuz static deployment

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

Cloud development Discuz static deployment

Static deployment

Below using cloud development to deploy this home page, other pages need to generate HTML pages after deployment.

Deploy to cloud development static site hosting

Create a cloud development environment

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.

Cloud development Discuz static deployment

Go to the site hosting control page and open a static website hosting service

Cloud development Discuz static deployment

When you see an interface like this, it's already open.

Install cloud development CLI tools

npm install -g @cloudbase/cli

Log in

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

Cloud development Discuz static deployment

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

Cloud development Discuz static deployment

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

View static site domain names and statuses

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

Summarize

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.