URLOS实战入门—HelloWorld

URLOS实战入门—HelloWorld

创建hello world应用 

升级hello world应用(允许动态设置页面内容) 

1. 用ssh登录云主机,将/data/urlos/master-config/config.json文件的envType的值设置为dev。

2. 打开浏览器登录URLOS,地址:http://云主机IP:9968或者https://云主机IP:9966。

3. 在左侧菜单中选择应用管理。然后点击右上角的添加应用按钮。然后在表单页面输入应用的基本信息。如下图:

 

应用名称:hello world 版本号:0.1.0

应用别名:{ "cn": "hello world","en": "hello world"} 镜像:urlos/nginx:1.14.2-alpine-curl-[启动脚本:sh]。

URLOS最低版本号:0 应用分类:网站环境

容器端口:{"80":false, "443":false} 开发者信息:[{"text": "Nginx","url": "http://nginx.org/"}] 标签:nginx 状态:开启

描述:{"cn": "hello world"}

 

 

扩展设置插件:staticWebsites:v0_1_0-Liu Xin-静态网站环境。服务表单步骤:{"2": {"cn": "网站", "en": "Website"},"F": {"cn": "上传下载", "en": "File Transfer"},"%": {"cn":

"Nginx设置","en": "Nginx Set"}}。这里的步骤对应着创建服务时填写表单信息的步骤。

 

脚本设置安装脚本:test -d /run/nginx || mkdir -p /run/nginx 。

启动脚本:nginx

状态脚本:(ps -ef|grep "nginx"|grep "master process"|grep -v "grep") && statusScriptResult=1 检查nginx 是否正常运行。监控脚本:{w:statusScript:w} [ "$statusScriptResult" != 1 ] && exit 1 监控nginx是否正常运行。退出脚本:nginx -s stop 容器退出运行时执行的脚本,这里我们希望容器退出时关闭nginx。

 

4. 添加nginx虚拟站点的模板文件

 

模板内容如下:

{w:domains:w}、{w:listenLines:w}这两个变量是URLOS自带的,分别是域名、监听的端口号。

server {
server_name {w:domains:w};
{w:listenLines:w}
root /data/www;
index index.html index.htm;
}

 

5. 添加index.html模板文件

 

6. 测试hello world应用。在应用列表找到hello world应用点击右侧更多选择创建服务。填写相关信息,然后提交。

 

安装完成后,在浏览器访访问地址,检查是否页面内容显示hello world。一起动手试试吧。


升级hello world应用

1. 回到应用管理页面,点击hello world应用的更多,选择管理模板。

 

修改模板index.html的内容,将hello world 更改为变量 {w:pageContent:w},然后保存。

 

2. 在模板列表右上角点击管理扩展变量。然后点击添加扩展变量pageContent。

 

 

点击保存。然后修改刚才创建的hello world服务。在第2项表单中增加了一个网站内容的多行输入框,默认值为hello world。然后我们将内容改为hello world 2 如下图:

 

修改完后,需要回到第1步骤,将修改部署方式改为强制部署或者其他部署方式(请不要选择暂不部

署)。然后提交。服务部署完成后,刷新访问地址,页面内容则显示hello world 2。一起动手试试吧。