当前位置: 首页 > 后端技术 > PHP

快速部署WordPress和phpMyAdmin-阿里云ROS

时间:2023-03-30 01:09:27 PHP

本文介绍如何使用ROS模板一键部署WordPress站点和phpMyAdmin应用。文档链接背景信息如果您只有网站内容管理人员,而没有专业的技术人员来建设和管理网站,则只能部署基础网站。如果你的网站有更高的要求,需要定制服务,高可用,高弹性,就需要寻求其他的解决方案。本文介绍的ROS资源栈模板(WordPressCluster-phpMyAdmin.ros)可以帮助您满足高可用和高弹性的需求。通过该模板,您可以快速部署由实例组成的资源栈,如全VPC、负载均衡、弹性伸缩、ECS、云数据库RDS等。同时部署WordPress和phpMyAdmin,并配置弹性伸缩。系统会根据需要自动添加和配置新实例,无需您手动操作。架构原理概述下图是通过ROS资源栈模板(WordPressCluster-phpMyAdmin.ros)创建资源栈的架构图。共有三种类型的用户将访问此基础架构:最终用户最终用户通过URL访问托管在WordPress上的网站。WordPress部署在ApacheWeb服务器中。服务器的文档根目录是/wwwroot。根目录所在的OSSBucket是Web服务器通过OSSFS(阿里云官方提供的基于FUSE的文件系统)共享的存储空间。RAM用户拥有OSSBuckets的访问权限,可以将OSSBuckets挂载到ECS实例上。RDSMySQL数据库存储WordPress内容。通过内网连接字符串从Web服务器访问数据库。系统管理员系统管理员通过SSH登录JumpBox(堡垒机),进入VPC环境。JumpBox具有弹性公网IP,可以通过互联网访问。通过JumpBox访问可管理VPC中的产品实例。phpMyAdmin安装在JumpBox上并通过Internet访问。这样系统管理员就可以管理RDS版本的云数据库了。内容所有者内容所有者可以通过互联网访问WordPress管理控制台。可以通过基于环境配置的安全组来控制对所有服务的访问。资源站模板概览点击WordPressCluster-phpMyAdmin.ros下载资源栈模板。说明您可以根据资源编排控制台支持的ECS可用区和镜像修改模板中的ZoneId和ImageId。根据WordPressCluster-phpMyAdmin.ros,系统会创建并配置VPC、负载均衡、VSwitch、NAT网关、ECS实例、弹性公网IP、弹性伸缩和云数据库RDS版本实例等。创建资源栈时,以下参数可以满足任何地区用户的需求。系统会根据模板在JumpBox上安装httpd、mysql-client、PHP、OSSFS、phpMyAdmin、WordPress,并通过资源ALIYUN::ECS::Instance的UserData部分配置这些应用。下面是UserData节选:"ossbucketendpoint=",{"Ref":"OSSBucketEndPoint"},"\n","DatabaseUser=",{"Ref":"MasterUserName"},"\n","DatabasePwd=",{"Ref":"MasterDBPassword"},"\n","DatabaseName=",{"Ref":"DBName"},"\n","DatabaseHost=",{"Fn::GetAtt":["数据库","InnerConnectionString"]},"\n","yuminstall-ycurlhttpdmysql-serverphpphp-commonphp-mysql\n","yuminstall-yphp-gdphp-imapphp-ldapphp-odbcphp-pearphp-xmlphp-xmlrpc\n","yuminstall-yphpmyadmin\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%DenyfromAll%AllowfromAll%\"/etc/httpd/conf.d/phpMyAdmin.conf\n","sed-i\"//aRequireallGranted\"/etc/httpd/conf.d/phpMyAdmin.conf\n","chkconfighttpdon\n","servicehttpdstop\n","wgethttps://github.com/aliyun/ossfs/releases/download/v1.80.3/ossfs_1.80.3_centos6.5_x86_64.rpm\n","yuminstall-yossfs_1.80.3_centos6.5_x86_64.rpm\n","echo$ossbucket:$ossbucketaccesskey:$ossbucketsecret>>/etc/passwd-ossfs\n","chmod600/etc/passwd-ossfs\n","mkdir$ossbucketmountpoint\n","chmod-R755$ossbucketmountpoint\n","echo#Thisscriptwillautomounttheossbucket\n","echoumount$ossbucketmountpoint>>/usr/local/bin/ossfs-automount.sh\n","echo#MountingOSSBucket\n","echoossfs$ossbucket$ossbucketmountpoint-ourl=http://$ossbucketendpoint-oallow_other-omp_umask=0022-ouid=48-ogid=48>>/usr/local/bin/ossfs-automount.sh\n","chmod755/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","wgethttp://WordPress.org/latest.tar.gz\n","tar-xzvflatest.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","mvWordPress/wp-config-sample.phpWordPress/wp-config.php\n","cp-aWordPress/*$ossbucketmountpoint\n","chmod-R755/wwwroot/*\n","rm-rfWordPress*\n","servicehttpdstart\n","done\n》通过UserData部分在OSSBucket上部署WordPress。OSSBucket可以挂载到弹性伸缩创建的Web服务器上,保证所有Web服务器的根目录下的内容都是最新的。安装配置httpd、PHP、ossutil,挂载DocumentRoo,通过弹性伸缩配置的UserData部分启动所有服务。以下是自动缩放配置的UserData部分的摘录:"DatabaseHost=",{"Fn::GetAtt":["Database","InnerConnectionString"]},"\n","yuminstall-ycurlhttpdmysql-serverphpphp-commonphp-mysql\n","yuminstall-yphp-gdphp-imapphp-ldapphp-odbcphp-pearphp-xmlphp-xmlrpc\n","chkconfighttpdon\n","servicehttpdstop\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","wgethttps://github.com/aliyun/ossfs/releases/download/v1.80.3/ossfs_1.80.3_centos6.5_x86_64.rpm\n","yuminstall-yossfs_1.80.3_centos6.5_x86_64.rpm\n","echo$ossbucket:$ossbucketaccesskey:$ossbucketsecret>>/etc/passwd-ossfs\n","chmod600/etc/passwd-ossfs\n","mkdir$ossbucketmountpoint\n","chmod-R755$ossbucketmountpoint\n","echo#Thisscriptwillautomounttheossbucket\n","echoumount$ossbucketmountpoint>>/usr/local/bin/ossfs-automount.sh\n","echo#MountingOSSBucket\n","echoossfs$ossbucket$ossbucketmountpoint-ourl=http://$ossbucketendpoint-oallow_other-omp_umask=0022-ouid=48-ogid=48>>/usr/local/bin/ossfs-automount.sh\n","chmod755/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-R755/wwwroot/*\n","servicehttpdstart\n","done\n"]