×
Community Blog WordPress (Marketplace) on Alibaba Cloud

WordPress (Marketplace) on Alibaba Cloud

In this tutorial, we will reply on the Terraform to provision the cloud resources.

Quick start with WordPress on Alibaba Cloud. We use the WordPress image on Alibaba Cloud Marketplace.

We will reply on the Terraform to provision the cloud resources in this tutorial. If you are the 1st time to use Terraform, please refer to terraform templates to learn how to install and use the Terraform on different operating systems.

Project URL

https://github.com/alibabacloud-howto/solution-marketplace-wordpress

More tutorial around Alibaba Cloud Database, please refer to this link.

Index

  • Phase 0: "ALL-IN-ONE" for entry level deployment
  • Phase 1: WordPress ECS Server + Standalone RDS MySQL in Basic Edition
  • Phase 2-1: SLB + WordPress ECS Servers (Auto-scaling) + Cloud Native PolarDB MySQL
  • Phase 2-2: SLB + WordPress ECS Servers (Auto-scaling) + Multi-AZ Redis Cache + RDS MySQL in High Availability Edition
  • Phase 2-3: SLB + WordPress ECS Servers (Auto-scaling) + Multi-AZ Redis Cache + Cloud Native PolarDB MySQL

Phase 0: "ALL-IN-ONE" for entry level deployment

  • WordPress with web app server and MySQL database are all built within a single ECS instance.
  • This is for entry level deployment with low cost but without high availability feature for both web app and database.

1

Run the terraform script to initialize the resources. Within the terraform script, please use the right Image ID of WordPress image on the corresponding region.

2
3

After the Terraform script execution, open the following URL in a Web browser to initialize WordPress:

http://<ECS_EIP>

4

Note: Replace the <ECS_EIP> placeholder with the Elastic IP address of the ECS instance.

Phase 1: WordPress ECS Server + Standalone RDS MySQL in Basic Edition

  • Decouple the database from web app server.
  • More stable for both web app and database but still without high availability feature for both of them.

5

Run the terraform script to initialize the resources. Within the terraform script, please use the right Image ID of WordPress image on the corresponding region.

  • After the Terraform script execution, logon to ECS via SSH, use the account root/N1cetest, the password has been predefined in Terraform script for this tutorial. If you changed the password, please use the correct password accordingly.

6

ssh root@<EIP_ECS>

Edit the WordPress configuration file to set the RDS MySQL URL, database and account information.

vim /data/wwwroot/wordpress/wp-config.php

7

Open the following URL in a Web browser to initialize WordPress:

http://<ECS_EIP>

Note: Replace the <ECS_EIP> placeholder with the Elastic IP address of the ECS instance that you obtained previously.

Phase 2-1: SLB + WordPress ECS Servers (Auto-scaling) + Cloud Native PolarDB MySQL

  • Setup SLB and auto-scaling group for multiple ECS servers with WordPress web app.
  • Use cloud native database PolarDB with high availability and scalability.

8

Run the terraform script to initialize the resources. Within the terraform script, please use the right Image ID of WordPress image on the corresponding region.

  • After the Terraform script execution, logon to ECS via SSH, use the account root/N1cetest, the password has been predefined in Terraform script for this tutorial. If you changed the password, please use the correct password accordingly.

9

ssh root@<EIP_ECS>

Edit the WordPress configuration file to set the PolarDB MySQL URL, database and account information.

vim /data/wwwroot/wordpress/wp-config.php

10

Open the following URL in a Web browser to initialize WordPress:

http://<ECS_EIP>

Note: Replace the <ECS_EIP> placeholder with the Elastic IP address of the ECS instance that you obtained previously.

Auto-scaling configuration

After you have successfully configured and installed WordPress, you can follow the step 4 of following guide for auto-scaling configurations:

https://www.alibabacloud.com/blog/cloud-native-wordpress-on-alibaba-cloud_598043

Phase 2-2: SLB + WordPress ECS Servers (Auto-scaling) + Multi-AZ Redis Cache + RDS MySQL in High Availability Edition

  • Setup SLB and auto-scaling group for multiple ECS servers with WordPress web app.
  • Use RDS with cross availability zone feature for high availability.
  • Use Redis as data cache to improve web app performance. The cross availability zone feature also ensure the high availability.

