一、apache的移植
从 上下载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 DocumentRoot "/usr/local/apache_arm/htdocs" <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory "/usr/local/apache_arm/htdocs"> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny Allow from all </Directory> <IfModule mod_userdir.c> UserDir public_html </IfModule> <IfModule mod_dir.c> DirectoryIndex index.html DirectoryIndex index.php DirectoryIndex index.php3 DirectoryIndex index.phtml </IfModule> AccessFileName .htaccess <Files ~ "^\.ht"> Order allow,deny Deny from all Satisfy All </Files> UseCanonicalName On <IfModule mod_mime.c> TypesConfig /usr/local/apache_arm/conf/mime.types </IfModule> DefaultType text/plain <IfModule mod_mime_magic.c> MIMEMagicFile /usr/local/apache_arm/conf/magic </IfModule> 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 <IfModule mod_alias.c> Alias /icons/ "/usr/local/apache_arm/icons/" <Directory "/usr/local/apache_arm/icons"> Options Indexes MultiViews AllowOverride None Order allow,deny Allow from all </Directory> Alias /manual/ "/usr/local/apache_arm/htdocs/manual/" <Directory "/usr/local/apache_arm/htdocs/manual"> Options Indexes FollowSymlinks MultiViews AllowOverride None Order allow,deny Allow from all </Directory> ScriptAlias /cgi-bin/ "/usr/local/apache_arm/cgi-bin/" ScriptAlias /php4/ "/usr/local/php_arm/bin/" <Directory "/usr/local/apache_arm/cgi-bin"> AllowOverride None Options None Order allow,deny Allow from all </Directory> </IfModule> <IfModule mod_autoindex.c> 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 </IfModule> <IfModule mod_mime.c> 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 <IfModule mod_negotiation.c> LanguagePriority en da nl et fr de el it ja kr no pl pt pt-br ru ltz ca es sv tw </IfModule> AddType application/x-tar .tgz AddType application/x-httpd-php .php3 AddType application/x-httpd-php .php AddType application/x-httpd-php .phtml AddEncoding x-compress .Z AddEncoding x-gzip .gz .tgz </IfModule> Action application/x-httpd-php "/php4/php" <IfModule mod_setenvif.c> 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 </IfModule>然后还需要添加用户,修改开机启动文件。具体过程如下
[cpp]
kwrite /nfsroot/rootfs/etc/passwd /* 在最后添加以下内容 */ root::0:0:root:/:/bin/ash nobody::65534:65533:nobody:/:/bin/ash kwrite /nfsroot/rootfs/etc/group /* 在最后添加以下内容 */ nobody::65533: nogroup::65534:nobody root::0: users::100: /* 添加开机启动 */ kwrite /nfsroot/rootfs/etc/init.d/rcS /* 在最后添加以下内容 */ cd /usr/local/apache_arm/bin ./apachectl start echo " " > /dev/tty1 echo "Starting Apache..." > /dev/tty1 sleep 1