Appweb是一个嵌入式HTTP Web服务器,主要的设计思路是安全。这是直接集成到客户的应用和设备,便于开发和部署基于Web的应用程序和设备。它迅速( 每秒处理3500多要求)而紧凑 ,其中包括支持动态网页制作,服务器端嵌入式脚本过程中的CGI ,可加载模块,的SSL ,摘要式身份验证,虚拟主机, Apache样式配置,日志记录,单和多线程应用程序。它提供了大量的文档和示例,在最新的Appweb 5.2.0中支持esp-angular-mvc,真正的与最新的前端技术接轨。废话少说,进入正题。呵呵
1、配置ARM编译环境
获取相应ARM编译工具链,解压并将安装在etc/bin/local中
在~/.bashrc设置相应环境变量:
export DIR=/usr/local/bin/arm/4.3.3
export AR=$DIR/bin/arm-linux-ar
export CC=$DIR/bin/arm-linux-gcc
export LD=$DIR/bin/arm-linux-ld
export NM=$DIR/bin/arm-linux-nm
export RANLIB=$DIR/bin/arm-linux-ranlib
export STRIP=$DIR/bin/arm-linux-strip
export CFLAGS="-I$DIR/include"
2、下载appweb 5.2.0版本(源码版本)并解压
进入appweb源码根目录make -f projects/appweb-linux-default.mk ARCH=arm PROFILE=static
ARCH :体系结构
PROFILE:debug 调试版本、release 发布版本、static 静态编译版本(适合在嵌入式平台)
产生build文件夹,里面相应产生linux-arm-static文件夹
将linux-arm-static/bin文件夹拷贝到相应arm平台的根文件系统
3、下载esp版本并解压(此esp用当前gcc编译,否则esp命令是无法执行)
make 进行编译源码
make install 将esp安装到系统
4、下载pak源码并解压(我们可以用pak下载相应的框架源码到本地缓存例如:~/.pak)
pak esp-angular-mvc 下载esp-angular-mvc框架
5、利用esp产生相应我们要的框架 esp-angular-mvc
esp init(产生package.json配置文件)
esp install esp-angular-mvc(产生esp-angular-mvc框架并将相应配置写进package.json)
esp generate appweb (产生appweb配置文件appweb.conf)
6、配置package.json和appweb.conf
appweb.conf增加:
Documents static(appweb静态链接)
package.json 修改:
app.http.content = combine:["c"]
app.http.update = false (不产生动态编译,嵌入式没有编译器)
7、编译应用程序
拷贝appweb 5.2.0的build目录下linux-arm-static到应用程序根目录,然后
esp --platform linux-arm-static compile
8、将当前文件夹挂载nfs,然后在arm平台上
bin/appweb
192.168.1.2:4000
成功访问页面!!
appweb.conf与package.json配置
#
# appweb.conf -- Appweb configuration for ${UAPP} (esp-angular-mvc)
#
ErrorLog stdout level=2 append stamp=1hr
Documents static
Listen 4000
LoadModule espHandler libmod_esp
#
# SSL/TLS configuration
#
# LoadModule sslModule libmod_ssl
# ListenSecure 443
#
# SECURITY NOTE: you must generate the server.crt and server.key.pem.
# Use a decrypted key here so it won't prompt for the password.
#
# SSLCertificateFile "server.crt"
# SSLCertificateKeyFile "server.key.pem"
#
# Define the application
#
#
# EspResource NAME
# EspResourceGroup
#
#
# AddInputFilter uploadFilter
# UploadDir /tmp
# UploadAutoDelete on
# LimitUpload 200MB
#
# LogRoutes
{
"name": "init",
"title": "init",
"description": "init",
"version": "1.0.0",
"dependencies": {
"esp-angular-mvc": "~5.2"
},
"import": true,
"app": {
"http": {
"database": "default",
"serverPrefix": "/do",
"formats": {
"response": "json",
"date": "yyyy-MM-dd",
"float": 2
},
"routes": "esp-angular-mvc",
"xsrf": true,
"update":false,
"content": {
"combine":["c"]
},
},
"client": {
"scripts": [
"lib/angular/angular.js",
"lib/angular/angular-animate.js",
"lib/angular/angular-route.js",
"lib/esp-angular/*.js",
"app/main.js",
"app/*/**.js*"
],
"mappings": {
"auth": {
"login": "app.http.auth.login",
"store": "app.http.auth.store"
},
"formats": "app.http.formats",
"prefix": "app.http.prefix",
"serverPrefix": "app.http.serverPrefix",
"timeouts": "app.http.timeouts"
}
},
"esp": {
"compile":"optimized",
"generate": {
"controllerSingleton": "esp-mvc/generate/controller.c",
"migration": "esp-mvc/generate/migration.c",
"module": "esp-mvc/generate/src/app.c",
"appweb": "esp-angular-mvc/generate/appweb.conf",
"clientModel": "esp-angular-mvc/generate/model.js",
"clientController": "esp-angular-mvc/generate/controller.js",
"clientList": "esp-angular-mvc/generate/list.html",
"clientEdit": "esp-angular-mvc/generate/edit.html",
"controller": "esp-angular-mvc/generate/controller.c"
}
}
}
}