11

Run the terraform script to initialize the resources. Within the terraform script, please use the right Image ID of WordPress image on the corresponding region.

After the Terraform script execution, logon to ECS via SSH, use the account root/N1cetest, the password has been predefined in Terraform script for this tutorial. If you changed the password, please use the correct password accordingly.

12

ssh root@<EIP_ECS>

Edit the WordPress configuration file to set the RDS MySQL URL, database and account information.

vim /data/wwwroot/wordpress/wp-config.php

13

Open the following URL in a Web browser to initialize WordPress:

http://<ECS_EIP>

Note: Replace the <ECS_EIP> placeholder with the Elastic IP address of the ECS instance that you obtained previously.

Configure Redis caching

Run the following commands in sequence to download the Redis object cache plugin and unzip the plugin package:

wget https://downloads.wordpress.org/plugin/redis-cache.2.0.18.zip 
unzip redis-cache.2.0.18.zip 

Run the following commands in sequence to copy the redis-cache folder to the /data/wwwroot/wordpress/wp-content/plugins/ path and configure WordPress to access ApsaraDB for Redis:

cp -rf redis-cache /data/wwwroot/wordpress/wp-content/plugins/ 
vim /data/wwwroot/wordpress/wp-config.php

Complete the settings as follows:

// Redis settings
define( 'WP_REDIS_HOST', '<Redis URL>' );
define( 'WP_REDIS_CLIENT', 'predis' );
define( 'WP_REDIS_PORT', '6379' );
define( 'WP_REDIS_DATABASE', '0');
define( 'WP_REDIS_PASSWORD', 'wordpress:N1cetest' );

14

Please MAKE SURE this Redis setting block is set at the first settings block of the wp-config.php file as shown in the image above.

Run the following command to copy the object-cache configuration file to the /data/wwwroot/wordpress/wp-content/ path:

cp /data/wwwroot/wordpress/wp-content/plugins/redis-cache/includes/object-cache.php /data/wwwroot/wordpress/wp-content/ 

Log on to WordPress to enable Redis object cache.

15

In the left-side navigation pane, click Plugins. Find the Redis Object Cache plugin and click Activate.

After the plugin is activated, click Settings.

16

Verify that the plugin status is Connected. Click Flush Cache to synchronize cache data to the ApsaraDB for Redis instance.

17

Now, your cloud native Wordpress has been setup successfully. You can visit it via SLB EIP:

http://<SLB_EIP>/

Auto-scaling configuration

After you have successfully configured and installed WordPress, you can follow the Step 4 of the following guide for auto-scaling configurations:

https://www.alibabacloud.com/blog/cloud-native-wordpress-on-alibaba-cloud_598043

Phase 2-3: SLB + WordPress ECS Servers (Auto-scaling) + Multi-AZ Redis Cache + Cloud Native PolarDB MySQL

  • Setup SLB and auto-scaling group for multiple ECS servers with WordPress web app.
  • Use cloud native database PolarDB with high availability and scalability.
  • Use Redis as data cache to improve web app performance. The cross availability zone feature also ensure the high availability.

18

Run the terraform script to initialize the resources. Within the terraform script, please use the right Image ID of WordPress image on the corresponding region.

  • After the Terraform script execution, logon to ECS via SSH, use the account root/N1cetest, the password has been predefined in Terraform script for this tutorial. If you changed the password, please use the correct password accordingly.

19

ssh root@<EIP_ECS>

Edit the WordPress configuration file to set the PolarDB MySQL URL, database and account information.

vim /data/wwwroot/wordpress/wp-config.php

20

Open the following URL in a Web browser to initialize WordPress:

http://<ECS_EIP>

Note: Replace the placeholder with the Elastic IP address of the ECS instance that you obtained previously.

Auto-scaling configuration

After you have successfully configured and installed WordPress, you can follow the following guide for auto-scaling configurations:

https://www.alibabacloud.com/blog/cloud-native-wordpress-on-alibaba-cloud_598043

0 0 0
Share on

ApsaraDB

235 posts | 18 followers

You may also like

Comments