WordPress is a blogging platform developed by using PHP. It can be deployed on an ECS instance that supports PHP and MySQL databases to create your own website or function as a content management system.
Software versions
- Operating system: In the example provided in this topic, CentOS 7.6 is used. You can also use CentOS 7.9, veLinux 1.0 (CentOS compatible version), or other CentOS 7 series images.
- WordPress: In the example provided in this topic, WordPress 5.8.1 is used.
Prerequisites
Step 1: Configure a database for WordPress
- Execute the following command to access the MySQL/MariaDB database as the root user. The password of the root user is the one you specified during the configuration of MySQL/MariaDB.
- Execute the following command to create a database for the WordPress blogging platform.
create database database_name;
- Create a user for the database created for WordPress.
create user 'username'@'localhost' identified by 'Password';
- Grant all permissions to the user.
grant all privileges on database name.* to 'Username'@'localhost';
- Execute the following command to make the preceding commands take effect.
- Execute the following command to exit the MySQL/MariaDB database.
Step 2: Set up a WordPress website
- Execute the following command to download WordPress to the website root directory of Nginx. Visit the official WordPress website to obtain the download path.
wget https://cn.wordpress.org/wordpress-5.8.1-zh_CN.tar.gz
tip
Replace /var/www/html with the website root directory you specified when you set up LNMP or LAMP.
- Execute the following command to decompress the installation package.
tar -vzxf wordpress-5.8.1-zh_CN.tar.gz
- Modify the WordPress configuration file.
- Back up the configuration file in the configuration file directory.
cp wp-config-sample.php wp-config.php
- Execute the following command to modify the configuration file.
- Press the i key to enter edit mode and modify the following content in the MySQL section.
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'WordPress_database_name');
/** MySQL database username */
define('DB_USER', 'MySQL_name');
/** MySQL database password */
define('DB_PASSWORD', 'MySQL_password');
define('DB_HOST', 'localhost');
- Press Esc, enter :wq, and then press Enter to save the modifications and close the file.
Step 3: Log in to the WordPress website
- Enter http://<ECS instance EIP>/wordpress in your local browser to access the WordPress website.
- If the following output is displayed, WordPress is set up successfully.
- Enter the basic information of the website, and then click the "Install WordPress" button.
- Click the "Log in" button.
- Enter your username and password to log in to the WordPress website.
- The following output is displayed.
Step 4 (Optional): Resolve the WordPress domain name
You can configure a domain name for your website, eliminating the need to use a complex, less secure EIP to access it. You can perform the following steps to specify a domain name for the website.
- Apply for an ICP filing for your domain name.
- If your domain name points to a server located in the Chinese mainland, you need to apply for an ICP filing for your domain name. Otherwise, the website is not accessible.
- Configure domain name resolution.
- You need to resolve your domain name to the EIP to access your website.
- After you complete the preceding steps, you can enter http://<domain name> in your local browser to access the WordPress website.
Step 5 (Optional): Enable HTTPS for the website
When a user accesses your website over the HTTP protocol, the browser warns the user that the connection is not secure. We recommend that you enable HTTPS secure communication for your website. This ensures encrypted data transmission between users and your website, effectively defending against network hijacking, information leakage, and other threats.