转载:在Ubuntu上安装boa,非常详细

来源:互联网 发布:手机淘宝一元起拍在哪 编辑:程序博客网 时间:2024/06/06 00:22

本文转自:http://www.programmershare.com/1136324/


Boa-0.94.13 ported to uclinux arm s3c4510b process 

Being ported to Boa-0.94.13 uclinux, a few notes to share with you.
Compile a linux c system, including morphology and syntax analysis module for Linux on bison and flex. 
yacc is a grammar parser generator bison that is the GNU version of yacc and lex and yacc are tools used to construct the lexical analyzer and syntax interpreter, Lex and Yacc, you can easily construct a grammar explanations.


1 Extract the Boa-0.94.13.tar.gz, into the boa-0.94.13/src Catalog 
2 .. / configure Enter generate Makefile 
Began to make a 
Error 1: 
debian :/ home/a/boa-0.94.13/src # make 
yacc-d boa_grammar.y 
make: yacc: Command not found 
make: *** [y.tab.c] Error 127 


Solution: 
debian :/ home/a/boa-0.94.13/src # apt-get install bison
Error 2: 
debian :/ home/a/boa-0.94.13/src # make 
lex boa_lexer.l to 
make: lex: Command not found 
make: *** [lex.yy.c] Error 127
Solution: 
debian :/ home/a/boa-0.94.13/src # apt-get install flex 


Error 3: 
debian :/ home/a/sss/boa-0.94.13/src # make 
gcc-g-O2-pipe-Wall-I.-c-o util.o util.c 
util.c: 100:1: error: pasting "t" and "->" does not give a valid preprocessing token 
make: *** [util.o] Error 1 
Solution: 
Modify the src / compat.h 
Find 
# Define TIMEZONE_OFFSET (foo) foo # # -> tm_gmtoff 
Modified 
# Define TIMEZONE_OFFSET (foo) (foo) -> tm_gmtoff
Then 
debian :/ home/a/sss/boa-0.94.13/src # make clean 
debian :/ home/a/sss/boa-0.94.13/src # make


