日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

嵌入式 boa服务器移植

發布時間:2023/12/19 编程问答 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 嵌入式 boa服务器移植 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

隨著Internet技術的興起,在嵌入式設備的管理與交互中,基于Web方式的應用成為目前的主流,這種程序結構也就是大家非常熟悉的B/S結構,即在嵌入式設備上運行一個支持腳本或CGI功能的Web服務器,能夠生成動態頁面,在用戶端只需要通過Web瀏覽器就可以對嵌入式設備進行管理和監控,非常方便實用。本節主要介紹這種應用的開發和移植工作。 用戶首先需要在嵌入式設備上成功移植支持腳本或CGI功能的Web服務器,然后才能進行應用程序的開發。 1、嵌入式Web服務器移植 由于嵌入式設備資源一般都比較有限,并且也不需要能同時處理很多用戶的請求,因此不會使用Linux下最常用的如Apache等服務器,而需要使用一些專門為嵌入式設備設計的Web服務器,這些Web服務器在存貯空間和運行時所占有的內存空間上都會非常適合于嵌入式應用場合。

典型的嵌入式Web服務器有Boa (www.boa.org),它們和Apache等高性能的Web服務器主要的區別在于它們一般是單進程服務器,只有在完成一個用戶請求后才能響應另一個用戶的請求,而無法并發響應,但這在嵌入式設備的應用場合里已經足夠了。 我們紹比較常用的Boa服務器的移植。 Boa是一個非常小巧的Web服務器,可執行代碼只有約60KB。它是一個單任務Web服務器,只能依次完成用戶的請求,而不會fork出新的進程來處理并發連接請求。但Boa支持CGI,能夠為CGI程序fork出一個進程來執行。Boa的設計目標是速度和安全,在其站點公布的性能測試中,Boa的性能要好于Apache服務器。

(1) ?虛擬機ubuntu上boa配置:

1 下載源碼

www.boa.org

解壓

# tar xzvf boa-0.94-13.tar.gz

2 編譯源代碼

進入源碼目錄的src子目錄

# cd boa-0.94.13/src

生成Makefile文件

# ./configure

在編譯之前

修改boa.c文件(第226行)注釋掉即

//DIE('"icky Linux Kernel bug!");

修改src/compat.h文件:

#define TIMEZONE_OFFSET(foo) foo##->tm_gmtoff 改為

#define TIMEZONE_OFFSET(foo) foo->tm_gmtoff

修改src/log.c:73注釋掉:

//DIE("unable to dup2 the error log");

然后運行make進行編譯,得到的可執行程序為boa,將調試信息剝去,得到的最后程序只有約60KB大小。

# make

# arm-linux-strip boa(也可不做)

3 ?配置Boa Webserver環境

Boa Webserver的配置文件是boa.conf。該文件需要被放置在/etc/boa目錄下(因為該文件的默認目錄為/src/defines.h文件的SERVER_ROOT定義, 默認目錄為/etc/boa)。如果不改變defines.h對其的定義,則需要對boa.conf 稍做修改:

a ?將boa.conf復制到/etc/boa目錄下:

# sudo mkdir /etc/boa

# sudo cp boa.conf /etc/boa

b 修改boa.conf


點擊(此處)折疊或打開


# 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


# Listen: the Internet address to bind(2) to. If you leave it out,

# it takes the behavior before 0.93.17.2, which is to bind to all

# addresses (INADDR_ANY). You only get one \"Listen\" directive,

# if you want service on multiple IP addresses, you have three choices:

# 1. Run boa without a \"Listen\" directive

# a. All addresses are treated the same; makes sense if the addresses

# are localhost, ppp, and eth0.

# b. Use the VirtualHost directive below to point requests to different

# files. Should be good for a very large number of addresses (web

# hosting clients).

# 2. Run one copy of boa per IP address, each has its own configuration

# with a \"Listen\" directive. No big deal up to a few tens of addresses.

# Nice separation between clients.

# The name you provide gets run through inet_aton(3), so you have to use dotted

# quad notation. This configuration is too important to trust some DNS.


#Listen 192.68.0.5


# User: The name or UID the server should run as.

# Group: The group name or GID the server should run as.


User 0 //改過后

Group 0 //改過后


# ServerAdmin: The email address where server problems should be sent.

# Note: this is not currently used, except as an environment variable

# for CGIs.


#ServerAdmin root@localhost


# ErrorLog: The location of the error log file. If this does not start

# with /, it is considered relative to the server root.

# Set to /dev/null if you don\'t want errors logged.

# If unset, defaults to /dev/stderr


ErrorLog /var/log/boa/error_log

# Please NOTE: Sending the logs to a pipe (\'|\'), as shown below,

# is somewhat experimental and might fail under heavy load.

# \"Usual libc implementations of printf will stall the whole

# process if the receiving end of a pipe stops reading.\"

#ErrorLog \"|/usr/sbin/cronolog --symlink=/var/log/boa/error_log /var/log/boa/error-%Y%m%d.log\"


