应用开发前,首先打开dev模式创建helloworld应用并升级helloworld应用(允许动态设置页面内容)1.使用ssh登录云主机,并设置/data/urlos/master-config/config.json文件的envType值设置为dev。2、打开浏览器登录URLOS,地址:http://云主机IP:9968或https://云主机IP:9966。3.在左侧菜单中选择应用程序管理。然后点击右上角的添加应用按钮。然后在表单页面输入申请的基本信息。如下图:应用名称:helloworld版本号:0.1.0应用别名:{"cn":"helloworld","en":"helloworld"}镜像:urlos/nginx:1.14.2-alpine-curl-[启动脚本:sh]。最低URLOS版本号:0应用类别:网站环境容器端口:{"80":false,"443":false}开发者信息:[{"text":"Nginx","url":"http://nginx.org/"}]标签:nginx状态:开启描述:{"cn":"helloworld"}服务表单步骤:{"2":{"cn":"Website","en":"Website"},"F":{"cn":"上传下载","en":"文件传输"},"%":{"cn":"Nginx设置","en":"Nginx设置"}}这里的步骤对应创建服务时填写表单信息的步骤。脚本设置安装脚本:test-d/run/nginx||mkdir-p/run/nginxstartscript:nginxstatusscript:(ps-ef|grep"nginx"|grep"masterprocess"|grep-v"grep")&&statusScriptResult=1查看nginx是否正常运行。监控脚本:{w:statusScript:w}["$statusScriptResult"!=1]&&exit1监控nginx是否正常运行。退出脚本:nginx-sstop容器退出runtime时执行的脚本,这里我们要在容器退出时关闭nginx。4.添加nginx虚拟站点模板文件。模板内容如下:{w:domains:w},{w:listenLines:w}这两个变量是URLOS自带的,分别是域名和监听端口号。server{server_name{w:domains:w};{w:listenLines:w}root/data/www;indexindex.htmlindex.htm;}5.添加index.html模板文件6.测试helloworld应用程序。在应用列表中找到helloworld应用,点击右侧的更多创建服务。填写相关信息并提交。安装完成后,在浏览器中访问该地址,查看页面内容是否显示helloworld。让我们一起试试吧。升级helloworld应用回到应用管理页面,点击helloworld应用的更多,选择管理模板。修改模板index.html的内容,将helloworld改为变量{w:pageContent:w},保存。单击模板列表右上角的管理扩展变量。然后单击添加扩展变量pageContent。单击保存。然后修改刚才创建的helloworld服务。在第二个窗体中增加了网站内容的多行输入框,默认值为helloworld。然后我们将内容改为helloworld2如下图:修改后需要回到步骤1,将修改后的部署方式改为强制部署或者其他部署方式(请不要选择暂时不部署).然后提交。服务部署完成后,刷新访问地址,页面内容会显示helloworld2,一起来试试吧。
