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 precautions to avoid pitfalls, providing you with a complete step-by-step setup process. Please cherish it!
If you don't like the lengthy explanation at the beginning, feel free to skip ahead to the Baota installation.
No offense, thank you!
If you need to buy a server, you can click the link to purchase a server on 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 kernel, 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 allow it 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 spikes in 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 an excellent 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 student prices can be renewed three times. If conditions allow, consider purchasing for one year and renewing. Tencent also offers free configuration upgrades. Alibaba Cloud's student machines have been taken down, but you can still buy those offered to new users. It is advisable to choose Lightweight Application Server, with a 1h2g configuration being more than sufficient, and the traffic is also adequate.
Tencent Cloud: https://cloud.tencent.com/act/campus
Alibaba Cloud: https://developer.aliyun.com/plan/grow-up
If you can't buy these, you can also look for servers with new user discounts from other service providers, preferably from reputable 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, filing is not 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 complex and take several days, but it has its benefits, 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.
Using mainland servers offers the best access speed in China compared to foreign and Hong Kong servers. Of course, if you're dealing with foreign business, just ignore this...
Domain Selection: Choosing a domain is straightforward; just register one with any major service provider. Pick whatever you like, but if you plan to file using 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
Alibaba Cloud: https://wanwang.aliyun.com/domain
Huawei Cloud: https://activity.huaweicloud.com/domain1.html
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 general term for 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, which 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, embedding HTML documents.
Of course, if you prefer not to use Nginx or MySQL, feel free to replace them with others; I won't go into detail 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 method can be very cumbersome 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 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, enhancing operational efficiency. For example: creating and managing websites, FTP, databases, with a visual file manager, visual software manager, visual CPU, memory, 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, offsite backups; provides SSH service start/stop, SSH port changes, ping disabling, firewall port release, and operation log viewing; CPU, memory, disk IO, network IO data monitoring, with settings for record retention days and the ability to view data for any specific day;
Scheduled tasks can be added for execution periodically, supporting SHELL scripts, providing website, database backups, and log cutting, and supporting one-click backups to Youpai Cloud storage or other cloud storage; through the web interface, you can easily manage the server software used for installation, along with practical extension plugins; it integrates a convenient and efficient file manager, supporting upload, download, packaging, decompression, 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 choose other systems as well...
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 settings default, remarks can be arbitrary.
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 of 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
Different operating systems have different installation commands; please refer to the Baota official website for details!
When prompted during installation, simply enter: y
After installation, it will look like this:
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 open it.
Log in to the Baota panel using the username and password, 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. Here, we choose the LNMP environment on the left!
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 above), Pure-Ftpd 1.0.49, phpMyAdmin 5.0 (this is a software program that allows database management through a browser interface; you need to add port 888 in the server console's security firewall, otherwise it cannot be opened)
There are two installation methods: quick installation (fast installation speed, saves time) and compiled installation (super slow installation speed, may sometimes hang, but improves server performance); you can choose as you wish. This article will use quick installation as an example!
Installation process:
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, on the left side, in panel settings, 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.
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 unzipping, you will see a build folder inside, which contains the Typecho program files.
First, resolve the domain name. Go to your domain service provider, find your domain in the console, resolve it, and add 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, on the left side -> Websites -> Add Site.
Add the domain name, select MySQL utf-8 for the database, fill in the database username and password, and the corresponding PHP version, then submit.
Here you can set up the site. Click the settings on the right side of the site; you need to set up pseudo-static, SSL certificate, etc.
For pseudo-static, select Typecho, then save.
For the SSL certificate, select Baota SSL certificate, apply for the certificate, fill in the relevant information, submit the materials, and once the application is successful, you're good to go.
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 under Root Directory /www/wwwroot/your domain, directly enter the root directory folder, and delete the index.html file.
Click upload, a pop-up window will appear, click "Upload Files," find the downloaded Typecho compressed package, open it, and start uploading. After uploading, close the window.
After unzipping the 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 return to the previous root directory, paste, and delete the unnecessary build folder.
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 affect anything.
Click next to enter the initialization configuration. In this step, you need to fill in the modified database username (the database account set when adding the site, if forgotten, you can check it on the left side of the Baota panel under databases), database password, database name (the database name is the same as the database username!), username, login password, email address, confirm, and start installation.
If all goes well, the installation will be successful!
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 Baidu for a theme you like, download it, and upload it to the root directory /usr/themes/. You can change it in the backend appearance settings. Each theme has documentation for tutorials and configurations.
To install plugins, upload the downloaded plugins to the root directory /usr/plugin/, enable the plugins in the backend settings, and configure them.
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, and now let's discuss some optimization issues!
8. Optimization#
Permalinks: Rewrite the addresses of 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; this 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.