使用ROS在阿里云上快速部署WordPress和phpMyAdmin

This article was originally published on Alibaba Cloud. Thank you for supporting the partners who make SitePoint possible.

本文最初发表在阿里云上 感谢您支持使SitePoint成为可能的合作伙伴。

Think you got a better tip for making the best use of Alibaba Cloud services? Tell us about it and go in for your chance to win a Macbook Pro (plus other cool stuff). Find out more here.

认为您有更好的技巧来充分利用阿里云服务吗? 告诉我们,并争取获得Macbook Pro的机会(还有其他很棒的东西)。 在这里找到更多

This document shows how to deploy a WordPress site and phpMyAdmin application using the ROS template with a single click.

本文档展示了如何通过单击ROS模板来部署WordPress网站和phpMyAdmin应用程序。

介绍 (Introduction)

Many users do not have in-house technical capabilities to build and manage a website. They have teams who can manage the content but not the infrastructure that comes along with it. Currently available solutions are suitable for a limited period when the requirements are basic, but as soon as they require customization, high availability, and scalability, additional solutions supporting scaling are needed.

许多用户没有内部技术能力来构建和管理网站。 他们的团队可以管理内容,但不能管理随之而来的基础架构。 当前可用的解决方案仅在基本需求时适用于有限的时期,但是一旦需要定制,高可用性和可伸缩性,就需要支持扩展的其他解决方案。

The ROS stack template (WordPressCluster-phpMyAdmin.ros) discussed in this document helps address the high availability and scalability requirements of such users. With a single click, it creates the entire VPC stack, Server Load Balancer, Auto Scaling, ECS, RDS, and other instances, deploys WordPress and phpMyAdmin, and configures Auto Scaling to guarantee that any new instances can be added and configured without manual intervention.

本文档中讨论的ROS堆栈模板( WordPressCluster-phpMyAdmin.ros )帮助解决此类用户的高可用性和可伸缩性要求。 只需单击一下,它即可创建整个VPC堆栈, Server Load BalancerAuto ScalingECSRDS和其他实例,部署WordPress和phpMyAdmin,并配置Auto Scaling以确保无需手动干预即可添加和配置任何新实例。 。

先决条件 (Prerequisites)

  • Availability of an OSS bucket.

    OSS存储桶的可用性。
  • RAM user with read and write access to the OSS bucket.

    具有对OSS存储桶的读写访问权限的RAM用户。
  • Understanding of ROS and ability to create ROS stack templates and stacks from the console.

    了解ROS以及从控制台创建ROS堆栈模板和堆栈的能力。

架构概述 (Architecture overview)

Architecture

This diagram provides an overview of the deployment architecture that is generated based on the template WordPressCluster-phpMyAdmin.ros.

此图概述了基于模板WordPressCluster-phpMyAdmin.ros生成的部署体系结构。

Three types of users access the infrastructure:

三种类型的用户访问基础结构:

End users, who access the website hosted on WordPress through a URL that is resolved to a Public Server Load Balancer instance.

最终用户 ,他们通过解析为Public Server Load Balancer实例的URL访问WordPress上托管的网站。

WordPress is hosted on Apache web servers. The servers have their document root set to /wwwroot which is on an OSS bucket shared across the web servers using OSSFS (a FUSE-based file system officially provided by Alibaba Cloud).

WordPress托管在Apache Web服务器上。 这些服务器的文档根目录设置为/wwwroot ,位于使用OSSFS(阿里云正式提供的基于FUSE的文件系统)在Web服务器上共享的OSS存储桶中。

RAM users who have the access permission of the OSS bucket can mount the OSS bucket on the ECS instance.

拥有OSS存储桶访问权限的RAM用户可以将OSS存储桶安装在ECS实例上。

The RDS for MySQL database holds the WordPress content and is accessed from the web server over its intranet connect string.

适用于MySQL的RDS数据库包含WordPress内容,可通过Web服务器通过其Intranet连接字符串进行访问。

System administrator, who can access to the VPC environment through an SSH logon to the JumpBox (bastion host).

系统管理员 ,可以通过SSH登录到JumpBox(堡垒主机)来访问VPC环境。

The JumpBox has an elastic IP and is accessed over the Internet.

JumpBox具有弹性IP,可通过Internet访问。

The access through JumpBox is to manage the instances inside the VPC.

通过JumpBox进行的访问是在VPC内部管理实例。

phpMyAdmin is installed on the JumpBox and is accessible over the Internet.

phpMyAdmin安装在JumpBox上,可通过Internet访问。

In this way, the administrators can administer the RDS database.

这样,管理员可以管理RDS数据库。

Content managers, who can access the WordPress Management console through the Internet.

