部署PaaS应用(Part5)CakePHP & Node.js 本文档是在已经完成“PaaS基础平台配置.docx”,Openshift平台没有部署任何应用的基础上编写的。 部署PaaS应用(Part5)CakePHP & Node.js 这两个应用分别来自于2015年和2014年样题中PaaS应用。 CakePHP的配置思路与WordPress相近,Node.js部署完后,能显示页面, 1、部署CakePHP应用 CakePHP 是一种用 PHP 构建 Web 站点的辅助工具,它很稳定,可直接用于生产及快速开发。 以下截取自2015年国赛云计算项目样题: 4.CakePHP系统部署 在Git Server上配置CakePHP的Git代码源,在PaaSNode通过git clone进行验证,将验证结果截图;部署CakePHP系统,CakePHP的公众URL为http://cakephp-paas.example.com;修改应用代码:CakePHP系统成功部署后,在PaaS Node上通过git下载CakePHP的代码,修改CakePHP的首页文件,把“Release Notes for CakePHP”修改为“PaaS CakePHP”。提交CakePHP的首页网页截图到答题框中。(本题5分) (1)在Git Server上配置CakePHP的本地代码源 [iyunv@codeserver ~]# cd [iyunv@codeserver ~]# mkdir gitlocal 使用SFTP将PaaS光盘中paas-xiandan目录中的cakephp-example.tar.gz传到Git Server的/root/gitlocal目录中。 [iyunv@codeserver ~]# cd gitlocal/ [iyunv@codeserver gitlocal]# ls cakephp-example.tar.gz [iyunv@codeserver gitlocal]# tar -zxfcakephp-example.tar.gz [iyunv@codeserver gitlocal]# ls cakephp-example cakephp-example.tar.gz [iyunv@codeserver gitlocal]# git clone --bare cakephp-examplecakephp-example.git Initialized empty Git repository in/root/gitlocal/cakephp-example.git/ [iyunv@codeserver gitlocal]# ls cakephp-example cakephp-example.git cakephp-example.tar.gz (2)在Node节点上git clone cakephp-example.git(样题得分点) Initialized empty Git repository in/root/cakephp-example/.git/ remote: Counting objects: 3374, done. remote: Compressing objects: 100%(2144/2144), done. remote: Total 3374 (delta 910), reused 3374(delta 910) Receiving objects: 100% (3374/3374), 4.21MiB, done. Resolving deltas: 100% (910/910), done. [iyunv@node ~]# ls anaconda-ks.cfg cakephp-example install.log install.log.syslog (3)使用浏览器打开paas.example.com,在设置标签的Namespace填写paas,点击Save保存。 (4)在应用标签创建新应用,点击CakePHP。 (5)在公共URL处填写cakephp,在源代码处填写root@192.168.200.200:/root/gitlocal/cakephp-example.git,点击CreateApplication。 (6)点击“现在不用,继续”。 (7)CakePHP创建完成。 (8)在新的标签页打开http://cakephp-paas.example.com。(样题得分点) (9)点击“添加公钥到您的账户”。 (10)在Node节点查看自己的RSA公钥。 [iyunv@node ~]# cd /root/.ssh [iyunv@node .ssh]# ls authorized_keys id_rsa id_rsa.pub known_hosts rsync_id_rsa.pub [iyunv@node .ssh]# cat id_rsa.pub ssh-rsaAAAAB3NzaC1yc2EAAAABIwAAAQEAs3WBUIFef4FtbWSEQVCoeUUiUsIFYB+YgXidW2MajYqlYvjCqtLJcLg2dZFjKwJ0JgoLbaJhi+3V0EtsVCyXK/pAyn56QkxZia/BzgSp0n3kNVxZ5KkLWnZ/xkMXaQH7CYk0e++4FgxUEviPv34hs58dXvR7IKbSSc2WDsJEpX78a82HnNiLoKtAs+h5im1aF25o6vzaqLHPzZkht4xcR/7oP5YNr9wwaVFmaqr0hyfgzZMwvQqJlX2Bx1GhHCTqQHKqshW+Ia1cGzGnVGNmI0bybP1pKRQTGwUS1yKTzgB7UxGYHZn3lN5I2aVUbFYccHD83qNa92Qhu/DTVO/2jw==root@node (11)将Node节点的RSA公钥复制进去。 (12)复制右侧的Source Code:ssh://5568141013db8c79fa000002@cakephp-paas.example.com/~/git/cakephp.git/。 (13)在PaaS Node上通过git下载CakePHP的代码。 [iyunv@node .ssh]# cd [iyunv@node ~]# mkdir sourcegit [iyunv@node ~]# cd sourcegit/ [iyunv@node sourcegit]# git clonessh://5568141013db8c79fa000002@cakephp-paas.example.com/~/git/cakephp.git/ Initialized empty Git repository in/root/sourcegit/cakephp/.git/ The authenticity of host'cakephp-paas.example.com (192.168.200.102)' can't be established. RSA key fingerprint is90:b6:9e:d0:3e:76:27:ce:34:3b:d6:b4:41:5d:e7:31. Are you sure you want to continueconnecting (yes/no)? yes Warning: Permanently added'cakephp-paas.example.com,192.168.200.102' (RSA) to the list of known hosts. remote: Counting objects: 3374, done. remote: Compressing objects: 100%(2144/2144), done. remote: Total 3374 (delta 910), reused 3374(delta 910) Receiving objects: 100% (3374/3374), 4.21MiB, done. Resolving deltas: 100% (910/910), done. [iyunv@node sourcegit]# ls cakephp (14)修改CakePHP的首页文件,把“Release Notes for CakePHP”修改为“PaaS CakePHP”。 看这里: (15)在Node节点上进入/root/sourcegit/cakephp/php/app/View/Pages/目录,修改home.ctp。 [iyunv@node sourcegit]# cd /root/sourcegit/cakephp/php/app/View/Pages/ [iyunv@node Pages]# ls home.ctp [iyunv@node Pages]# vi home.ctp 将“Release Notes for CakePHP”修改为“PaaS CakePHP”。 (16)提交更改 [iyunv@node Pages]# git commit -a 在自动弹出的vi编辑器中输入本次修改的注释信息,保存。 [iyunv@node Pages]# git push Counting objects: 13, done. Compressing objects: 100% (6/6), done. Writing objects: 100% (7/7), 523 bytes,done. Total 7 (delta 5), reused 0 (delta 0) remote: Stopping PHP cartridge remote: [Fri May 29 03:47:34 2015] [warn]PassEnv variable SHELL was undefined remote: [Fri May 29 03:47:34 2015] [warn]PassEnv variable USER was undefined remote: [Fri May 29 03:47:34 2015] [warn]PassEnv variable LOGNAME was undefined remote: Waiting for stop to finish remote: Stopping MySQL cartridge remote: Building git ref 'master', commitad64489 remote: Building PHP cartridge remote: Preparing build for deployment remote: Deployment id is 4e0531a6 remote: Activating deployment remote: Starting MySQL cartridge remote: Database found, skipping import. remote: Starting PHP cartridge remote: Result: success remote: Activation status: success remote: Deployment completed with status:success Tossh://5568141013db8c79fa000002@cakephp-paas.example.com/~/git/cakephp.git/ 4620c2d..ad64489 master ->master (17)刷新http://cakephp-paas.example.com。(样题得分点) 2、部署Node.js应用 Node.js是一个基于ChromeJavaScript Runtime建立的平台,用于方便地搭建速度快、易于扩展的网络应用。 以下截取自2014年国赛云安全项目样题: 任务五、PaaS平台上部署应用(10分) 1、通过PaaS部署NodeJS(50%) 创建一个NodeJS的应用,应用名为use-nodejs.paas.com。 2、登录部署应用的网站验证 (50%) (1)使用浏览器打开paas.example.com,在应用标签点击“增加应用”。 (2)选择Node.js 0.10。 (3)输入公共URL,点击Create Application。 (4)点击查看应用程序。 (5)访问http://nodejs-paas.example.com。 注:这里是按照2015年的域名要求配置的,如需严格按照2014年的域名要求配置Node.js,可以先不部署CakePHP,直接部署Node.js。 图文详情,请查看附件。
|