bl双性强迫侵犯h_国产在线观看人成激情视频_蜜芽188_被诱拐的少孩全彩啪啪漫画

SylixOS移植Boa服務器

1. Boa簡介

Boa是一種非常小巧的Web服務器,其可執行代碼只有大約60KB左右。作為一種單任務Web服務器,Boa只能依次完成用戶的請求,而不會fork出新的進程來處理并發連接請求。但Boa支持CGI,能夠為CGI程序fork出一個進程來執行。Boa的設計目標是速度和安全,適合于嵌入式系統的單任務的http服務器,源代碼開放、性能高。

創新互聯建站-云計算及IDC服務提供商,涵蓋公有云、IDC機房租用、成都多線機房、等保安全、私有云建設等企業級互聯網基礎服務,聯系熱線:13518219792

下面給大家介紹一下Boa服務器在SylixOS上移植的具體操作步驟,希望能夠有幫助。

2. SylixOS Boa移植:

Boa采用服務器模型,因此需要編譯出服務器的可執行程序。

2.1 下載Boa源碼

在官網下載第三方中間件的資源,Boa的官方網站為:http://www.boa.org/。本文中使用的版本是boa-0.94.13,下載后解壓文件,文件目錄如圖 2-1所示。

                  SylixOS移植Boa服務器

                                                    

圖 2-1 Boa解壓后的文件

2.2 服務器工程創建

在Real-Evo IDE中創建boa_sylixos應用工程,刪除工程中src目錄下的boa_sylixos.c文件,導入源碼中的src目錄下的一系列相關.c和.h文件。導入完成后的工程文件如圖 2-2所示。

                                                   SylixOS移植Boa服務器

                                                          

圖 2-2 工程文件

2.3 修改源碼文件

具體源碼文件修改,詳見《移植boa服務器過程文檔》。

2.4 修改boa.conf配置文件

在boa-0.94.13目錄下已有一個示例boa.conf,可以在其基礎上進行修改。如下:

(1)Group的修改

修改:Group nogroup

為 :Group 0

(2)user的修改

修改:User nobody

為 :User 0

(3)ScriptAlias的修改

修改:ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

為 :ScriptAlias /cgi-bin/ /var/www/cgi-bin/

(5)DoucmentRoot的修改

DoucmentRoot /var/www

(6)ServerName的設置

修改:#ServerName www.your.org.here

為 :ServerName www.your.org.here

否則會出現錯誤“gethostbyname::No such file or directory”

(7)AccessLog修改

修改:AccessLog /var/log/boa/access_log

為:#AccessLog /var/log/boa/access_log

否則會出現錯誤提示:“unable to dup2 the error log: Bad file descriptor”

2.5 編譯生成boa_sylixos可執行文件

編譯生成可執行文件boa_sylixos,并將之上傳至目標機/etc/boa目錄下;

2.6 拷貝mime.types文件

將linux /etc目錄下的mime.types文件拷貝到目標機/etc目錄下;(mime.types文件用來指明不同文件擴展名對應的MIME類型,一般可以直接從Linux主機上拷貝一個,大部分也都是在主機的/etc目錄下。)

2.7 新建工程boa_cgi_child_func

目的:實現Boa源碼中的fork函數功能

1) 創建app工程,修改boa_cgi_child_func.c文件,加入如下代碼:

#include <stdio.h>

#include <stdlib.h>

 

#define NI_MAXHOST                  20

#define CGI_ENV_MAX                 50

#define SOCKETBUF_SIZE              8192

#define MAX_HEADER_LENGTH           1024

#define CLIENT_STREAM_SIZE          SOCKETBUF_SIZE

#define BUFFER_SIZE                 CLIENT_STREAM_SIZE

 

struct mmap_entry {

    dev_t dev;

    ino_t ino;

    char *mmap;

    int use_count;

    size_t len;

};

 

struct request {                /* pending requests */

    int fd;                     /* client's socket fd */

    int status;                 /* see #defines.h */

    time_t time_last;           /* time of last succ. op. */

    char *pathname;             /* pathname of requested file */

    int simple;                 /* simple request? */

    int keepalive;              /* keepalive status */

    int kacount;                /* keepalive count */

 

    int data_fd;                /* fd of data */

    unsigned long filesize;     /* filesize */

    unsigned long filepos;      /* position in file */

    char *data_mem;             /* mmapped/malloced char array */

    int method;                 /* M_GET, M_POST, etc. */

 

    char *logline;              /* line to log file */

 

    char *header_line;          /* beginning of un or incompletely processed header line */

    char *header_end;           /* last known end of header, or end of processed data */

    int parse_pos;              /* how much have we parsed */

    int client_stream_pos;      /* how much have we read... */

 

    int buffer_start;           /* where the buffer starts */

    int buffer_end;             /* where the buffer ends */

 

    char *http_version;         /* HTTP/?.? of req */

    int response_status;        /* R_NOT_FOUND etc. */

 

    char *if_modified_since;    /* If-Modified-Since */

    time_t last_modified;       /* Last-modified: */

 

