boa服务器

boa服务器移植

本文是针对最新2005年0.94.14rc21开发版的移植

      下载源码

      官网:http://www.boa.org/

      网盘:https://pan.baidu.com/s/1AqgdmvsjfrY14TK2d4bseQ

      提取码:ekfr

  • 解压源码

    tar -xvf boa-0.94.14rc21.tar.gz

  • 修改源码

    位置 src/defines.h

    #define SERVER_ROOT "/home/george/boa" //此处为boa服务器位置,根据自己设置的位置填写正确

  • 配置编译选项

    ./configure

    如果无法执行,请修改 configure 文件的权限为755

  • 编译源码

    make clean //编译前先清理以下

    make //编译

  • 配置boa服务器

    创建放置boa服务器的位置。(本文放在用户的根目录下)

    mkdir -p ~/boa ~/boa/www ~/boa/cgi-bin ~/boa/log

    拷贝安装相关文件

    cp src/boa src/boa_indexer examples/boa.conf ~/boa

    cp /etc/mime.types

    修改配置文件 boa.conf

  1 Port 80
  2 User 0
  3 Group 0
  4 ErrorLog /home/george/boa/log/error_log
  5 AccessLog /home/george/boa/log/access_log
  6 DocumentRoot /home/george/boa/www
  7 UserDir public_html
  8 DirectoryIndex index.html
  9 DirectoryMaker /home/george/boa/boa_indexer
 10 KeepAliveMax 1000
 11 KeepAliveTimeout 10
 12 MimeTypes /home/george/boa/mime.types
 13 DefaultType text/plain
 14 CGIPath /bin:/usr/bin:/usr/local/bin
 15 Alias /doc /usr/doc
 16 ScriptAlias /cgi-bin/ /home/george/boa/cgi-bin/

至此,即完成了boa 服务器的移植。

测试boa服务器

网盘地址里有测试文件,可以直接拷贝,也可按照下面自己新建。

  • 准备测试文件 index.html 和 test.cgi

在 boa 服务器的 www 目录下,新建 index.html,内容如下:

<html>
    <body>
        <h3>This is a test page!</h3><br/>
            <style>
                img{
                    width:auto;
                    height:auto;
                    max-width:100%;
                    max-height:100%;
                }
            </style>
            <img src="image.jpg"/>
            <h3>Tree picture</h3><br/>

            <a href="/cgi-bin/test.cgi">to cgi page</a>
    </body>
</html>
View Code

在 boa 服务器的 cgi-bin 目录下,新建 test.c,内容如下:

#include <stdio.h>

int main(void)
{
    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;
}
View Code

编译 test.c

gcc test.c -o test.cgi

找一张图片放入 www 目录下,并重命名为image.jpg

  • 启动 boa 服务器

    sudo ./boa

  • 在浏览器输入 boa 服务器所在机器的 IP 地址即可看到如下内容啦。

This is a test page! 
Tree picture 
tQ_ggL

如果不能看到图片,请查看图片的权限。

关闭 boa 服务器

查看 boa 服务器的进程号

ps -aux | grep boa

关闭 boa 服务器

sudo kill -9 [ boa 服务器的进程号 ]

posted @ 2020-02-27 14:28  嵌入式George  阅读(1124)  评论(0)    收藏  举报