1. <ul id="0c1fb"></ul>

      <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
      <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区

      RELATEED CONSULTING
      相關(guān)咨詢
      選擇下列產(chǎn)品馬上在線溝通
      服務(wù)時間:8:30-17:00
      你可能遇到了下面的問題
      關(guān)閉右側(cè)工具欄

      新聞中心

      這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
      SylixOS移植Boa服務(wù)器

      1. Boa簡介

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

      創(chuàng)新互聯(lián)建站-云計算及IDC服務(wù)提供商,涵蓋公有云、IDC機房租用、成都多線機房、等保安全、私有云建設(shè)等企業(yè)級互聯(lián)網(wǎng)基礎(chǔ)服務(wù),聯(lián)系熱線:13518219792

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

      2. SylixOS Boa移植:

      Boa采用服務(wù)器模型,因此需要編譯出服務(wù)器的可執(zhí)行程序。

      2.1 下載Boa源碼

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

                        SylixOS移植Boa服務(wù)器

                                                          

      圖 2-1 Boa解壓后的文件

      2.2 服務(wù)器工程創(chuàng)建

      在Real-Evo IDE中創(chuàng)建boa_sylixos應(yīng)用工程,刪除工程中src目錄下的boa_sylixos.c文件,導(dǎo)入源碼中的src目錄下的一系列相關(guān).c和.h文件。導(dǎo)入完成后的工程文件如圖 2-2所示。

                                                         SylixOS移植Boa服務(wù)器

                                                                

      圖 2-2 工程文件

      2.3 修改源碼文件

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

      2.4 修改boa.conf配置文件

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

      (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的設(shè)置

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

      為 :ServerName www.your.org.here

      否則會出現(xiàn)錯誤“gethostbyname::No such file or directory”

      (7)AccessLog修改

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

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

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

      2.5 編譯生成boa_sylixos可執(zhí)行文件

      編譯生成可執(zhí)行文件boa_sylixos,并將之上傳至目標(biāo)機/etc/boa目錄下;

      2.6 拷貝mime.types文件

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

      2.7 新建工程boa_cgi_child_func

      目的:實現(xiàn)Boa源碼中的fork函數(shù)功能

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

      #include

      #include

       

      #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可執(zhí)行文件,利用FTP工具上傳到目標(biāo)機/etc/boa目錄下。

      2.8 測試Boa服務(wù)器功能

      2.8.1 不包含cgic庫的CGI程序

      1) index.html網(wǎng)頁

      CGI登陸

      姓名:


      密碼:


      確定:

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

      #include

      #include

      int main()

      {

      char *date;

      char name[50],pwd[20];

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

      printf("登陸結(jié)果");

      printf("

      登陸結(jié)果

      ");

      date=getenv("QUERY_STRING");

      if(date==NULL)

      printf("

      錯誤:數(shù)據(jù)沒有被輸入或數(shù)據(jù)傳輸發(fā)生錯誤

      ");

      else

      {

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

      printf("

      name=%s

      ",name);

      printf("

      pwd=%s

      ",pwd);

      printf("%s",date);

      }

      return 0;

      }

      3) 操作流程

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

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

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

      d) 執(zhí)行./boa_sylixos

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

      SylixOS移植Boa服務(wù)器

      圖 2-3 index.html登陸界面

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

                           SylixOS移植Boa服務(wù)器                             

      圖 2-4 CGI響應(yīng)程序執(zhí)行

      2.8.2 包含cgic庫的CGI程序

      1) 操作流程

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

      h) 在RealEvo IDE中創(chuàng)建boa_cgictest應(yīng)用工程;

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

      j) 執(zhí)行./boa_sylixos

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

      SylixOS移植Boa服務(wù)器

      圖 25 CGI響應(yīng)程序執(zhí)行

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

      3. 參考資料

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

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

       


      標(biāo)題名稱:SylixOS移植Boa服務(wù)器
      URL地址:http://www.ef60e0e.cn/article/gjoseg.html
      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区
      1. <ul id="0c1fb"></ul>

        <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
        <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

        资兴市| 泽州县| 贵定县| 莫力| 鄂伦春自治旗| 南康市| 双牌县| 武清区| 呈贡县| 哈密市| 杭锦旗| 策勒县| 周宁县| 潜江市| 英山县| 汾阳市| 新闻| 镇巴县| 奉节县| 旺苍县| 娱乐| 周至县| 洞头县| 榆树市| 淮阳县| 汤原县| 灌云县| 广昌县| 宁河县| 建德市| 郑州市| 同仁县| 乾安县| 彰武县| 饶平县| 惠州市| 福清市| 铜鼓县| 甘谷县| 宝山区| 谢通门县|