Manually Build WordPress Website

Last updated: 2020-03-26 11:20:33

PDF

Scenario

WordPress is a blog platform developed in PHP language. You can use WordPress to build your own blog platform. This article takes the Tencent Cloud server of CentOS 7.6 operating system as an example to build a WordPress personal site manually.

To manually build an LNMP environment, you need to be familiar with Linux commands (see Installing software via YUM in CentOS environment For some examples), usage and version compatibility of the software to be installed.

Software Versions

The composition and description of the WordPress personal site built in this article are as follows:

  • Linux: Linux operating system. In this example, CentOS 7.6 is used.
  • Nginx: Web server. In this example, Nginx 1.17.5 is used.
  • MariaDB: Database. In this example, MariaDB 10.4.8 is used.
  • PHP: Scripting language. In this example, PHP 7.2.22 is used.
  • WordPress: blog platform, this article takes WordPress 5.0.4 as an example.

Directions

Step 2: Purchase cloud virtual machine

Step 2: manually build the LNMP environment

LNMP is an acronym for Linux, Nginx, MariaDB, and PHP, and this combination is one of the most common environments in which Web servers run. After creating and logging in to Cloud Virtual Machine instance, you can refer to Manually build LNMP environment Complete the construction of the basic environment.

Step 3: configure the WordPress database

There are some differences in how to set user authentication according to the MariaDB version. For more information, please see the MariaDB official website.

  1. Run the following command to install MariaDB.
mysql
  1. Execute the following command to create the MariaDB database. For example, "wordpress".
CREATE DATABASE wordpress;
  1. Execute the following command to create a new user. For example, "user", the login password is 123456 .
CREATE USER 'user'@'localhost' IDENTIFIED BY '123456';
  1. Execute the following command to give the user all Permission on the "wordpress" database.
GRANT ALL PRIVILEGES ON wordpress.* TO 'user'@'localhost' IDENTIFIED BY '123456';
  1. Execute the following command to make all configurations effective.
flush privileges;
  1. Run the following command to exit MariaDB.
\q

Step 4: configure the root account

  1. Run the following command to install MariaDB.
mysql
  1. Execute the following command to set the root account password.

MariaDB 10.4 has added the root account secret-free login feature on the CentOS system, please perform the following steps to set your root account password and keep in mind.

ALTER USER root@localhost IDENTIFIED VIA mysql_native_password USING PASSWORD('Enter your password');
  1. Run the following command to exit MariaDB.
\q

Step 3: Install and configure WordPress

Download WordPress

WordPress can download and install the latest Chinese version of WordPress from the official website of WordPress. This tutorial is based on the Chinese version of WordPress.

  1. Delete the command used to test PHP-Nginx configuration under Directory, the root of the website, by executing the following command index.php File.
vim /usr/share/nginx/html/index.php
  1. Execute the following command in turn to enter the /usr/share/nginx/html/ Directory, and download and decompress WordPress.
root   /usr/share/nginx/html;
//cn.wordpress.org/wordpress-4.7.4-zh_CN.tar.gz
tar zxvf wordpress-5.0.4-zh_CN.tar.gz

Modify WordPress configuration file

  1. Execute the following command in turn, enter WordPress to install Directory, and set wp-config-sample.php Copy files to wp-config.php File and keep the previous sample configuration file as a backup.
cd /usr/share/nginx/html/wordpress
cp wp-config-sample.php wp-config.php
  1. Execute the following command to open and edit the newly created configuration file.
vim wp-config.php
  1. Press " I "switch to edit mode, locate the MySQL section of the file, and modify the relevant configuration information to Configure the WordPress database The contents of the.
     ** MySQL settings - You can get this info from your web host **
     The name of the database for WordPress 
    define('DB_NAME', 'wordpress');

     MySQL database username 
    define('DB_USER', 'user');

     MySQL database password 
    define('DB_PASSWORD', '123456');

     MySQL hostname 
    define('DB_HOST', 'localhost');
  1. After modifying the address, press Esc And enter : wq To save the file and go back.

Step 6: verify the WordPress installation

  1. Enter the public network IP of the CVM instance plus the wordpress folder in the browser address bar, for example:
http://192.xxx.xxx.xx /wordpress

Go to the WordPress installation page and start configuring WordPress.

  1. Follow the prompts of the WordPress installation wizard to enter the following installation information, and click [install WordPress] to complete the installation.
Required informationDESCRIPTION
Site titleLaunch a WordPress site
UserNameWordPress administrator name. For security reasons, it is recommended that you set a name that is different from admin. Because this name is more difficult to crack than the default user name admin.
PasswordYou can use a default strong password or a custom password. Do not reuse existing passwords and be sure to keep them in a secure location.
Your emailThe e-mail address used to receive notifications.
Now, you can log in to your WordPress blog website and publish blogs.

FAQ

If you encounter a problem when using CVM, refer to the following documents for troubleshooting as needed: