Setting Up a WordPress Website (Linux)
Application Scenarios
WordPress (WP for short) is initially a blog system and gradually evolved to a free CMS or website setup system. The best practices for ECS guide you through the setup of LNMP on a Linux ECS running the CentOS 7.2 64bit OS and deploy WordPress on the website.
Architecture
Advantages
- A website with a simple networking architecture can be quickly set up.
- The website is secure and easy to use.
Resources and Costs
Resource |
Description |
Cost |
---|---|---|
VPC |
VPC CIDR block: 192.168.0.0/16 |
Free |
VPC subnet |
|
Free |
Security group |
Inbound rule:
|
Free |
ECS |
|
The following resources generate costs:
For billing details, see Billing Modes. |
Nginx |
A high-performance HTTP and reverse proxy server. Download URL: http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm |
Free |
MySQL |
An open-source relational database software Download URL: https://dev.mysql.com/get/mysql80-community-release-el7-11.noarch.rpm |
Free |
PHP |
An open-source software used for web development Download URL: https://mirrors.huaweicloud.com/remi/enterprise/remi-release-7.rpm |
Free |
WordPress |
An open-source blogging software. Download URL: |
Free |
Domain name |
Used to access the created website. |
The price of a domain name is subject to that provided by the domain name registrar. For details, see the help document of the domain name registrar. |
Process
Procedure
Preparations
- A VPC and an EIP are available.
- A domain name is available if you plan to configure a domain name for the website.
- The rule listed in Table 2 has been added to the security group which the target ECS belongs to. For details, see Configuring Security Group Rules.
- To obtain and update the system and software, you are advised to update the image source to a Huawei Cloud image source. For details, see How Can I Use an Automated Tool to Configure a Huawei Cloud Image Source (x86_64 and Arm)?
Procedure
- Log in to the ECS.
- Set up the LNMP environment. For details, see Manually Deploying LNMP (CentOS 7.2).
- Create a database.
- Run the following command and enter the root user password of MySQL as prompted to log in to the MySQL CLI:
mysql -u root -p
- Run the following command to create a database:
In the preceding command, wordpress is the database name, which can be customized.
- Run the following command to create a user:
CREATE USER 'user'@'localhost' IDENTIFIED BY 'xxxxx';
In the preceding command, user is the name of the database user, and xxxxx is the configurable user password.
- Run the following command to grant all permissions on the WordPress database to the user:
- Run the following command to make all configurations take effect:
- Run the following command to exit the MySQL CLI:
- (Optional) Run the following commands to verify the creation of the database and user and then exit the MySQL CLI:
SHOW DATABASES;
exit
In the preceding command, user is the created username for logging in to the database.
- Run the following command and enter the root user password of MySQL as prompted to log in to the MySQL CLI:
- Install WordPress.
- Run the following commands to go to the root directory of the Nginx website and download the WordPress package:
wget https://cn.wordpress.org/wordpress-6.6.1-zh_CN.tar.gz
- Run the following command to decompress the WordPress software package:
tar zxvf wordpress-6.6.1-zh_CN.tar.gz
After the decompression, the folder wordpress is obtained.
- Run the following commands to go to the WordPress installation directory, copy the wp-config-sample.php file to the wp-config.php file, and retain the original sample configuration file as a backup:
cd /usr/share/nginx/html/wordpress
cp wp-config-sample.php wp-config.php
- Run the following command to open and edit the created configuration file:
- Press i to enter insert mode. Find MySQL configurations in the file and modify them to information in 3.
Figure 2 Modifying MySQL configurations
- Press Esc to exit the editing mode. Then, enter :wq to save the settings and exit the file.
- Enter http://Server IP address/wordpress in the address bar of the browser to access the installation wizard.
- Set the site title, administrator username, password, and email address. Then, click Install WordPress.
Table 3 Configuration parameters Parameter
Description
Site title
Name of the WordPress website.
Username
Name of the WordPress administrator.
Password
Default or user-defined password.
Do not reuse an existing password and keep your password secure.
Email address
Email address for receiving notifications.
- Check that the installation is successful.
- Click Log In. Alternatively, enter http://Server IP address/wordpress/wp-login.php in the address bar of the browser, enter the username or email address and password, and click Log In.
- Run the following commands to go to the root directory of the Nginx website and download the WordPress package:
- Purchase a domain name.
Configure a unique domain name for website access. You need to obtain an authorized domain name from the domain name registrar first.
- Configure DNS records.
Your website can be visited using the registered domain name only after DNS records are configured. For details, see Routing Internet Traffic to a Website.
For example, if the domain name is www.example.com, enter http://www.example.com in the address bar of the browser to access the website.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot