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
- Cross_compile =/usr/local/ARM-uclibc/bin/ARM-uclibc-
- As = $ (cross_compile)
- LD = $ (cross_compile) LD
- Cc = $ (cross_compile) GCC
- CPP = $ (CC)-e
- AR = $ (cross_compile) Ar
- Nm = $ (cross_compile) nm
- Strip = $ (cross_compile) strip
- Objcopy = $ (cross_compile) objcopy
- Objdump = $ (cross_compile) objdump
At the same time, put the statements in makefile:
View plain
- 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
- /*
- * Define the local IP address, host name, default home page and
- * Root web directory.
- */
- /* Del by gyr 2011.09.17
- If (gethostname (host, sizeof (host) <0 ){
- Error (e_l, e_log, T ("can't get hostname "));
- Printf ("initwebs: Can't Get hostname. \ n"); // added by gyr 2011.09.17
- Return-1;
- }
- If (HP = gethostbyname (host) = NULL ){
- Error (e_l, e_log, T ("can't get host address "));
- Printf ("initwebs: Can't Get hostname... \ n"); // added by gyr 2011.09.17
- Return-1;
- }
- Memcpy (char *) & intaddr, (char *) HP-> h_addr_list [0],
- (Size_t) HP-> h_length );
- */
- 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
- /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
- Dynamic segment at offset 0xf638 contains 18 entries:
- Tag type name/value
- 0x00000001 (needed) Shared Library: [libfloat. so.1]
- 0x00000001 (needed) Shared Library: [libc. so.0]
- 0x0000000c (init) 0x8e2c
- 0x0000000d (fini) 0x15aa0
- 0x00000004 (hash) 0x8130
- 0x00000005 (strtab) 0x8924
- 0x00000006 (symtab) 0x83a4
- 0x0000000a (strsz) 712 (bytes)
- 0x0000000b (syment) 16 (bytes)
- 0x00000015 (Debug) 0x0
- Zero X 00000003 (pltgot) 0x1f704
- 0x00000002 (pltrelsz) 552 (bytes)
- 0x00000014 (pltrel) REL
- 0x00000017 (jmprel) 0x8c04
- 0x00000011 (rel) 0x8bec
- 0x00000012 (relsz) 24 (bytes)
- 0x00000013 (relent) 8 (bytes)
- 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
- /*
- * We do whitelist validation in addition to standard URL validation.
- * The whitelist shocould really catch anything invalid first.
- * If the whitelist check fails, rebuild the list and try again.
- * Also validate if we are not on a secure connection, but the whitelist
- * Entry has the SSL flag set, do not serve the page.
- */
- # Ifdef webs_whitelist_support
- If (rc = webswhitelistcheck (WP-> URL) <0 ){
- Websbuildwhitelist ();
- If (rc = webswhitelistcheck (WP-> URL) <0 ){
- Webserror (WP, 404, T ("cannot open URL "));
- Return 1;
- }
- }
- If (! (Flags & webs_secure) & (RC & whitelist_ssl )){
- Webserror (WP, 500, T ("HTTPS access required "));
- Return 1;
- }
- # 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