But there is a warning:
request.c: In funtion 'get_request':
request.c: 84: warning: pointer targets in passing argument 3 of 'accept' differ in signedness
Looked unhappy, it does not matter
To 84 look request.c.
int accept (int socket, struct sockaddr * address, size_t * address_len) prototype. Where the parameter type is wrong. Int to size_t on it.
debian :/ home/a/sss/boa-0.94.13/src # make 
Basically there is no problem. 
However, when running boa, running, ps this process
Solution:
Written off
if (setuid (0)! = -1) {
DIE ("icky Linux kernel bug!");
}
Can be a recompile. Generated boa tested on a PC no problem
-------------------------------------------------- --------------------
This is at the forum to share, I just started testing have not encountered .... hope to be useful
(2) modify the src / log.c
Comment out
if (dup2 (error_log, STDERR_FILENO) == -1) {
DIE ("unable to dup2 the error log");
}
As follows:
Otherwise, an error occurs:
log.c: 73 unable to dup2 the error log: bad file descriptor
(3) modify the src / boa.c
Comment out the following two sentences:
the if (passwdbuf == NULL) {
Die ("getpwuid");
}
if (initgroups (passwdbuf-> pw_name, passwdbuf-> pw_gid) == -1) {
Die ("initgroups");
}
For
# If 0
the if (passwdbuf == NULL) {
Die ("getpwuid");
}
if (initgroups (passwdbuf-> pw_name, passwdbuf-> pw_gid) == -1) {
Die ("initgroups");
}
# Endif
Otherwise, there will be of error: boa.c: 211 - getpwuid: No such file or directory
-------------------------------------------------- ---------------------------
Cross-compiler, uClinux need to use arm-elf-gcc compiler tool (kernel 2.4)
Second, with arm-elf-gcc cross compiler
Vim Makefile, modify the compiler, as follows: 
Of course, need to make sure is already installed arm-elf tools (sh arm-elf-tools-20030314.sh) 
CC = arm-elf-gcc-elf2flt 
CPP = arm-elf-gcc-E 
Save and exit. 
(2) make 
The following error 
util.c: In function `get_commonlog_time ': 
util.c: 100: structure has no member named `tm_gmtoff ' 
The first thought is to look at util.c: 100 near code 
if (use_localtime) { 
t = localtime (& CURRENT_TIME); 
= TIMEZONE_OFFSET time_offset (t); 
} Else { 
t = gmtime (& CURRENT_TIME); 
time_offset = 0; 

And do not see what the problem is. 
The Source Insight tool to find TIMEZONE_OFFSET find compat.h 
# Ifdef HAVE_TM_GMTOFF 
# Define TIMEZONE_OFFSET (foo) foo # # -> tm_gmtoff 
# Else 
The # define TIMEZONE_OFFSET (foo) timezone 
# Endif
Or this place, according to remove the # # 
Save and exit, make 
Errors and above 
Try the other way, shield util.c: 100 at the code, save and exit 
make 
Compiled successfully 
But this may be dangerous. Boa process of using the error
(I'm just guessing, but the compiler does not use tm_gmtoff error is likely to occur) 
5. Ultimate solution 
Can think about when using arm-linux-gcc compiler boa, basic normal compiled successfully, 
Use arm-ELF-gcc compiler boa error occurs, it is the most likely problem areas, must be 
Cross-compiler tool, I use the arm-elf-tools-20030314.sh 
Find arm-elf installation directory: / usr / local / arm-elf / 
The source Insight tool can search tm_gmtoff find / usr / local / arm-elf / include / time.h 
vim time.h 
Time.h: 130 of conditionally compiled code modified to "# if 1" 
Save and exit. 
Into boa-0.94.13/src directory, it is recommended to make clean 
make 
Compiled successfully (Applause)
(Note: this is only compiled successfully. Did not test)
Ported to uclinux, replace the original boa folder, the most important is to modify the makefile, boa main directory put a Makefile, Makefile.in src inside do not move, src inside the Makefile and delete their own write Makefile put inside, here is my Makefile (do not use configure production Makefile file, pass uclinux compile)
-------------------------------------------------- -
The Makefile (BOA home directory)
, EXPORT_ALL_VARIABLES.:
DIRS = src
all romfs: 
for i in $ (DIRS); do make-C $ $ i $ @ | | exit $?; done
clean: 
for i in $ (DIRS); do make-C $ $ i clean; done
-------------------------------------------------- ---
Makefile (src)
EXEC = boa 
OBJS = alias.o boa.o buffer.o cgi.o cgi_header.o config.o escape.o get.o \ 
hash.o ip.o log.o mmap_cache.o pipe.o queue.o read.o request.o \ 
response.o select.o signals.o timestamp.o util.o sublog.o y.tab.o \ 
lex.yy.o
FLTFLAGS + =-s 8192
EXTRALIBS = $ (libcrypt)
ifdef CONFIG_USER_BOA_WITH_SSL are 
CFLAGS + = $ (INCSSL)-DSERVER_SSL = 1 
EXTRALIBS + = $ (libssl) $ (libcrypto) 
endif
N style = "COLOR: # 000000"> ifdef CONFIG_USER_TINYLOGIN_SHADOWPASSWDS 
CFLAGS + =-DSHADOW_AUTH 
endif 
ifdef CONFIG_USER_OLD_PASSWORDS are 
CFLAGS + =-DOLD_CONFIG_PASSWORDS 
endif
all: $ (EXEC)
$ (EXEC): $ (OBJS) 
$ (CC) $ (LDFLAGS)-o $ @ $ (OBJS) $ (EXTRALIBS) $ (LDLIBS)-lcrypt_old
romfs: 
$ (ROMFSINST) / bin / $ (EXEC)
clean: 
-Rm-f $ (EXEC) *. Gdb *. Elf *. O
-------------------------------------------------- --------
Has finished, the compiler, there will be no transplant that error,
The following error 
util.c: In function `get_commonlog_time ': 
util.c: 100: structure has no member named `tm_gmtoff ' 
The reform have changed this sad to say I,
Try again, shielding util.c: 100 at the code, save and exit 
make user_only 
Compiled by (Applause) (This may not think)
In order to solve this problem, do not let what consequences, I looked at the source code again and found util.c: 100
if (use_localtime) { 
t = localtime (& CURRENT_TIME); 
= TIMEZONE_OFFSET time_offset (t); 
} Else { 
t = gmtime (& CURRENT_TIME); 
time_offset = 0; 
}
This variable use_localtime of useless, this place this introduction, the boa.conf
# Use local time. If it is not commented out, use local time. Commented out using UTC time 
# UseLocaltime
Generally it out with, Therefore, time_offset the TIMEZONE_OFFSET (t); direct injection out, in theory, there is no problem.
2, the compiler is passed, but the problem again, compiled uimage.rom burn on the board found boa dead, not up and running, start reading the information, start the way, how it?
Manually start the boa on the board
# Boa &
Errors
Fork: Pars ......... (sorry, the error did not remember)
(I change the fork vfork ah, how could such a mistake), looking for a half-day, finally going wrong boa.c: 138,


if (do_fork) { 
switch (fork ()) { 
case -1: 


perror ("fork"); / / only here 
Exit (1); 
break; 
case 0: 


break; 
default: 


exit (0); 
break; 

}
I found this passage is nothing more than a Background ourself, my startup script to do the work, I do not directly pay off.
After compilation, and then burn the board, testing, normal (applause). (Not normal not measured out, ha ha)
Learn together (
0 0