完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
` 【创龙AM4379 Cortex-A9试用体验】之移植boa到TL-4379+WEB远程操作开发板 TL-4379开发板,出厂时已实现了基于ligththttpd的WEB服务,而对于嵌入式系统来讲,多数情况下是使用boa这个各方面性能更好的WEB服务承载工具,这篇使用报告,我们介绍一下将boa移植到TL-4379开发板,实现通过PC或移动终端浏览器访问TL-4379的软硬件资源。 1. 移植boa 1.1 下载boa源码 从http://www.boa.org/下载Boa源码,得到boa-0.94.13.tar.gz文件,通过VMWare工具拷贝到Ubuntu虚拟机,执行解压命令: tar -zxvf boa-0.94.13.tar.gz 执行结果如图所示: 1.2 安装必要的工具 由于我们安装的Ubuntu虚拟机,部分依赖库没有安装,我这里需要提前安装,否则在交叉编译boa时,会报错,报错信息如图所示: sudo apt-get install bison 执行过程如图所示: sudo apt-get install flex 执行过程如图所示: 1.3 生成并修改Makefile 进入boa源码目录: cd ./boa-0.94.13/src 执行./configure命令,如图所示: 命令执行结果如图所示: 生成Makefile后,我们将Makefile中的编译工具修改Wie交叉编译工具链,修改内容如图所示: 此时,我们就可以执行make命令了,但是在执行交叉编译时,会弹出如下错误: 解决方法: 修改的内容如图所示: 经过上述步骤我们就可以完成交叉编译了。 但是在我们配置boa到TL-4379开发板时,会提示新的错误,boa无法在开发板上正常启动,所以,除了上述的修改配置外,我们还需要在src源码下修改两处: 1)log.c 将src/log.c文件中的部分如下图所示的代码注释掉: 2)boa.c 将src/boa.c文件中的如下图所示的代码注释掉: 1.4 交叉编译 经过上述的一些修改、配置之后,我们执行make命令,系统生成boa可执行文件,如下图所示: 我们查看一下文件属性,看看其是否是基于ARM的可执行文件: 最后,执行命令,缩减boa的文件大小: arm-linux-gnueabihf-strip boa 1.5 创建能够在TL-4379开发板上运行boa的配置文件 这一步完成Boa的配置,使其能够支持CGI程序的执行。Boa需要在/etc目录下建立一个boa目录,里面放入Boa的主要配置文件boa.conf。在Boa源码目录下已有一个示例boa.conf,可以在其基础上进行修改,修改后的文件内容如下所示: # Boa v0.94 configuration file # File format has not changed from 0.93 # File format has changed little from 0.92 # version changes are noted in the comments # # The Boa configuration file is parsed witha lex/yacc or flex/bison # generated parser. If it reports an error, the line number willbe # provided; it should be easy to spot. The syntax of each of these # rules is very simple, and they can occurin any order. Where possible # these directives mimic those of NCSAhttpd 1.3; I saw no reason to # introduce gratuitous differences. # $Id: boa.conf,v 1.25 2002/03/22 04:33:09jnelson Exp $ # The "ServerRoot" is not in thisconfiguration file. It can be compiled # into the server (see defines.h) orspecified on the command line with # the -c option, for example: # # boa -c /usr/local/boa # Port: The port Boa runs on. The default port for http servers is 80. # If it is less than 1024, the server mustbe 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 IPaddresses, 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 verylarge 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 trustsome DNS. #Listen 192.68.0.5 # User: The name or UID the server should run as. # Group: The group name or GID the servershould run as. User root #Group nogroup Group 0 # ServerAdmin: The email address whereserver problems should be sent. # Note: this is not currently used, exceptas an environment variable # for CGIs. #ServerAdmin root@localhost # ErrorLog: The location of the error logfile. If this does not start # with /, it is considered relative to theserver root. # Set to /dev/null if you don't want errorslogged. # If unset, defaults to /dev/stderr ErrorLog /var/log/boa/error_log # Please NOTE: Sending the logs to a pipe('|'), as shown below, # issomewhat experimental and might fail under heavy load. # "Usual libc implementations ofprintf will stall the whole # process if the receiving end of a pipe stops reading." #ErrorLog "|/usr/***in/cronolog--symlink=/var/log/boa/error_log /var/log/boa/error-%Y%m%d.log" # AccessLog: The location of the access logfile. If this does not # start with /, it is considered relativeto the server root. # Comment out or set to /dev/null (lesseffective) to disable # Access logging. AccessLog /var/log/boa/access_log # Please NOTE: Sending the logs to a pipe('|'), as shown below, # issomewhat experimental and might fail under heavy load. # "Usual libc implementations ofprintf will stall the whole # process if the receiving end of a pipe stops reading." #AccessLog "|/usr/***in/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 logicalswitch. # Itsimply notes the start and stop times of cgis in the error log # Comment out to disable. #VerboseCGILogs # ServerName: the name of this server thatshould be sent back to # clients if different than that returnedby gethostname + gethostbyname #ServerName www.your.org.here ServerName www.linuxidc.com # VirtualHost: a logical switch. # Comment out to disable. # Given DocumentRoot /var/www, requests oninterface '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 breakscommonlog # output rules, it prepends the interfacenumber to each access_log line. # You are expected to fix that problem witha postprocessing script. #VirtualHost # DocumentRoot: The root directory of theHTML documents. # Comment out to disable server non userfiles. DocumentRoot /var/www # UserDir: The name of the directory whichis appended onto a user's home # directory if a ~user request is recieved. UserDir public_html # DirectoryIndex: Name of the file to useas 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 tocreate a directory listing. # Comment out to disable directorylistings. If both this and # DirectoryIndex are commented out,accessing a directory will give # an error (though accessing files in thedirectory are still ok). DirectoryMaker /usr/lib/boa/boa_indexer # DirectoryCache: If DirectoryIndex doesn'texist, and DirectoryMaker # has been commented out, the theon-the-fly indexing of Boa can be used # to generate indexes of directories. Bewarned that the output is # extremely minimal and can cause delayswhen slow disks are used. # Note: The DirectoryCache must be writableby the same user/group that # Boa runs as. # DirectoryCache /var/spool/boa/dircache # KeepAliveMax: Number of KeepAliverequests to allow per connection # Comment out, or set to 0 to disablekeepalive processing KeepAliveMax 1000 # KeepAliveTimeout: seconds to wait beforekeepalive connection times out KeepAliveTimeout 10 # MimeTypes: This is the file that is usedto generate mime type pairs # and Content-Type fields for boa. # Set to /dev/null if you do not want toload a mime types file. # Do *not* comment out (better useAddType!) MimeTypes /etc/mime.types # DefaultType: MIME type used if the fileextension is unknown, or there # is no file extension. DefaultType text/plain # CGIPath: The value of the $PATHenvironment variable given to CGI progs. CGIPath /bin:/usr/bin:/usr/local/bin # SinglePostLimit: The maximum allowablenumber of bytes in # a single POST. Default is normally 1MB. # AddType: adds types without editingmime.types # Example: AddType type extension[extension ...] # Uncomment the next line if you want .cgifiles to execute from anywhere #AddType application/x-httpd-cgi cgi # Redirect, Alias, and ScriptAlias all havethe same semantics -- they # match the beginning of a request and takeappropriate action. Use # Redirect for other servers, Alias for thesame server, and ScriptAlias # to enable directories for scriptexecution. # Redirect allows you to tell clients aboutdocuments which used to exist in # your server's namespace, but do notanymore. This allows you to tell the # clients where to look for the relocateddocument. # Example: Redirect /barhttp://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 adirectory for serving scripts # Example: ScriptAlias /htbin/ /www/htbin/ #ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ ScriptAlias /cgi-bin/ /var/www/cgi-bin/ 2. 移植boa到TL-4379 第一节,我们交叉编译了boa,并且编写了boa.conf文件,这一节,我将把boa从Ubuntu虚拟机拷贝到TL-4379开发板。 首先将编译好的boa,boa.conf文件拷贝到NFS共享目录,如图所示: 2.1 TL-4379上电 1)给TL-4379开发板上电,并执行如下命令: mount -t nsf 192.168.1.108:/nfsshare /mnt-o nolock 2)创建必要的目录 mkdir /etc/boa mkdir /var/www mkdir /var/www/cgi-bin mkdir /var/log/boa 3)创建日志文件 cd /var/log/boa touch access_log chmod 777 access_log 2.2 拷贝文件 cp /mnt/boa /usr/local/boa cp /mnt/boa.conf /etc/boa/ 2.3 拷贝mime.types 将Ubuntu /etc下载的mime.types文件拷贝到开发板的/etc目录下。 3. 编写一个简单的静态HTML文件 编写一个简单的静态网页测试文件,如下所示: Welcome to Boa sever! |