    char local_ip_addr[NI_MAXHOST]; /* for virtualhost */

 

    /* CGI vars */

 

    int remote_port;            /* could be used for ident */

 

    char remote_ip_addr[NI_MAXHOST]; /* after inet_ntoa */

 

    int is_cgi;                 /* true if CGI/NPH */

    int cgi_status;

    int cgi_env_index;          /* index into array */

 

    /* Agent and referer for logfiles */

    char *header_user_agent;

    char *header_referer;

 

    int post_data_fd;           /* fd for post data tmpfile */

 

    char *path_info;            /* env variable */

    char *path_translated;      /* env variable */

    char *script_name;          /* env variable */

    char *query_string;         /* env variable */

    char *content_type;         /* env variable */

    char *content_length;       /* env variable */

 

    struct mmap_entry *mmap_entry_var;

 

    struct request *next;       /* next */

    struct request *prev;       /* previous */

 

    /* everything below this line is kept regardless */

    char buffer[BUFFER_SIZE + 1]; /* generic I/O buffer */

    char request_uri[MAX_HEADER_LENGTH + 1]; /* uri */

    char client_stream[CLIENT_STREAM_SIZE]; /* data from client - fit or be hosed */

    char *cgi_env[CGI_ENV_MAX + 4];             /* CGI environment */

 

#ifdef ACCEPT_ON

    char accept[MAX_ACCEPT_LENGTH]; /* Accept: fields */

#endif

};

 

typedef struct request request;

 

int main (int argc, char **argv)

{

    void   (*child_func)(request *req,int *pipes,int use_pipes);

    request *req;

    int     *pipes;

    int     use_pipes;

 

    child_func  = (void *)   atoi(argv[0]);

    req         = (request *)atoi(argv[1]);

    pipes       = (int *)    atoi(argv[2]);

    use_pipes   = *((int *)  atoi(argv[3]));

    child_func(req,pipes,use_pipes);

 

    return  (0);

}

2)編譯生成boa_cgi_child_func可執行文件,利用FTP工具上傳到目標機/etc/boa目錄下。

2.8 測試Boa服務器功能

2.8.1 不包含cgic庫的CGI程序

1) index.html網頁

<html>

<head><title>CGI登陸</title></head>

<body>

<form name="login" action="./cgi-bin/login.cgi">姓名:<input type="text" name="name" />

<br/>密碼:<input type="password" name="pwd" />

<br/>確定:<input type="submit" value="登陸" />

</form>

</body>

</html>

2) test.c CGI測試程序代碼

#include<stdio.h>

#include<stdlib.h>

int main()

{

char *date;

char name[50],pwd[20];

printf("content-type:text/html;charset=gb2312\n\n");

printf("<TITLE>登陸結果</TITLE>");

printf("<H3>登陸結果</h4>");

date=getenv("QUERY_STRING");

if(date==NULL)

printf("<p>錯誤:數據沒有被輸入或數據傳輸發生錯誤</p>");

else

{

sscanf(date,"name=%[^&]&pwd=%s",name,pwd);

printf("<p>name=%s</p>",name);

printf("<p>pwd=%s</p>",pwd);

printf("%s",date);

}

return 0;

}

3) 操作流程

a) 將index.html拷貝到先前我們創建的/var/www目錄下;

b) 在IDE中新建boa_test應用工程,生成測試CGI程序:boa_test;

c) 將boa_test拷貝到/var/www/cgi-bin目錄下

d) 執行./boa_sylixos

e) 在瀏覽器地址欄輸入http://192.168.7.32/index.html,產生如圖 2-3所示。

SylixOS移植Boa服務器

圖 2-3 index.html登陸界面

f) 在姓名和密碼欄分別輸入相應值,點擊登陸按鈕,進入如圖 24所示界面。

                     SylixOS移植Boa服務器                             

圖 2-4 CGI響應程序執行

2.8.2 包含cgic庫的CGI程序

1) 操作流程

g) 從CGI官網(http://www.boutell.com/cgic/)上下載cgic庫文件;

h) 在RealEvo IDE中創建boa_cgictest應用工程;

i) 把cgic.h、cgic.c、cgictest.c 拷貝到工程boa_cgictest源碼文件所在的目錄src下,然后編譯生成boa_cgictest文件,并將之上傳到目標機/var/www/cgi-bin目錄下;

j) 執行./boa_sylixos

k) 在瀏覽器地址欄輸入http://192.168.7.32/cgi-bin/boa_cgictest,效果如圖 25所示。

SylixOS移植Boa服務器

圖 25 CGI響應程序執行

可以看到一個網頁被展示出來。這樣,包含cgic庫的的CGI程序就運行起來了。

3. 參考資料

1) http://blog.chinaunix.net/uid-20620288-id-3139686.html

2) http://blog.csdn.net/manchestermi/article/details/50826129

 

本文題目:SylixOS移植Boa服務器
新聞來源:http://vcdvsql.cn/article46/gjoseg.html

成都網站建設公司_創新互聯,為您提供云服務器定制開發微信小程序商城網站品牌網站建設響應式網站

廣告

聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯

成都定制網站建設