内容管理员 ,可以通过Internet访问WordPress管理控制台。

Access to all these services can be controlled by security groups and can be configured as per the environment.

对所有这些服务的访问可以由安全组控制,并可以根据环境进行配置。

模板概述 (The Template Overview)

Click WordPressCluster-phpMyAdmin.ros to download the ROS stack template for use.

单击WordPressCluster-phpMyAdmin.ros下载ROS堆栈模板以供使用。

Note: In the template, the ZoneId is set as eu-central-1a, and the ImageId is m-gw8efmfk0y184zs0m0aj. You can modify the ZoneId and the ImageId according to the zones and images supported in the ROS console. Log on to the ROS console, click ECS Instance Information, select a region, and click ECS Zone or ECS Image to view all the zones or images supported in this region.

注意:在模板中,ZoneId设置为eu-central-1a ,ImageId为m-gw8efmfk0y184zs0m0aj 。 您可以根据ROS控制台中支持的区域和图像来修改ZoneId和ImageId。 登录ROS控制台 ,单击“ ECS实例信息” ,选择一个区域,然后单击“ ECS区域”或“ ECS图像”以查看该区域支持的所有区域或图像。

Based on the WordPressCluster-phpMyAdmin.ros stack template, the system creates the VPC, Server Load Balancer, VSwitch, NAT Gateway, Security Groups, and ECS instances for JumpBox, Elastic IP for JumpBox, Auto Scaling for ECS instances, and RDS instance.

系统基于WordPressCluster-phpMyAdmin.ros堆栈模板,为JumpBox创建VPC,服务器负载平衡器,VSwitch,NAT网关,安全组和ECS实例,JumpBox的弹性IP,ECS实例的Auto Scaling和RDS实例。

It takes the following input parameters to make the resource stack generic enough to be deployable for any user in any region.

它使用以下输入参数来使资源堆栈具有足够的通用性,以便可用于任何区域中的任何用户。

parameters1
parameter2

According to the template, the system installs httpd, mysql-client, PHP, OSSFS, phpMyAdmin, and WordPress on the JumpBox and also configures them in the UserData section of the ALIYUN::ECS::Instance resource.

根据模板,系统会在JumpBox上安装httpd,mysql-client,PHP,OSSFS,phpMyAdmin和WordPress,并在ALIYUN :: ECS :: Instance资源的UserData部分中对其进行配置。

The following is a snippet of the UserData section of the JumpBox.

以下是JumpBox的UserData部分的代码段。

"ossbucketendpoint=",
   {
   "Ref": "OSSBucketEndPoint"
   },
   "\n",
   "DatabaseUser=",
   {
   "Ref": "MasterUserName"
   },
   "\n",
   "DatabasePwd=",
   {
   "Ref": "MasterDBPassword"
   },
   "\n",
   "DatabaseName=",
   {
   "Ref": "DBName"
   },
   "\n",
   "DatabaseHost=",
   {
   "Fn::GetAtt": ["Database", "InnerConnectionString"]
   },
   "\n",
   "yum install -y curl httpd mysql-server php php-common php-mysql\n",
   "yum install -y php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc\n",
   "yum install -y phpmyadmin\n",
   "sed -i \"s%localhost%$DatabaseHost%\" /etc/phpMyAdmin/config.inc.php\n",
   "sed -i \"s%Deny,Allow%Allow,Deny%\" /etc/httpd/conf.d/phpMyAdmin.conf\n",
   "sed -i \"s%Deny from All%Allow from All%\" /etc/httpd/conf.d/phpMyAdmin.conf\n",
   "sed -i \"/<RequireAny>/a Require all Granted\" /etc/httpd/conf.d/phpMyAdmin.conf\n",
   "chkconfig httpd on\n",
   "service httpd stop\n",
   "wget  
   https://github.com/aliyun/ossfs/releases/download/v1.80.3/ossfs_1.80.3_centos6.5_x86_64.rpm\n",
   "yum install -y ossfs_1.80.3_centos6.5_x86_64.rpm\n",
   "echo $ossbucket:$ossbucketaccesskey:$ossbucketsecret >> /etc/passwd-ossfs\n",
   "chmod 600 /etc/passwd-ossfs\n",
   "mkdir $ossbucketmountpoint\n",
   "chmod -R 755 $ossbucketmountpoint\n",
   "echo #This script will automount the ossbucket\n",
   "echo umount $ossbucketmountpoint >> /usr/local/bin/ossfs-automount.sh\n",
   "echo #Mounting OSS Bucket\n",
              "echo ossfs $ossbucket $ossbucketmountpoint -ourl=http://$ossbucketendpoint -o allow_other -o mp_umask=0022 -ouid=48 -ogid=48 >> /usr/local/bin/ossfs-automount.sh\n",
"chmod 755 /usr/local/bin/ossfs-automount.sh\n",
"echo /usr/local/bin/ossfs-automount.sh >> /etc/rc.d/rc.local\n",
"chmod +x /etc/rc.d/rc.local\n",
"/usr/local/bin/./ossfs-automount.sh\n",
"wget http://WordPress.org/latest.tar.gz\n",
"tar -xzvf latest.tar.gz\n",             
"sed -i \"s%database_name_here%$DatabaseName%\" WordPress/wp-config-sample.php\n",
"sed -i \"s%username_here%$DatabaseUser%\" WordPress/wp-config-sample.php\n",
"sed -i \"s%password_here%${DatabasePwd:-$DatabasePwdDef}%\" WordPress/wp-config-sample.php\n",
"sed -i \"s%localhost%$DatabaseHost%\" WordPress/wp-config-sample.php\n",
"mv WordPress/wp-config-sample.php WordPress/wp-config.php\n",
"cp -a WordPress/* $ossbucketmountpoint\n",
"chmod -R 755 /wwwroot/*\n",
"rm -rf WordPress*\n",
"service httpd start\n",
"done\n"

The UserData section deploys WordPress on the OSS bucket which can be mounted to the web servers created using Auto Scaling. This guarantees that the web servers have the updated content from the document root.

UserData部分将WordPress部署在OSS存储桶上,该OSS存储桶可以安装到使用Auto Scaling创建的Web服务器上。 这样可以确保Web服务器具有来自文档根目录的更新内容。

The web servers are started through Auto Scaling. The installation and configuration of httpd, PHP, and ossutil, mounting of DocumentRoo, and starting of services are done in the UserData section of the Auto Scaling configuration.

Web服务器通过Auto Scaling启动。 httpd,PHP和ossutil的安装和配置,DocumentRoo的安装以及服务的启动在Auto Scaling配置的UserData部分中完成。

The following is a snippet of the UserData section of the web server Auto Scaling configuration.

以下是Web服务器Auto Scaling配置的UserData部分的代码段。

"DatabaseHost=",
              {
                "Fn::GetAtt": ["Database", "InnerConnectionString"]
              },
              "\n",
              "yum install -y curl httpd mysql-server php php-common php-mysql\n",
              "yum install -y php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc\n",
              "chkconfig httpd on\n",
              "service httpd stop\n",
              "DocumentRoot='/var/www/html'\n",
              "sed -i \"s%$DocumentRoot%$ossbucketmountpoint%\" /etc/httpd/conf/httpd.conf\n",
              "Directory='/var/www'\n",
              "sed -i \"s%$Directory%$ossbucketmountpoint%\" /etc/httpd/conf/httpd.conf\n",
"wget https://github.com/aliyun/ossfs/releases/download/v1.80.3/ossfs_1.80.3_centos6.5_x86_64.rpm\n",
              "yum install -y ossfs_1.80.3_centos6.5_x86_64.rpm\n",
              "echo $ossbucket:$ossbucketaccesskey:$ossbucketsecret >> /etc/passwd-ossfs\n",
              "chmod 600 /etc/passwd-ossfs\n",
              "mkdir $ossbucketmountpoint\n",
              "chmod -R 755 $ossbucketmountpoint\n",
              "echo #This script will automount the ossbucket\n",
              "echo umount $ossbucketmountpoint >> /usr/local/bin/ossfs-automount.sh\n",
              "echo #Mounting OSS Bucket\n",
              "echo ossfs $ossbucket $ossbucketmountpoint -ourl=http://$ossbucketendpoint -o allow_other -o mp_umask=0022 -ouid=48 -ogid=48 >> /usr/local/bin/ossfs-automount.sh\n",
              "chmod 755 /usr/local/bin/ossfs-automount.sh\n",
              "echo /usr/local/bin/ossfs-automount.sh >> /etc/rc.d/rc.local\n",
              "chmod +x /etc/rc.d/rc.local\n",
              "/usr/local/bin/./ossfs-automount.sh\n",
              "chmod -R 755 /wwwroot/*\n",
              "service httpd start\n",
              "done\n"
            ]

This is a good solution for users who are looking for an end-to-end environment, and for solution architects to support their customers in POC.

对于正在寻找端到端环境的用户以及解决方案架构师在POC中支持其客户而言,这是一个很好的解决方案。

进一步阅读 (Further Reading)

翻译自: https://www.sitepoint.com/quickly-deploy-wordpress-phpmyadmin-on-alibaba-cloud-with-ros/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值