Migrate goahead 2.5 embedded web server to 2440 + linux

Source: Internet
Author: User
Document directory
  • 1. Introduction to the GoAhead Web Server
  • 2. Get the goahead source code package
  • 3. goahead source code structure
  • 4. goahead's built-in help documentation
  • 5. Steps for porting A GoAhead Web server to arm-Linux
  • 6. References

Summary: describes in detail the process, steps, problems and solutions for porting goahead 2.5 to S3C2440 Linux.

Development Environment:

Host Machine: Window XP;

Virtual Machine: ubuntu9.10;

Cross Compiler: Arm-uclibc-GCC (arm-linux-gcc-4.3.2 can be compiled smoothly through)

-------------------------------------------------------------------

1. Introduction to the GoAhead Web Server

GoAhead Web server is compact and exquisite. It provides commendable performance and is especially suitable for embedded systems. Therefore, goahead is used as an embedded web server in many embedded products such as routers.

The GoAhead Web server has the following features:

  • Supports ASP;
  • Embedded Javascript, that is, ejscript;
  • Supports CGI processing in the memory;
  • Fast response. More than 65 requests can be processed per second;
  • Complies with http1.0/http1.1 standards;
  • It has a large number of extended APIs for user development;
  • SSL3.0 (Secure Sockets Layer) is supported, such as matrixssl (the latest version is matrixssl 3-2 );
  • Supports user group management;
  • Supports DAA access authentication;
  • Small memory usage. If SSL is not included, only 60 kb of memory is required. If SSL is included, KB of memory is required;
  • Web pages can be stored in ROM or file system;
  • Supports multiple operating systems, such as Linux, WinCE, and VxWorks;

The latest version is WebServer 2.5.

2. Get the goahead source code package

The address is http://www.goahead.com/products/webserver/download.aspx. the latest address is: webserver 2.5.

Note: To download the source code package, you must enter some personal information.

Decompress the package:

# Tar-xzvf webs-2-5.tar.gz

# Cd webs-2-5/

3. goahead source code structure

Go to the goahead source code directory webs-2-5/to easily understand its source code structure.

Webs-2-5/

| Various OS migration subdirectories, including Ce, ECOs, Linux, lynx, MacOSX, NW, qnx4, VxWorks, and win

| Utils: currently only webcomp. C is available, that is, web page compiler.

| Www: stores web pages

| Wwwdemo: Demo webpage with goahead, which contains some documents of goahead

| Goahead Server Source program file (C program file)

From the above we can see that goahead supports the window system. If you are interested, try porting it on a PC.

After obtaining the source code, we recommend that you use tools such as source insight to create a goahead project to facilitate code reading or querying API functions.

4. goahead's built-in help documentation

Go to the wwwdemodirectory of goaheadand find the webs25gettingstarted.pdf file. This is the help document of goahead. Before porting the file, we recommend that you check it first.

5. Steps for porting A GoAhead Web server to arm-Linux

After obtaining the source package and decompress it, now the goahead is transplanted to arm-Linux, arm refers to S3C2440, linux-2.6.30.4.

The porting steps are very simple. Basically, there will be no problems in the compilation phase, and these steps are described in many blogs on the Internet. But when I was testing the server, I encountered a problem. I couldn't open the webpage in my browser. However, the solution was finally solved. Please refer to the following description.

5.1 modify makefile

Go to the Linux directory under the goahead source code and use ue to open the MAKEFILE file.

The MAKEFILE file is the GCC compiler of the Virtual Machine by default. Therefore, specify its cross compiler. Note that the version of the cross compiler should be consistent with the cross compiler used by your file system.

Add the following information at the beginning of the makefile:

View plain
  1. Cross_compile =/usr/local/ARM-uclibc/bin/ARM-uclibc-
  2. As = $ (cross_compile)
  3. LD = $ (cross_compile) LD
  4. Cc = $ (cross_compile) GCC
  5. CPP = $ (CC)-e
  6. AR = $ (cross_compile) Ar
  7. Nm = $ (cross_compile) nm
  8. Strip = $ (cross_compile) strip
  9. Objcopy = $ (cross_compile) objcopy
  10. Objdump = $ (cross_compile) objdump

At the same time, put the statements in makefile:

View plain
  1. Matrixssldir: = $ (shell LS-D ../matrixssl-3-1 */)

Block. This is used to start SSL matrixssl. For details, refer to the instructions in the webs25gettingstarted.pdf (page8 ).

5.2 modify the Linux/Main. c file: the IP address specified in the initwebs () function

Linux/Main. c file: initwebs () function, the original program cannot correctly obtain the Server IP address; therefore, a static IP address is assigned to the server.

Modify as follows:

