zishu's blog

zishu's blog

一个热爱生活的博主。https://zishu.me

Typecho Blog Setup and Optimization Tutorial (Detailed)

1. Introduction#

This article starts with an introduction to Typecho, including server selection, domain registration, server system selection, Baota installation, environment configuration, Typecho installation, and important precautions to avoid pitfalls. It provides you with a complete, beginner-friendly setup process, so cherish it!

If you don't like the lengthy explanation at the beginning, feel free to skip ahead to the Baota installation.

Please refrain from negative comments, thank you!

If you need to buy a server, you can click the link to purchase a server at Tencent Cloud with discounts~. Why not save a few bucks?

2. Introduction to Typecho#

Typecho is developed based on PHP5 and supports various databases. It is a lightweight open-source blog program with a robust core, easy extensibility, user-friendly experience, and smooth operation.

Typecho is very simple, with only 7 data tables and less than 400KB of code, achieving a complete plugin and template mechanism. Its ultra-low CPU and memory usage rates are sufficient to maximize the performance of the host.

It natively supports Markdown syntax, making it easy to read and write. It supports various cloud hosts like BAE/GAE/SAE, easily handling sudden high traffic.

The default template and backend of Typecho are all designed responsively. Therefore, most of Typecho's custom templates also adopt adaptive design.

Now Typecho has many users, a complete ecosystem, various functional plugins, and simple yet beautiful themes, making it the best choice for blogging. I believe you will love its simplicity!

3. Preparation#

Server + Domain

Setting up a Typecho blog requires a server or virtual machine. Recently, I also saw an article about setting up Typecho using Vercel + MySQL, but this method uses an external MySQL service, which is less convenient for configuration and management compared to using a server or virtual machine. Using a server is generally more user-friendly than a virtual machine.

Note: This article only explains the server setup process; please refer to other resources for virtual machines!

Server Selection: It is recommended to go with Tencent Cloud or Alibaba Cloud, which offer student machines (9 yuan/month). Tencent Cloud does not require student verification for those under 25, and the student price can be renewed three times. If conditions allow, consider purchasing for one year and renewing. Tencent also offers free upgrades, while Alibaba Cloud's student machines have been taken down, but you can still purchase those offered to new users. It is advisable to choose Lightweight Application Server; a 1h2g configuration is completely sufficient, and the traffic is also adequate.

Tencent Cloud: https://cloud.tencent.com/act/campus

image

Alibaba Cloud: https://developer.aliyun.com/plan/grow-up

image

If you can't buy this type, you can also look for servers with new user discounts from other service providers, preferably from large companies.

When choosing a server, consider the region. If it's a server in mainland China, you need to go through the corresponding service provider for domain filing; otherwise, you won't be able to use it. If it's a server in Hong Kong or abroad, no filing is required.

Note: Both Alibaba and Tencent's lightweight application servers require filing. If you find it troublesome or don't want to file, you can choose servers from other regions!

The filing process can be somewhat complicated and may take several days, but there are benefits to filing, such as using domestic CDN acceleration. Please carefully refer to the processes provided by each service provider and pay attention to the notes in the filing process to prevent rejections that waste time.

Compared to foreign and Hong Kong servers, using mainland servers offers the best access speed in China. Of course, if you're doing foreign business, just ignore this...

Domain Selection: Choosing a domain is very simple; just register one with any major service provider. Choose whatever you like, but if you need to file for a mainland server, make sure not to register a domain that does not support filing. Most domains do support filing. Major service providers also have promotional activities for new users registering domains, so just search carefully on Baidu.
Tencent Cloud: https://cloud.tencent.com/act/domainsales

image

Alibaba Cloud: https://wanwang.aliyun.com/domain

image

Huawei Cloud: https://activity.huaweicloud.com/domain1.html

image

Now let's start the setup process:

4. LNMP Environment#

The first thing we need to set up is the LNMP environment, which stands for: Linux system with Nginx + MySQL + PHP as the web server architecture.

Linux is a term that refers to a class of Unix computer operating systems and is currently the most popular free operating system. Representative versions include: debian, centos, ubuntu, fedora, gentoo, etc.

Nginx is a high-performance HTTP and reverse proxy web server that also provides IMAP/POP3/SMTP services.

MySQL is a secure, cross-platform, efficient database system that closely integrates with mainstream programming languages like PHP and Java.

PHP is a scripting language that executes on the server side and is embedded in HTML documents.

Of course, if you prefer not to use Nginx or MySQL, feel free to replace them with others; I won't elaborate further here!

For the Linux system, this article uses CentOS 8 for explanation.

To set up the LNMP environment, we can choose to download the corresponding installation packages and then install Nginx, MySQL, PHP, etc., in the CentOS system. This hands-on approach can be very tedious and complex, especially when managing multiple websites and configuring HTTPS certificates, as well as website pseudo-static configurations.

Therefore, this article explains how to use the Baota panel for environment installation and deployment!

5. What is Baota#

Baota Panel is a server management software that supports both Windows and Linux systems, allowing easy management of servers through a web interface, improving operational efficiency. For example: creating and managing websites, FTP, databases, with a visual file manager, visual software manager, visual CPU, memory, and traffic monitoring charts, scheduled tasks, and more.

Baota Panel offers fast and convenient one-click configuration and management, allowing one-click configuration of server environments (LAMP/LNMP/Tomcat/Node.js), one-click deployment of SSL, off-site backups; provides SSH to start and stop services, change SSH ports, disable ping, open firewall ports, and view operation logs; monitors CPU, memory, disk IO, and network IO data, allowing you to set record retention days and view data for any day;