# AccessLog: The location of the access log file. If this does not

# start with /, it is considered relative to the server root.

# Comment out or set to /dev/null (less effective) to disable

# Access logging.


AccessLog /var/log/boa/access_log

# Please NOTE: Sending the logs to a pipe (\'|\'), as shown below,

# is somewhat experimental and might fail under heavy load.

# \"Usual libc implementations of printf will stall the whole

# process if the receiving end of a pipe stops reading.\"

#AccessLog \"|/usr/sbin/cronolog --symlink=/var/log/boa/access_log /var/log/boa/access-%Y%m%d.log\"


# UseLocaltime: Logical switch. Uncomment to use localtime

# instead of UTC time

#UseLocaltime


# VerboseCGILogs: this is just a logical switch.

# It simply notes the start and stop times of cgis in the error log

# Comment out to disable.


#VerboseCGILogs


# ServerName: the name of this server that should be sent back to

# clients if different than that returned by gethostname + gethostbyname


ServerName www.rxlinux.com //改過后:直接去掉前面#即可


# VirtualHost: a logical switch.

# Comment out to disable.

# Given DocumentRoot /var/www, requests on interface \'A\' or IP \'IP-A\'

# become /var/www/IP-A.

# Example: http://localhost/ becomes /var/www/127.0.0.1

#

# Not used until version 0.93.17.2. This \"feature\" also breaks commonlog

# output rules, it prepends the interface number to each access_log line.

# You are expected to fix that problem with a postprocessing script.


#VirtualHost


# DocumentRoot: The root directory of the HTML documents.

# Comment out to disable server non user files.


DocumentRoot /www //改過后


# UserDir: The name of the directory which is appended onto a user\'s home

# directory if a ~user request is recieved.


UserDir public_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 DirectoryMaker


DirectoryIndex index.html


# DirectoryMaker: Name of program used to create a directory listing.

# Comment out to disable directory listings. If both this and

# DirectoryIndex are commented out, accessing a directory will give

# an error (though accessing files in the directory are still ok).


DirectoryMaker /usr/lib/boa/boa_indexer


# DirectoryCache: If DirectoryIndex doesn\'t exist, and DirectoryMaker

# has been commented out, the the on-the-fly indexing of Boa can be used

# to generate indexes of directories. Be warned that the output is

# extremely minimal and can cause delays when slow disks are used.

# Note: The DirectoryCache must be writable by the same user/group that

# Boa runs as.


# DirectoryCache /var/spool/boa/dircache


# KeepAliveMax: Number of KeepAlive requests to allow per connection

# Comment out, or set to 0 to disable keepalive processing


KeepAliveMax 1000


# KeepAliveTimeout: seconds to wait before keepalive connection times out


KeepAliveTimeout 10


# MimeTypes: This is the file that is used to generate mime type pairs

# and Content-Type fields for boa.

# Set to /dev/null if you do not want to load a mime types file.

# Do *not* comment out (better use


MimeTypes /dev/null //改過后


# DefaultType: MIME type used if the file extension is unknown, or there

# is no file extension.


DefaultType text/plain


# CGIPath: The value of the $PATH environment variable given to CGI progs.


CGIPath /bin:/usr/bin:/www/cgi-bin //改過后


# SinglePostLimit: The maximum allowable number of bytes in

# a single POST. Default is normally 1MB.


# AddType: adds types without editing mime.types

# Example: AddType type extension [extension ...]


# Uncomment the next line if you want .cgi files to execute from anywhere

#AddType application/x-httpd-cgi cgi


# Redirect, Alias, and ScriptAlias all have the same semantics -- they

# match the beginning of a request and take appropriate action. Use

# Redirect for other servers, Alias for the same server, and ScriptAlias

# to enable directories for script execution.


# Redirect allows you to tell clients about documents which used to exist in

# your server\'s namespace, but do not anymore. This allows you to tell the

# clients where to look for the relocated document.

# Example: Redirect /bar http://elsewhere/feh/bar


# Aliases: Aliases one path to another.

# Example: Alias /path1/bar /path2/foo


Alias /doc /usr/doc


# ScriptAlias: Maps a virtual path to a directory for serving scripts

# Example: ScriptAlias /htbin/ /www/htbin/


ScriptAlias /cgi-bin/ /www/cgi-bin/ //改過后

c 根據修改后的boa.conf創建對應的目錄或文件:

# sudo mkdir -p /www/cgi-bin

#sudo ?mkdir -p /var/log/boa

并修改權限

sudo chmod 777 /var/log/boa

在boa目錄下建error_log,access_log 文件并修改權限

#sudo chmod ?777 error_log

#sudo chmod 777 access_log

d boa測試

1 ?靜態網頁測試

在www目錄下編輯一個test.html文件:


BOA靜態網頁測試成功!


#cd ?boa-0.94.13/src

執行:

#sudo ./boa ?(一定要加sudo命令)


轉載于:https://blog.51cto.com/10495845/1707915

總結

以上是生活随笔為你收集整理的嵌入式 boa服务器移植的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。