一、apache的移植
从http://www.apache.org/ 上下载apache_1.3.36.tar.gz,然后解压缩的一个目录。
使用本地的gcc编译这个版本,我用的是Fedora14上的arm-linux-gcc4.4.3,运行:./configure生成makefile文件,make 完成后,不需要make install(如果安装的话,会把pc上的apache安装到默认目录下,此处是usr/local/apache)。
创建一个新的编译arm版本的目录,然后在该目录下解压缩apache_1.3.36,转到该目录下的apache_1.3.36,运行:export CC="arm-linux-gcc"(export指定环境变量,指定交叉编译器的地址)./configure--prefix=/lusr/local/apache_arm/ --without-execstrip --enable-module=so(生成Makefile文件,--prefix指定apache安装路径默认为usr/local/apache,我们可以在后面加个后缀以示区分)
运行make 命令,这时编译会在apache_1.3.36/src/main/gen_test_char处失败,因为arm版本该程序无法在本地机器运行,你需要把前面编译的本地版本的apache_1.3.36/src/main/gen_test_char覆盖这个arm版本,然后转到arm版本的apache_1.3.36下继续make,随后编译到另一个程序apache_1.3.36/src/main/gen_uri_delims也出现相同的问题,也使用本地版本覆盖掉它,继续make,直到最后编译成功。
# make install
这就编译好了!
还需要配置apache/conf/httpd.conf 来设置服务器的功能,见下面。
移植到rootfs中,由于配置apache的时候“prefix”参数指定的安装位置是/usr/local/apache_arm,所以制作好的文件在/usr/local/apache_arm中,将apache拷贝到rootfs中的usr/local/中
# cp /usr/local/apache_arm /nfsroot/rootfs/usr/local/apache_arm / -rf
二、PHP的安装
交叉编译php同样需要两个步骤:1.编译本机代码;2.利用本机代码进行交叉编译。原因我就不重复了,假设为本机编译的php代码已经解压缩到/home/sg131971/php-4.4.8-i586,为ARM编译的php代码已经解压缩到/home/ sg131971/php-4.4.8,交叉编译器arm-linux-gcc已设缺省路径,具体步骤还是用命令来说明:
# cd /home/sg131971/php-4.4.8-i586
# ./configure
# make
在编译的同时,可以打开/home/ sg131971/php-4.4.8/configure这个文件,搜索“can not run test program while cross compiling”,会搜索到很多个这样的结果:
{echo "configure: error: can not runtest program while cross compiling" 1>&2;exit 1;}
把它们都改为
{ echo "configure: error: can not runtest program while cross compiling" 1>&2; }
这样做的目的是直接无视交叉编译测试程序错误。
# cd /home/sg131971/php-4.4.8
#CC=arm-linux-gcc ./configure--prefix=/usr/local/php_arm --host=arm-linux --target=arm-linux --enable-sockets
别以为可以编译了,还有东西要修改,打开/home/sg131971/php-4.4.8/Makefile,找到这段
install-pear-packages:$(top_builddir)/sapi/cli/php @$(top_builddir)/sapi/cli/php$(PEAR_INSTALL_FLAGS) /home/sg131971/php-4.4.8/pear/install-pear.php-d "$(peardir)" -b "$(bindir)" /home/sg131971/php-4.4.8/pear/packages/*.tar
用上我们刚才编译的本机php里的文件,把它改成
install-pear-packages: /home/sg131971/php-4.4.8-i586/sapi/cli/php @/home/sg131971/php-4.4.8-i586/sapi/cli/php$(PEAR_INSTALL_FLAGS) /home/sg131971/php-4.4.8/pear/install-pear.php -d"$(peardir)" -b "$(bindir)" /home/sg131971/php-4.4.8/pear/packages/*.tar
现在终于可以编译了
# cd /home/sg131971/php-4.4.8
# make
# make install
# exit
这样php就编译完成了。
三、Apache与PHP的配置
需要修改/nfsroot/rootfs/usr/local/apache_arm/conf/httpd.conf文件,此处我就直接将该文件贴出来来了!O(∩_∩)O~
[html]
ServerType standalone
ServerRoot "/usr/local/apache_arm"
PidFile /usr/local/apache_arm/logs/httpd.pid
ScoreBoardFile /usr/local/apache_arm/logs/httpd.scoreboard
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 15
MinSpareServers 5
MaxSpareServers 10
StartServers 5
MaxClients 150
MaxRequestsPerChild 0
User nobody
Group nobody
ServerAdmin sg131971@qq.com
ServerName www.whut.edu.cn
DocumentRoot "/usr/local/apache_arm/htdocs"
Options FollowSymLinks
AllowOverride None
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
UserDir public_html
DirectoryIndex index.html
DirectoryIndex index.php
DirectoryIndex index.php3
DirectoryIndex index.phtml
AccessFileName .htaccess
Order allow,deny
Deny from all
Satisfy All
UseCanonicalName On
TypesConfig /usr/local/apache_arm/conf/mime.types
DefaultType text/plain
MIMEMagicFile /usr/local/apache_arm/conf/magic
HostnameLookups Off
ErrorLog /usr/local/apache_arm/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_arm/logs/access_log common
ServerSignature On
Alias /icons/ "/usr/local/apache_arm/icons/"
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
Alias /manual/ "/usr/local/apache_arm/htdocs/manual/"
Options Indexes FollowSymlinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
ScriptAlias /cgi-bin/ "/usr/local/apache_arm/cgi-bin/"
ScriptAlias /php4/ "/usr/local/php_arm/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^^