免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2248 | 回复: 0
打印 上一主题 下一主题

嵌入式linux apache 移植文档 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-12-20 09:44 |只看该作者 |倒序浏览

嵌入式linux  apache 移植文档

一:综述

          Apache源于NCSAhttpd服务器,经过多次修改,成为世界上最流行的Web服务器软件之一。Apache取自“a patchy server”的读音,意思是充满补丁的服务器,因为它是自由软件,所以不断有人来为它开发新的功能、新的特性、修改原来的缺陷。Apache的特点是简单、速度快、性能稳定,并可做代理服务器来使用。

  本来它只用于小型或试验Internet网络,后来逐步扩充到各种Unix系统中,尤其对Linux的支持相当完美。Apache有多种产品,可以支持SSL技术,支持多个虚拟主机Apache是以进程为基础的结构,进程要比线程消耗更多的系统开支,不太适合于多处理器环境,因此,在一个Apache Web站点扩容时,通常是增加服务器或扩充群集节点而不是增加理器。到目前为止Apache仍然是世界上用的最多的Web服务器,市场占有率达60%左右。世界上很多著名的网站如AmazonYahoo!W3 ConsortiumFinancial Times等都是Apache的产物,它的成功之处主要在于它的源代码开放、有一支开放的开发队伍、支持跨平台的应用(可以运行在几乎所有的UnixWindowsLinux系统平台上)以及它的可移植性等方面。

  Apache web服务器软件拥有以下特性:

  支持最新的HTTP/1.1通信协议

  拥有简单而强有力的基于文件的配置过程

  支持通用网关接口

  支持基于IP和基于域名的虚拟主机

  支持多种方式的HTTP认证

  集成Perl处理模块

  集成代理服务器模块

  支持实时监视服务器状态和定制服务器日志

  支持服务器端包含指令(SSI)

  支持安全Socket(SSL)

  提供用户会话过程的跟踪

  支持FastCGI

  通过第三方模块可以支持Java Servlets

如果你准备选择Web服务器,毫无疑问Apache是你的最佳选择。

 

         本文档主要描述如何将 移植 web 服务器 apache 移植到arm 开发板上。

二:开发环境

        

内容

说明

嵌入式开发板:

ATMEL  原厂AT91SAM10 开发板

核心CPU

ATMEL  AT91SAM10

嵌入式linux 版本:

linux2.6.30

交叉编译器版本

arm-none-linux-gnueabi-gcc  version 4.2.0

主机开发环境:

VMWARE 下安装的 UBUNTU 10.04

 

 

三:移植步骤

 

参考资料: http://blogold.chinaunix.net/u2/81592/showart_1870580.html

 

1.              http://archive.apache.org/dist/httpd/ 上下载 apache1.3.39 源码

,若存到/opt/webserver目录下,

2.      PC GCC 编译 。在/opt/webserver/pc目录下解压 tar zxvf Apache1.3.39.tar.gz

3.       进入到 /opt/webserver/pc /apache1.3.39/src目录下执行 ./Configure 命令,生成Makefile文件。

4.       返回到  /opt/webserver/pc /apache1.3.39目录下,执行 ./configure命令,然后 make一下。在主机上不需要make install.因为交叉编译的时候,只需要用到主机编译的在 ../src/main 目录下生成的两个可执行文件。gen_test_char gen_uri_delims.

5.       用交叉编译环境编译。需要重新建立一个目录,如在/opt/webserver/arm目录下。然后通过 cp 命令把软件包拷贝到该目录下,解压 tar zxvf apache1.3.39.tar.gz

6.       进入到 ../src/目录下,执行

export CC=”arm-linux-gcc”

.之后在该目录下执行  ./Configure 生成Makefile文件,在这过程中,会出现错误,如:

/home/yuaf/Web/arm/apache_1.3.39/src/helpers/testfunc: 1: Syntax error: word unexpected (expecting ")")

7.       把在主机上用gcc编译过的生成的(/opt/webserver/pc /apache1.3.39/src /main目录下)  两个可执行文件gen_test_char gen_uri_delims. 覆盖arm-linux-gcc编译过的,在目录

/opt/webserver/arm /src/main下的两个文件。

8.       /opt/webserver /arm/apach1.3.39目录下,执行

  export CC=”arm-linux-gcc”

  然后 ./configure 一下,之后就是用make 命令编译整个文件,之后就是用命令

  Make install 安装此服务器了。最后提示你

  +--------------------------------------------------------+

| You now have successfully built and installed the      |

| Apache 1.3 HTTP server. To verify that Apache actually |

| works correctly you now should first check the         |

| (initially created or preserved) configuration files   |

|                                                        |

|   /usr/local/apache/conf/httpd.conf

|                                                        |

| and then you should be able to immediately fire up     |

| Apache the first time by running:                      |

|                                                        |

|   /usr/local/apache/bin/apachectl start

|                                                        |

| Thanks for using Apache.       The Apache Group        |

|                                http://www.apache.org/  |

+--------------------------------------------------------+

服务安装成功。可能在执行安装的时候,你的权限不够,得用根用户,在ubuntu下,用sudo命令获得根用户权限就行了。因为此服务程序安装在/usr/local目录下的。

9.       把在 /usr/local/下生成的目录 apache拷贝到你的开发板根文件系统的 …/usr/local/ 目录下。

10.   修改配置http.conf文件。在…/usr/local/apache/conf/ 目录下,用文本编辑器打开。

还有注意的是,apache拒绝使用root用户运行。所以你需要增加一个用户和用户组,我们可以使用 http.conf配置文件默认的用户名和用户组名,nobodynobody。具体来说就是在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组。

   关于http.conf的配置见其最后。

11.配置完之后, httpd 应用程序 拷贝到 /usr/sbin 文件夹下并 设置其为 开机自启动。 /etc/init.d/rc 文件 最后 添加 命令 httpd

      重新制作并烧写 文件系统。

制作文件系统命令:mkfs.jffs2 -l -s 0x800 -e 0x20000 -p 0x4000000 -d mtd/ -o fs-image-apache-glibc-at91.rootfs.jffs2

       重启开发板。

然后你就可以在你的浏览器下面输入你的开发板 IP地址,这样你就可以看见一个测试网页了。

 

 

 

注意 ATMEL  原厂AT91SAM10 开发板 文件系统 Angstrom-x11-image-demo-glibc-at91.rootfs.jffs2 默认 thttp  webserver 需要我们将其去掉。Thttp /etc/init.d/thttp 文件夹下,应用程序在 /usr/sbin 下,CGI 程序在 srv/www/cgi-bin 文件夹下

 

 

附录:配置http.conf,   http.conf里面的内容是:

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

Listen 0.0.0.080

Port 80

User nobody

Group nobody

ServerAdmin yuaf059@nenu.edu.cn

ServerName www.yuanfu.com

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

 

其实也就是我上面颜色地方的显示的注意一下就可以了,其它的就选用默认的就行了。

 

 

 

 

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP