Ubuntu14.04搭建Boa服务
<p> Turn on/off Led </p>
<button type="button" id="led_on"> turn on </button>
<br/>
<br/>
<button type="button" id="led_off"> turn off </button>
</body>
</html>
1,下载boa源码
网址:
www.boa.org
版本:boa-0.94.13.tar.gz
2, 解压并进入boa-0.094.13/src/
3, 执行
./configure
make
错误:
yacc -d boa_grammar.y
make: yacc:命令未找到
make: *** [y.tab.c] 错误 127
解决:
缺bison库
sudo apt-get install bison
4, 继续执行make
错误:
lex boa_lexer.l
make: lex: 命令未找到
make: *** [lex.yy.c] 错误 127
解决:
sudo apt-get install flex
5,继续执行make
错误:
util.c:100:39: error: pasting "t" and "->" does not give a valid preprocessing token
time_offset = TIMEZONE_OFFSET(t);
compat.h: 120:30: note: in definition of macro 'TIMEZONE_OFFSET'
#define TIMEZONE_OFFSET(foo) foo##->tm_gmtoff
解决:
修改compat.h 120行,如下:
#define TIMEZONE_OFFSET(foo) foo->tm_gmtoff
6.继续执行make
OK.
上面已经初步编译成功!下面对boa进行配置
7.
sudo mkdir /etc/boa
cp boa-0.94.13/boa.conf /etc/boa/
将/etc/boa/boa.conf做如下修改:
a,
将:
User nobody
Group nogroup
改为:
User 0
Group 0
b, 将:
ScriptAlias /cgi-bin/ /var/www/htbin/
8, 创建必要的目录
sudo mkdir /var/www
sudo mkdir /var/www/cgi-bin
sudo mkdir /var/log/boa
9. 在/var/www/下创建测试的html文件index.html,
<html>
<body>
<p> Turn on/off Led </p>
<button type="button" id="led_on"> turn on </button>
<br/>
<br/>
<button type="button" id="led_off"> turn off </button>
</body>
</html>
10,在目录boa-0.94.13下执行./boa启动boa服务
sudo ./boa
a,
错误:
log.c:73 - unable to dup2 the error log: Bad file descriptor
解决:
注释掉log.c中:
}
/*
if (dup2(error_log, STDERR_FILENO) == -1) {
DIE("unable to dup2 the error log");
}
DIE("unable to dup2 the error log");
}
*/
重新编译。
b,再次执行./boa
错误:
boa.c: 226 - icky Linux kernel bug!: Success
解决:
注释掉:
if (setuid(0) != -1) {
DIE(”icky Linux kernel bug!”);
}
重新编译,并启动boa服务,成功启动!
11,打开浏览器,输入 http://127.0.0.1