Use WordPress to build your own blog

Scene introduction

Use an ECS (cloud server) instance with CentOS as the basic environment, and the LAMP environment has been built into the server. Install WordPress on the server here to help you quickly build your own cloud blog.
Alibaba Cloud server resources free experience

background knowledge

This scenario mainly involves the following cloud products and services:

Cloud Server ECS
Cloud Server (Elastic Compute Service, ECS for short) is an IaaS (Infrastructure as a Service) level cloud computing service provided by Alibaba Cloud with outstanding performance, stability, reliability, and elastic expansion. The cloud server ECS eliminates the pre-preparation for purchasing IT hardware, allowing you to use the server as convenient and efficient as using public resources such as water, electricity, and natural gas, realizing out-of-the-box and elastic scaling of computing resources. Alibaba Cloud ECS continues to provide innovative servers to solve a variety of business needs and help your business development.

Wordpress
WordPress is a blog platform developed using PHP language. Users can set up their own websites on servers that support PHP and MySQL databases. You can also use WordPress as a content management system (CMS).

The final effect of this scenario is similar to the following:
Blog homepage
Insert picture description here
blog edit page
Insert picture description here

Step 1: Connect to the ECS server

For specific operations, see Alibaba Cloud Experience Lab connection steps

If you have not purchased and operated ECS, you can experience the Alibaba Cloud ECS server for free here.
Resource address:
https://developer.aliyun.com/adc/scenario/ae75736b49b940d1a78fee1453232d94

Step 2: Install the Chinese version of WordPress

1. Install WordPress.
a. Execute the following command to obtain the wordpress Chinese installation package.

wget https://cn.wordpress.org/latest-zh_CN.tar.gz

b. Execute the following command to decompress.

tar -zxvf latest-zh_CN.tar.gz

c. Execute the following command to move wordpress to the Apache root directory.

mkdir /var/www/html/wp-blog
mv wordpress/* /var/www/html/wp-blog/

2. Initialize wordpress.

a. Execute the following command to view the wp-config-sample.php file.

cat -n /var/www/html/wp-blog/wp-config-sample.php

Insert picture description here
b. As can be seen from the above figure, wordpress needs to be copied and configured manually.
Execute the following command, copy wp-config-sample.php to wp-config.php, and modify the database configuration.

cp wp-config-sample.php wp-config.php  
# database_name_here为数据库名称
sed -i 's/database_name_here/wordpress/' /var/www/html/wp-blog/wp-config.php
# username_here为数据库的用户名
sed -i 's/username_here/root/' /var/www/html/wp-blog/wp-config.php
# password_here为数据库的登录密码
sed -i 's/password_here/NewPassWord1./' /var/www/html/wp-blog/wp-config.php

3. Start the Apache server.

systemctl start httpd

4. The browser visit http://<ECS public network IP>/wp-blog/wp-admin/install.php to complete the wordpress initial configuration.

5. Visit http://<ECS public network IP>/wp-blog/wp-admin/index.php to log in to the WordPress management console.
Insert picture description here

Step 3: Customize the site theme

The powerful function of WordPress is largely due to its good extension and numerous themes and plug-in support.
WordPress can generally be installed through two installation methods.

  • Method 1: Search and install online
    a. Access the WordPress management console in the browser.
    b. Click Appearance>Themes in turn.
    Insert picture description here
    c. Click Add. Choose the theme you like to install.
  • Method 2: Upload the theme directly to the wordpress server.
    a. Visit https://cn.wordpress.org/themes/ in the browser to enter the WordPress theme list page.
    Insert picture description here
    b. Click function filtering.
    c. Check a column in the layout column, check accessibility and friendly in the feature column, check blog in the theme column, and then click Apply Filter.
    Insert picture description here
    d. Choose the theme you like. For example: Markiter.
    Insert picture description here
    e. Right-click the download, and then click Copy Link Address.
    Insert picture description here
    f. Connect to the ECS server.
    g. In the command line, execute the following command to download and install the theme.
# 首先进入WordPress主题目录
cd /var/www/html/wp-blog/wp-content/themes/
# 使用wget命令下载上一步选择的主题
wget https://downloads.wordpress.org/theme/markiter.1.5.zip
# 使用unzip命令解压安装包
unzip markiter.1.5.zip
# 查看所有主题
ll

The command execution result is similar to the following.
Insert picture description here
h. Return to the Wordpress management console, enter the theme page, you can see that the Markiter theme has been installed.
Insert picture description here
i. Click Enable to apply the theme.
Insert picture description here

Step 3: Add custom widgets

1. Connect to the ECS server.
2. Execute the following command to edit the footer file footer.php of the blog theme.

vim /var/www/html/wp-blog/wp-content/themes/markiter/footer.php

3. Add the following code before the file </body> tag.

<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/L2Dwidget.min.js"></script>
<script type="text/javascript">
    L2Dwidget.init();
</script>

4. The browser visit http://<ECS public network IP>/wp-blog/, enter the blog homepage to check the component effect.
Insert picture description here
5. At this point, the interface settings are all completed.

Step 4: Install the MarkDown plugin

The way WordPress installs plugins is similar to the way to install themes. Both are divided into online installation and offline installation. This step mainly introduces offline installation.
1. Connect to the ECS server.
2. Execute the following command to enter the wordpress plugin directory.

cd /var/www/html/wp-blog/wp-content/plugins/

3. Execute the following command to download the MarkDown plug-in.

wget https://downloads.wordpress.org/plugin/wp-editormd.10.1.2.zip

4. After the download is complete, execute the following command to decompress the installation package.

unzip wp-editormd.10.1.2.zip

5. Return to the WordPress management console, and then click Plugins>Installed Plugins
Insert picture description here
6. Click Enable to enable the MarkDown plugin.
Insert picture description here
The editor effect is as follows.
Insert picture description here
7. At this point, the MarkDown plug-in installation is complete. For more plug-ins, please visit https://cn.wordpress.org/plugins/ to view.

Guess you like

Origin blog.51cto.com/14981263/2544433