第一步:下载boa服务器
www.boa.org
下载后解压 boa-0.94.13.tar.gz
tar xvf boa-0.94.13.tar.gz
第二步:进入解压后的文件夹/boa/src运行
./configure
命令
生成MakeFile文件
/*版本为第一步所示的版本,版本不对过程中可能会出现错误:
configure: error: cannot guess build type; you must specify one
在命令的后面添加 --build=arm-linux 即可 */
第三步:修改文件
修改/src/boa.c
注释掉第226行的if语句
if (setuid(0) != -1) {
DIE("icky Linux kernel bug!");
}
修改/src/compat.h
将
#define TIMEZONE_OFFSET(foo)foo##->tm_gmtoff
修改为
#defineTIMEZONE_OFFSET(foo)(foo)->tm_gmtoff
第四步:在/src文件夹下进行make
经过编译后,/src文件夹下会生成boa和boa_indexer两个文件
第五步:新建文件夹
在/etc文件夹下新建/boa文件夹,用来存放boa.conf文件和日志文件、报错文件。
在根目录下(与/etc同级)新建/web文件夹和/web/cgi-bin文件夹,web 文件夹用来存放HTML文件,/web/cgi-bin文件夹用来存放cgi文件
第六步:拷贝文件
将第四步产生的两个文件 boa和boa_indexer拷贝到/bin文件夹下
将/etc/mime.type 文件拷贝到/web文件夹下
将boa/boa.conf 文件拷贝到/etc/boa文件夹下
第七步:配置/etc/boa/boa.conf文件
将
Port 80
User nobody
Group nogroup
ErrorLog /var/log/boa/error_log
AccessLog /var/log/boa/access_log
DocumentRoot /var/www
UserDir public_html
DirectoryIndex index.html
DirectoryMaker /usr/lib/boa/boa_indexer
KeepAliveMax 1000
KeepAliveTimeout 10
MimeTypes /etc/mime.types
DefaultType text/plain
CGIPath /bin:/usr/bin:/usr/local/bin
Alias /doc /usr/doc
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
改为
Port 80
User 0
Group 0
ErrorLog /etc/boa/error_log
AccessLog /etc/boa/access_log
DocumentRoot /web
UserDir public_html
DirectoryIndex index.html
DirectoryMaker /bin/boa_indexer
KeepAliveMax 1000
KeepAliveTimeout 10
MimeTypes /web/mime.types
DefaultType text/plain
CGIPath /bin:/usr/bin:/usr/local/bin
Alias /doc /usr/doc
ScriptAlias /cgi-bin/ /web/cgi-bin/
第八步:启动服务器
直接 输入
boa
命令即可
第九步:测试
在/web文件夹下新建一个index.html文件(也可在别处新建,然后复制过来)
<html>
<body>
<a href="/cgi-bin/test.cgi">to cgi page</a>
</body>
</html>
在/web/cgi-bin文件夹下新建test.c文件(也可在别处新建,将编译后生成的test.cgi文件拷贝过来即可)
#include <stdio.h>
int main()
{
printf("Content-type:text/html\n\n"); //这句一定要加上
printf("<html><body>");
printf("<font style=\"color:red; font-size:30px;\">Hello, CGI!</font><br/>");
printf("<a href=\"/index.html\">return index.html</a>");
printf("</body></html>");
return 0;
}
编译测试文件
gcc -o test.cgi test.c
第十步:运行
在同网段的电脑浏览器中输入boa服务器所在主机的IP即可,收个页面会跳转到index.html界面,里面会有个链接,连接到cgi文件。