Scheduled tasks can be added for execution periodically, supporting SHELL scripts, providing website and database backups, as well as log rotation, and supporting one-click backups to Youpai Cloud storage or other cloud storage; you can easily manage the server software used for installation through the web interface, along with practical extension plugins; it integrates a convenient and efficient file manager that supports uploading, downloading, packaging, decompressing, and file editing/viewing.

Now, let's get into the setup:

6. Installing Baota#

When selecting a server, choose the system image; do not select the application image provided by the service provider. Choose CentOS as the operating system, and either version 7 or 8 is fine. Of course, you can also choose other systems...

Next, go to the service provider's console, find your server, enter the console, and reset the password.

Then, go to Security -> Firewall and add a rule.

Port range 8888, other defaults, remarks can be anything.

Note: If you do not add 8888, you will not be able to access it after installing Baota. After installing Baota, you can modify the access port for Baota, and then change it here.

Use an SSH tool to connect to your server; if you don't have an SSH tool, you can also use the remote connection provided in the console!

In the terminal, enter the following command to start the installation!

CentOS installation command:

yum install -y wget && wget -O install.sh http://download.bt.cn/install/install_6.0.sh && sh install.sh

image

Different operating systems have different installation commands; for details, please visit the Baota official website!

When prompted during installation, simply enter: y

After installation, it will look like this:

image

Access the external panel address in your browser.

Note: If you did not add port 8888 in the server console's security firewall, you will not be able to access it.

Log in to the Baota panel using the username and password, and click "I have read and agree to the 'User Agreement'" to enter the Baota panel!

After entering the Baota panel, a one-click installation environment suite selection interface will pop up. At this point, we choose the LNMP environment on the left!

image

Nginx 1.18, MySQL 5.6 (if the server has more than 2GB of memory, you can choose 5.7), PHP 7.4 (it is recommended to choose PHP version 7.0 or higher), Pure-Ftpd 1.0.49, phpMyAdmin 5.0 (this is a software program that allows database management through a browser; you need to add port 888 in the server console's security firewall, or it won't open)

There are two installation methods: quick installation (fast installation speed, saves time) and compiled installation (super slow installation speed, sometimes may hang, but improves server performance). You can choose as you like. This article will use quick installation as an example!

Installation process:

image

After installation, you will be prompted to bind your Baota account. Click to register for free, then bind it!

Note: It is recommended that after installation, go to the left side, panel settings, and set the login information for the panel, modifying the login entry, username, password, and port.
Note: If you modify the port in the panel settings, you must also change the port in the server console's security firewall.

image

7. Installing Typecho#

Visit the official website of Typecho, click "Download Now," and download version 1.1.

After downloading, you will get a 1.1-17.10.30-release.tar.gz compressed package. After extracting, you will find a build folder inside, which contains the Typecho program files.

image

First, resolve the domain by going to your domain service provider, finding your domain in the console, and adding a record. For the host record, fill in @, and you can use www or blog or anything else (whatever you fill in is what you will use to access it, for example, if you fill in www, it will be www.xxx.com, etc.), record type A, and record value should be your server's IP address (if you don't know, you can check the upper left corner of the Baota page). Confirm it!

Open the Baota page, go to the left side -> Website -> Add Site.

Add the domain, select MySQL utf-8 for the database, fill in the database username and password, and the corresponding PHP version, then submit.

image

Here you can set up the site. Click the settings on the right side of the site, and you need to set pseudo-static, SSL certificate, etc.

For pseudo-static, select Typecho, then save.

image

For the SSL certificate, choose Baota SSL certificate, apply for the certificate, fill in the relevant information, and submit the materials. Once approved, you're good to go.

image

image

If the application fails, you can go to the domain service provider, which offers free SSL certificates for single domains, then choose other certificates, upload the certificate, and enable the "Force HTTPs" option in the upper right corner.

Close the settings window, click on the path address /www/wwwroot/your domain under the root directory, and directly enter the root directory folder to delete the index.html file.

image

Click upload, a pop-up window will appear, click "Upload Files," find the downloaded Typecho compressed package, open it, and start uploading. Once uploaded, close the window.

image

image

After extracting the compressed package (delete the compressed package), you will get the build folder. Enter that folder, select all files next to the file names, choose "Cut" in the upper right corner, then go back to the previous root directory, paste, and delete the unnecessary build folder.

image

image

At this point, enter your domain in the browser, and you can install Typecho.

If you encounter the error Deprecated: Function get_magic_quotes_gpc() is deprecated in /www/wwwroot/woshishabi.top/var/Typecho/Common.php on line 208, don't worry; it doesn't have any impact.

image

Click "Next" to enter the initialization configuration. Here, you need to fill in the database username (the database account set when adding the site), database password, database name (the database name is the same as the database username!), username, login password, email address, confirm, and start installation.

image

If all goes well, the installation will be successful!

image

Now, visit your domain in the browser, and you can view your Typecho blog. Of course, it is currently using the default theme, which is quite ugly.

Search for a theme you like on Baidu, download it, and upload it to the root directory /usr/themes/. You can change it in the backend appearance settings. Each theme has its own documentation and configuration tutorials.

image

To install plugins, upload the downloaded plugins to the root directory /usr/plugin/, enable the plugins in the backend settings, and configure them.

image

Your backend panel address will be your domain/admin, and you can log in with the username and password you set!

The basic installation ends here; now let's discuss some optimization issues!

8. Optimization#

Permalinks: Rewrite the addresses for articles and pages to remove index.php from the address bar, which is also SEO-friendly.

Enable the rewrite function, choose the article path, select your preferred style, or customize the style. There are optional parameters below; our site uses a personalized definition of /{cid}.html. Then save the settings, and you may see (Rewrite function detection failed, please check your server settings. If you still want to enable this function, please check here). Check here, and click save settings again to proceed.

image

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.