Wednesday, October 7, 2015



Để tạo một web server có cách như:
- apache
- BusyBox (httpd)
- lighttpd
- boa

Trong bài viết này hướng dẫn tạo web server với thư viện lighttpd.

Thư viện phụ thuộc:
- zlib
- pcre
- bzip2 (may be don't need)

Xem hướng dẫn cross.


   
 export PATH=$PATH:/opt/FriendlyARM/toolschain/4.4.3/bin   
 export CROSS=arm-none-linux-gnueabi-    
 export HOST=arm-none-linux-gnueabi   
   
 DEPEND_LIB_DIR=/path/to/dependent/install    
 export CFLAGS=-I${DEPEND_LIB_DIR}/include    
 export CPPFLAGS=-I${DEPEND_LIB_DIR}/include    
 export LDFLAGS=-L${DEPEND_LIB_DIR}/lib    
 export PKG_CONFIG_PATH=${DEPEND_LIB_DIR}/lib/pkgconfig    
 export LD_LIBRARY_PATH=${DEPEND_LIB_DIR}/lib    
 export PATH=$PATH:${DEPEND_LIB_DIR}/bin:${DEPEND_LIB_DIR}/sbin   
   
   
 export PREFIX=/friendlyarm  
 ./configure --prefix=$PREFIX --host=${HOST} \  
 CC=${CROSS}gcc \  
 AR=${CROSS}ar \  
 RANLIB=${CROSS}ranlib \  
 LD=${CROSS}ld \  
 --with-bzip2=no  
   
 make  
 make install  


CREATE CONFIGURATION FILE: lighttpd.conf
 server.document-root = "/opt/nfs/www"   
 index-file.names = ( "index.html" )  
 server.port = 8080  
 mimetype.assign = (  
  ".html" => "text/html",   
  ".txt" => "text/plain",  
  ".jpg" => "image/jpeg",  
  ".png" => "image/png"   
 )  


CREATE index.html AND STORE IN /opt/nfs/www
 <html>  
      <body>  
           <h1>Hello World</h1>  
      </body>  
 </html>  

Run
 "First, check that your configuration is ok:"  
      lighttpd -t -f /opt/nfs/etc/lighttpd.conf -m /opt/nfs/lib  
   
 "Now start the server for testing:"  
      lighttpd -D -f /opt/nfs/etc/lighttpd.conf -m /opt/nfs/lib  


Leave a Reply

Subscribe to Posts | Subscribe to Comments

- Copyright © Lập trình hệ thống nhúng Linux . Powered by Luong Duy Ninh -