×
Community Blog Hands-on Labs | Build a Cloud-Based Blog on CentOS 7

Hands-on Labs | Build a Cloud-Based Blog on CentOS 7

This step-by-step tutorial introduces how to build a cloud-based blog on CentOS 7.

>> Get hands-on experience with this tutorial in a lab environment.

1. Configure Resources

This section is for reference. If you have already configured your resources, please skip this section and move to the next.

1.  On the basic configuration page, configure the ECS basic configuration according to the following instructions. The configuration that is not mentioned remains the default option, and then click Next: Network and security group.

1

Note: the following configurations are used in this experiment. The configurations not mentioned remain the default options.

Configuration description:

2

Configuration item Example Explain
Region and zone Region: Singapore
Zone: Singapore Zone B
After an instance is created, you cannot directly change the region and zone.
Instance type Type family:ecs.t5-c1m1.large (Standard) You can go to the ECS instance purchase region to view the instance purchase status in each region.
Image Type: Public image
Version: CentOS 7.9 64 bit
After the instance is started, the system disk will completely copy the operating system and application data of the image.

2.  On the network and security groups page, configure the ECS network and security group according to the following instructions. The configuration that is not mentioned remains the default option, and then click Next: Network and security group.

Configuration description:

Configuration item Example Explain
VPC Default VPC Select your VPC. To create a VPC, click create in the console.
VSwitch Default vSwitch Select your vSwitch. To create a vSwitch, click create in the console.
Assign public IPv4 addresses Select assign public IPv4 address When selected, a public IPv4 address is automatically assigned.
Bandwidth billing mode Pay-by-traffic You only need to pay for the Internet traffic consumed by using the traffic mode. For more information, see Internet bandwidth billing.
Peak bandwidth 5 Mbps None.
Security Group Default security group Select your security group. You must enable ports 80, 443, 22, 3389, and 3306. To create a security group, click Create Security Group.

3.  On the System configuration page, configure the ECS system configuration according to the following instructions. The configuration that is not mentioned remains the default option, and then click Next: Group settings.

Configuration description:

Configuration item Example Explain
login credentials Custom password In this tutorial, select a custom password and manually set a password for remote connection and sign in to the ECS instance.
Sign-in password Ecs123456 When you select a custom password for the Sign-in credential, you must set this option and confirm the password. When you connect to the ECS instance later, you must enter the username root and the password set here.
Instance name EcsQuickStart You can customize the instance name.

4.  On the Group settings page, all configurations remain the default option, confirm the order, and Create an instance.

2. Deploy Application Environment

Please click on the right side ICON button to switch to the Web Terminal operation interface.

1.  On the ECS server, run the following command to install the Apache service and its extension package.

yum -y install httpd httpd-manual mod_ssl mod_perl mod_auth_mysql

If the result is similar to the following figure, the installation is successful.

3

2.  Run the following command to start the Apache service.

systemctl start httpd.service

3.  Return to the ECS console. On the ECS instances page, click the ID of the created ECS instance to go to the ECS details page.

4.  In the left-side navigation pane, click the instance security group, and then click the security group ID link to view the security group configuration.

Make sure that port 80 is enabled for the security group. Otherwise, you cannot access the established personal website. A security group is a virtual firewall that can detect status and filter data packets. It is used to divide security domains in the cloud. By configuring security group rules, you can control the inbound and outbound traffic of one or more ECS instances in a security group.

4

5.  Open the browser and enter the public IP of the ECS server. If the test page shown in the figure below is displayed, the Apache service is installed successfully.

5

6.  Follow these steps to build a MySQL database on the ECS server.

a) Run the following command to download and install MySQL.

Note: The download process may take up to 10 minutes if the network speed is slow.

wget http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql-community-server --nogpgcheck

6

b) Run the following command to start the MySQL database.

systemctl start mysqld.service

c) Run the following command to view the running status of MySQL.

systemctl status mysqld.service

7

d) Run the following command to view the initial MySQL password.

grep "password" /var/log/mysqld.log

8

e) Run the following command to sign in to the database.

mysql -uroot -p

f) Run the following command to modify the MySQL default topassword.really

Note: the new password must contain both uppercase and lowercase lettters, digits, and special characters. Keep the database password properly. We recommend that you use the default password NewPassWord1.

ALTER USER 'root'@'localhost' IDENTIFIED BY 'NewPassWord1.';

g) Run the following command to create a database that stores blog website content.

create database wordpress; 

h) Run the following command to check whether the creation is successful.

show databases;

I) Enter exit to exit the database.

9

7.  WordPress is a blog platform developed in PHP. Follow these steps to install PHP.

a) Run the following command to install PHP.

yum -y install php php-mysql gd php-gd gd-devel php-xml php-common php-mbstring php-ldap php-pear php-xmlrpc php-imap

b) Run the following command to create a PHP test page.

echo "<?php phpinfo(); ?>" > /var/www/html/phpinfo.php

c) Run the following command to restart the Apache service.

systemctl restart httpd

d) Open the browser and visit http://<ECS public IP>/phpinfo.php. The following page is displayed to indicate that PHP has been installed successfully.

10

3. Install and Set up WordPress

After setting up the preceding environment, follow these steps to install the WordPress.

1.  Run the following command to install the WordPress.

yum -y install wordpress

The following information indicates that the installation is successful.

11

2.  Modify WordPress configuration file.

a) Run the following command to change the wp-config.php path to absolute path.

# Enter/usr/share/wordpress catalog。
cd /usr/share/wordpress
# modify path.
ln -snf /etc/wordpress/wp-config.php wp-config.php
# View the modified directory structure.
ll

b) Run the following command to move the WordPress to the Apache root directory.

# Create a wp-blog folder under Apache's root directory /var/www/html.
mkdir /var/www/html/wp-blog
mv * /var/www/html/wp-blog/

c) Run the following command to modify wp-config.php configuration file.

Replace the following three parameter values before executing the command.

database_name_here is the name of the database created in the previous step. In this example, wordpress.

username_here is the username of the MySQL database. In this example, the username is root.

password_here is the sign-in password for the MySQL database. In this example, NewPassWord1..

sed -i 's/database_name_here/wordpress/' /var/www/html/wp-blog/wp-config.php
sed -i 's/username_here/root/' /var/www/html/wp-blog/wp-config.php
sed -i 's/password_here/NewPassWord1./' /var/www/html/wp-blog/wp-config.php

d) Run the following command to check whether the configuration file information has been modified.

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

12

3.  Run the following command to restart the Apache service.

systemctl restart httpd

4. Publish the Blog

After installing the WordPress, follow these steps to create a personal site and publish the content.

1.  Open the browser and access http://<ECS public IP>/wp-blog/wp-admin/install.php.

You can view the public IP address of the ECS instance on the ECS instance list page.

2.  Set your site name, administrator username, and password, and then click Install WordPress to initialize the WordPress.

13

3.  Click Log In, enter the username and password, and then click Log In again to open the WordPress site.

14

4.  After writing your first blog, click [publish] to publish.

15

5.  In the left-side navigation pane, click All Posts to view the published Posts.

16


>> Get hands-on experience with this tutorial in a lab environment.

0 1 0
Share on

Alibaba Cloud Community

1,072 posts | 263 followers

You may also like

Comments

Alibaba Cloud Community

1,072 posts | 263 followers

Related Products