(轉)在嵌入式Linux系統(OK6410)中移植Boa 伺服器

來源:互聯網
上載者:User

標籤:

OK6410的Boa伺服器移植:

<一> Boa的編譯

1. 從 www.boa.org 下載 Boa 伺服器的最新版:boa-0.94.13.tar.gz。

2. 解壓:tar xzf boa-0.94.13.tar.gz

3. 進入解壓後的檔案夾 boa-0.94.13內部的 src檔案夾,對源檔案進行如下修改

=================================================

由於arm-linux-gcc 編譯器版本過高,對文法的支援有一些改變,所以需要修改compat.h中的
#define TIMEZONE_OFFSET(foo) foo##->tm_gmtoff
為:

#define TIMEZONE_OFFSET(foo) foo->tm_gmtoff
不然在編譯的時候會提示如下錯誤:
util.c: 100: 1: pasting “t” and “->” does not give a valid preprocessing token make: [util.o] Error1

=================================================

=================================================

將boa.c 檔案225-227三行的檔案注釋掉
if (setuid(0) != -1) {
DIE(”icky Linux kernel bug!”);
}

/*
if (setuid(0) != -1) {
DIE(”icky Linux kernel bug!”);
}
*/

,否則,但以root許可權啟動boa伺服器的時候,會出現以下錯誤:boa.c:226 - icky Linux kernel bug!:

=================================================

4. 然後產生Makefile:./configure

5. 修改產生的Makefile:預設產生的Makefile針對x86平台,我們的目標是針對嵌入式平台,所以需要修改編譯器.

1 更改Makefile的31行和32行:2 CC = gcc 3 CPP = gcc -E4 更改為5 CC = arm-linux-gcc6 CPP = arm-linux-gcc -E

6. 在目前的目錄下編譯Boa源檔案: make

7. 將產生好的boa可執行檔去掉冗餘資訊: arm-linux-strip boa. 如為strip 前後boa的大小對比。

 

<二> 將Boa移植到OK6410中

1. 修改boa.conf設定檔:

=================================================

(1) 修改25行的port連接埠,用來設定伺服器監聽的連接埠:# Port: The port Boa runs on.  The default port for http servers is 80.# If it is less than 1024, the server must be started as root.Port 80(2) 注釋43行的監聽IP地址:預設監聽該主機上的所有IP地址#Listen 192.68.0.5(3) 修改53、54行的user和Group 啟動的UID和GID,使其以root身份啟動#  User: The name or UID the server should run as.# Group: The group name or GID the server should run as.User rootGroup root(4) 修改116行的DocumentRoot地址,即用戶端要顯示的HTML頁面存放位置# DocumentRoot: The root directory of the HTML documents.# Comment out to disable server non user files.DocumentRoot /usr/local/boa(5) 修改輸入網頁輸入主機IP時要顯示的頁面:這裡設為index.html # DirectoryIndex: Name of the file to use as a pre-written HTML# directory index.  Please MAKE AND USE THESE FILES.  On the# fly creation of directory indexes can be _slow_.# Comment out to always use DirectoryMakerDirectoryIndex index.html(6) 修改CGI程式存放的位置:以http://IP/cgi-bin/cginame 的方式運行cgi 程式時將在/usr/local/boa/cgi-bin 目錄下尋找該程式# ScriptAlias: Maps a virtual path to a directory for serving scripts# Example: ScriptAlias /htbin/ /www/htbin/ScriptAlias /cgi-bin/ /usr/local/boa/cgi-bin/

=================================================

2. 將設定檔boa.conf 移動到OK6410的 /etc/boa/ 目錄下。

3. 建立/var/log/boa/ 目錄,這樣Boa伺服器啟動時會在該目錄下建立記錄檔。

4. 將Linux系統上/etc/mime.types 檔案複製到OK6410的/etc 目錄下,否則Boa伺服器啟動不起來。

5. 將產生的boa檔案移植到嵌入式板中的/sbin目錄下並變更指令碼檔案 /etc/init.d/rcS, 新增一行: /sbin/boa ,確保boa伺服器隨系統上電自啟動。

=================================================

這裡一定要注意:有時候boa伺服器並不能隨系統啟動,運行 /sbin/boa 命令會提示:

gethostbyname:: Success 這種情況下要修改boa.conf 檔案      #ServerName  www.your.org.here      改為       ServerName  www.your.org.here 即去掉注釋即可

=================================================

<三> 測試Boa伺服器:

1. 靜態頁面測試:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Boa 靜態網頁測試</title></head><body>    <h1>  Welcome to Boa sever! </h1></body></html>

  

2. CGI  程式測試:

#include <stdio.h>int  main(){    printf("Content-type: text/html\n\n");    printf("<html>\n");    printf("<head>\n");    printf("<title>CGI Output</title>\n");    printf("</head>\n");    printf("<body>");    printf("<h1> Hello, world. </h1>");    printf("</body>");    printf("</html>\n");   return 0;}

  

至此,Boa伺服器移植完成。

 

參考:

1,在嵌入式Linux系統(OK6410)中移植Boa 伺服器

http://www.cnblogs.com/chenchenluo/p/3576129.html

(轉)在嵌入式Linux系統(OK6410)中移植Boa 伺服器

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.