View plain
  1. /*
  2. * Define the local IP address, host name, default home page and
  3. * Root web directory.
  4. */
  5. /* Del by gyr 2011.09.17
  6. If (gethostname (host, sizeof (host) <0 ){
  7. Error (e_l, e_log, T ("can't get hostname "));
  8. Printf ("initwebs: Can't Get hostname. \ n"); // added by gyr 2011.09.17
  9. Return-1;
  10. }
  11. If (HP = gethostbyname (host) = NULL ){
  12. Error (e_l, e_log, T ("can't get host address "));
  13. Printf ("initwebs: Can't Get hostname... \ n"); // added by gyr 2011.09.17
  14. Return-1;
  15. }
  16. Memcpy (char *) & intaddr, (char *) HP-> h_addr_list [0],
  17. (Size_t) HP-> h_length );
  18. */
  19. Intaddr. s_addr = inet_addr (T ("192.168.1.168"); // added by gyr 2011.09.17
5.3 compile: Make clean; make

Go to the Linux directory in shell and run make clean; make to compile and pass.

After compilation, the two files are obtained in the Linux Directory: libwebs. A and webs executable files. Run the following command to view the library files that webs execution files depend on:

View plain
  1. /Usr/local/ARM-uclibc/bin/ARM-uclibc-readelf-D Webs

Among them, arm-uclibc-depends on the cross compiler you use.

The following information is displayed:

View plain
  1. Dynamic segment at offset 0xf638 contains 18 entries:
  2. Tag type name/value
  3. 0x00000001 (needed) Shared Library: [libfloat. so.1]
  4. 0x00000001 (needed) Shared Library: [libc. so.0]
  5. 0x0000000c (init) 0x8e2c
  6. 0x0000000d (fini) 0x15aa0
  7. 0x00000004 (hash) 0x8130
  8. 0x00000005 (strtab) 0x8924
  9. 0x00000006 (symtab) 0x83a4
  10. 0x0000000a (strsz) 712 (bytes)
  11. 0x0000000b (syment) 16 (bytes)
  12. 0x00000015 (Debug) 0x0
  13. Zero X 00000003 (pltgot) 0x1f704
  14. 0x00000002 (pltrelsz) 552 (bytes)
  15. 0x00000014 (pltrel) REL
  16. 0x00000017 (jmprel) 0x8c04
  17. 0x00000011 (rel) 0x8bec
  18. 0x00000012 (relsz) 24 (bytes)
  19. 0x00000013 (relent) 8 (bytes)
  20. 0x00000000 (null) 0x0

As shown above, webs depends on libc. so.0 and libfloat. so.1 check whether the lib directory in the file system contains the two dynamic files. If not, you need to obtain the two dynamic library files from the installation path of the cross compiler to the file system lib directory.

5.4 test the webs Server

Use ftp to upload the webs execution file to the target board and put it in the/mnt/webs/directory.

Note that in goahead2.5, the root directory of the web page is in the webs program .. /www or .. /wwwdemo (the-demo parameter is included when Webs is executed). For details, see Linux/main. in the c file, the code and comments of the 190 rows are displayed. Therefore, upload the WWW and wwwdemo file folders in the goahead source code directory to the/mnt/directory using FTP.

Go to the web page of the goahead server in the IE browser on the PC and enter http: // 192.168.1.168: 8080/

192.168.1.168 is the IP address of the target board, that is, the address of the goahead server. 8080 is the port number used by goahead. This is the default port number, which is defined in webs. h file.

5.4.1 Test Problems

If the Browser fails to open the home.htm webpage, the Error 404 is returned, which means:

Access Error: site or page not found

Cannot open URL

5.4.2 reasons and solutions for failing to open the webpage

After a long time, I decided to start with the source code. Finally, go to the websdefaulthandler () function in the default. c file. This function processes the default webpage.

The specific code snippet is as follows:

View plain
  1. /*
  2. * We do whitelist validation in addition to standard URL validation.
  3. * The whitelist shocould really catch anything invalid first.
  4. * If the whitelist check fails, rebuild the list and try again.
  5. * Also validate if we are not on a secure connection, but the whitelist
  6. * Entry has the SSL flag set, do not serve the page.
  7. */
  8. # Ifdef webs_whitelist_support
  9. If (rc = webswhitelistcheck (WP-> URL) <0 ){
  10. Websbuildwhitelist ();
  11. If (rc = webswhitelistcheck (WP-> URL) <0 ){
  12. Webserror (WP, 404, T ("cannot open URL "));
  13. Return 1;
  14. }
  15. }
  16. If (! (Flags & webs_secure) & (RC & whitelist_ssl )){
  17. Webserror (WP, 500, T ("HTTPS access required "));
  18. Return 1;
  19. }
  20. # Endif/* webs_whitelist_support */

The problem occurs in the above Code. My understanding is that goahead has the web page security function, that is, the web page whitelist function.

Disable macro webs_whitelist_support, recompile, and test again. OK. You can open the webpage.

 

The above is just a simple porting test. However, our ultimate goal is to port goahead to our application. In most applications, it is only a module in the application, therefore, the subsequent workload is quite large, including SSL porting.

6. References
  • Http://www.docin.com/p-67202641.html
  • Http://www.cnitblog.com/zouzheng/archive/2008/01/04/38464.html
  • Http://www.dzjs.net/html/qianrushixitong/2009/0812/3890.html
  • Http://blog.csdn.net/zyboy2000/article/details/6191266
  • Http://www.bianceng.cn/webkf/aspx/201103/25071.htm
  • Http://blog.chinaunix.net/space.php? Uid = 22982394 & Do = Blog & id = 116136
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.