分类: 嵌入式
2010-08-27 14:48:57
Linux-2.6.20
arm-linux-gcc 3.4.1
apache_1.3.39
二 配置过程
1解压、编译apache
交叉编译apache总体上需要两个步骤:
1.编译本机代码
2.利用本机代码进行交叉编译
这是因为编译apache时,需要使用编译生成的工具制作后续编译使用的头文件,交叉编译的工具没有办法在PC上运行,因此,需要借用本机编译生成的工具。假设为本机编译的apache代码已经解压缩到/home/apache-1.3.39-i586,为ARM编译的apache代码已经解压缩到/home/arm/apache-1.3.39,交叉编译器arm-linux-gcc已设缺省路径,具体步骤还是用命令来说明:
1.编译本机代码
# tar xvzf apache_1.3.39.tar.gz
# cd /home /apache-1.3.39-i586
# ./configure
# make
因为仅仅是借用下本机代码,所以不用设置配置参数,得到需要的工具,
等编译完成后,就可以配置交叉编译的apache了。
apache的安装位置为/usr/local/apache
2.利用本机代码进行交叉编译
# cd /home/arm/apache-1.3.39
# CC=arm-linux-gcc ./configure --prefix=/usr/local/apache
会出来这样的提示,因为交叉编译的生成的testfunc这个工具不能在PC上执行,但可以不理会它
./helpers/TestCompile: line 294: /home/lxz/apache-1.3.39/src/helpers/testfunc: cannot execute binary file
修改Makefile:
打开/home/arn/apache-1.3.39/src/main/Makefile这个文件,找到这两段代码
uri_delims.h: gen_uri_delims
./gen_uri_delims >uri_delims.h
test_char.h: gen_test_char
./gen_test_char >test_char.h
修改为
uri_delims.h: gen_uri_delims
/home/ apache-1.3.39-i586/src/main/gen_uri_delims >uri_delims.h
test_char.h: gen_test_char
/home/apache-1.3.39-i586/src/main/gen_test_char >test_char.h
这里借用了刚才编译生成的本机代码里的工具,然后
# make
# make install
这就编译好了!
需要配置apache/conf/httpd.conf 来设置服务器的功能;(详细配置在下边)
3 移植到rootfs中
由于配置apache的时候“prefix”参数指定的安装位置是/usr/local/apache,所以制作好的文件在/usr/local/apache,将apache拷贝到rootfs中的usr/local/apache中
#cp –r apache rootfs/usr/local/apache
接下来还必须在rootfs上建立nobody用户和nogroup组,因为apache拒绝使用root用户运行。具体来说就是在ARM Linux根文件系统上建立/etc/passwd和/etc/group两个文件,它们的内容可以如下:
/etc/passwd
root::0:0:root:/:/bin/ash
nobody::65534:65533:nobody:/:/bin/ash
/etc/group
nobody::65533:
nogroup::65534:nobody
root::0:
users::100:
如果rootfs中有这两个文件,那么就只需要检查一下是不是有nobody用户和nogroup组。
生成rootfs,移植到板子上;
然后就可以启动apache了
#httpd
测试:在主机上通过IE登陆板子;
查看是否成功!
注意:板子的IP 与主机的IP要在一个网段中;
提供:apache_1.3.39.tar.gz
arm-linux-gcc-3.4.1.tar.bz2
httpd.conf
ramdisk.gz(配置完整的文件系统)
配置Apache:
Conf/httpd.conf
ServerType standalone
ServerRoot "/usr/local/apache"
PidFile /usr/local/apache/logs/httpd.pid
ScoreBoardFile /usr/local/apache/logs/httpd.scoreboard
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 15
MinSpareServers 5
MaxSpareServers 10
StartServers 5
MaxClients 150
MaxRequestsPerChild 0
Port 80
User nobody
Group nobody
ServerAdmin
DocumentRoot "/usr/local/apache "
Options FollowSymLinks
AllowOverride None
UserDir public_html
DirectoryIndex index.htm
AccessFileName .htaccess
Order allow,deny
Deny from all
Satisfy All
UseCanonicalName On
TypesConfig /usr/local/apache/conf/mime.types
DefaultType text/plain
MIMEMagicFile /usr/local/apache/conf/magic
HostnameLookups Off
ErrorLog /usr/local/apache/logs/error_log
LogLevel warn
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
CustomLog /usr/local/apache/logs/access_log common
ServerSignature On
Alias /icons/ "/usr/local/apache/icons/"
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
Alias /manual/ "/usr/local/apache/htdocs/manual/"
Options Indexes FollowSymlinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
ScriptAlias /cgi-bin/ "/usr/local/apache/cgi-bin/"
AllowOverride None
Options None
Order allow,deny
Allow from all
IndexOptions FancyIndexing
AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip
AddIconByType (TXT,/icons/text.gif) text/*
AddIconByType (IMG,/icons/image2.gif) image/*
AddIconByType (SND,/icons/sound2.gif) audio/*
AddIconByType (VID,/icons/movie.gif) video/*
AddIcon /icons/binary.gif .bin .exe
AddIcon /icons/binhex.gif .hqx
AddIcon /icons/tar.gif .tar
AddIcon /icons/world2.gif .wrl .wrl.gz .vrml .vrm .iv
AddIcon /icons/compressed.gif .Z .z .tgz .gz .zip
AddIcon /icons/a.gif .ps .ai .eps
AddIcon /icons/layout.gif .html .shtml .htm .pdf
AddIcon /icons/text.gif .txt
AddIcon /icons/c.gif .c
AddIcon /icons/p.gif .pl .py
AddIcon /icons/f.gif .for
AddIcon /icons/dvi.gif .dvi
AddIcon /icons/uuencoded.gif .uu
AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl
AddIcon /icons/tex.gif .tex
AddIcon /icons/bomb.gif core
AddIcon /icons/back.gif ..
AddIcon /icons/hand.right.gif README
AddIcon /icons/folder.gif ^^DIRECTORY^^
AddIcon /icons/blank.gif ^^BLANKICON^^
DefaultIcon /icons/unknown.gif
ReadmeName README.html
HeaderName HEADER.html
IndexIgnore .??* *~ *# HEADER* README* RCS CVS *,v *,t
AddLanguage da .dk
AddLanguage nl .nl
AddLanguage en .en
AddLanguage et .ee
AddLanguage fr .fr
AddLanguage de .de
AddLanguage el .el
AddLanguage he .he
AddCharset ISO-8859-8 .iso8859-8
AddLanguage it .it
AddLanguage ja .ja
AddCharset ISO-2022-JP .jis
AddLanguage kr .kr
AddCharset ISO-2022-KR .iso-kr
AddLanguage nn .nn
AddLanguage no .no
AddLanguage pl .po
AddCharset ISO-8859-2 .iso-pl
AddLanguage pt .pt
AddLanguage pt-br .pt-br
AddLanguage ltz .lu
AddLanguage ca .ca
AddLanguage es .es
AddLanguage sv .sv
AddLanguage cs .cz .cs
AddLanguage ru .ru
AddLanguage zh-TW .zh-tw
AddCharset Big5 .Big5 .big5
AddCharset WINDOWS-1251 .cp-1251
AddCharset CP866 .cp866
AddCharset ISO-8859-5 .iso-ru
AddCharset KOI8-R .koi8-r
AddCharset UCS-2 .ucs2
AddCharset UCS-4 .ucs4
AddCharset UTF-8 .utf8
LanguagePriority en da nl et fr de el it ja kr no pl pt pt-br ru ltz ca es sv tw
AddType application/x-tar .tgz
AddEncoding x-compress .Z
AddEncoding x-gzip .gz .tgz
BrowserMatch "Mozilla/2" nokeepalive
BrowserMatch "MSIE 4\.0b2;" nokeepalive downgrade-1.0 force-response-1.0
BrowserMatch "RealPlayer 4\.0" force-response-1.0
BrowserMatch "Java/1\.0" force-response-1.0
BrowserMatch "JDK/1\.0" force-response-1.0