Chinaunix首页 | 论坛 | 博客
  • 博客访问: 185209
  • 博文数量: 20
  • 博客积分: 2010
  • 博客等级: 大尉
  • 技术积分: 405
  • 用 户 组: 普通用户
  • 注册时间: 2007-07-19 13:00
文章分类
文章存档

2011年(1)

2009年(18)

2008年(1)

我的朋友

分类: LINUX

2009-03-25 16:29:32

1 下载并解压

 

下载地址为: 我下载的是最新的2.25b

查看文件类型

[nick@localhost nick]$ file thttpd-2.25b.tar.tar

解压源码包

[nick@localhost nick]$ tar -zxvf thttpd-2.25b.tar.tar

[nick@localhost nick]$ cd thttpd-2.25b

 

2 交叉编译thttpd

 

[nick@localhost thttpd-2.25b]$ CC=arm-linux-gcc ./configure --host=arm-linux

[nick@localhost thttpd-2.25b]$ make

 

3 安装与配置

 

建立nfs服务,便于调试

 [root@ /mnt]#mount -o nolock 192.168.1.100:/home/nick/nfs /mnt/nfs

 [nick@localhost thttpd-2.25b]$cp contrib/redhat-  rpm/thttpd.conf /home/nick/nfs/

 [root@@localhost nfs]#vi thttpd.conf  

# This section overrides defaults

dir=/etc/thttpd/html  #指明WebServer存放网页的根目录路径

#chroot

#屏蔽chroot是为了运行动态编译CGI

user=root #default=nobody

logfile=/var/log/thttpd.log

pidfile=/var/run/thttpd.pid

# This section _documents_ defaults in effect

# port=80

# nosymlink# default = !chroot

# novhost

# nocgipat

cgipat=/cgi-bin/*

#声明CGI程序的目录,是以dir为根目录的路径

# nothrottles

# host=0.0.0.0

# charset=iso-8859-1

 

利用nfs服务,拷贝thttpd.conf二进制可执行文件到根文件系统/etc目录中

[root@ /mnt/nfs]#cp ./thttpd.conf  /etc

拷贝thttpd二进制可执行文件到根文件系统/usr/sbin目录中

[root@ /mnt/nfs]#cp thttpd /usr/sbin

[root@ /

拷贝thttpd二进制可执行文件到根文件系统/usr/sbin目录中

[root@ /]#mkdir /etc/thttpd

[root@ /]#mkdir /etc/thttpd/html

拷贝index.html(测试网页)二进制可执行文件到根文件系统/etc/thttpd/html目录中

[root@ /mnt/nfs]#cp index.html  /etc/thttpd/html

 

因为是动态编译所以查看一下需要的动态库

 

[nick@localhost nick]$cp /usr/local/arm/3.4.1/arm-linux/lib/ libnss_files.so.2   /home/nick/nfs

[nick@localhost nick]$cp /usr/local/arm/3.4.1/arm-linux/lib/ libnss_files-2.3.2.so  /home/nick/nfs

 

开发板上执行命令

[root@ /]# thttpd -C /etc/thttpd.conf

./thttpd: unknown user - 'root'

出现错误

[root@localhost nfs]$ cp /etc/passwd

[root@localhost nfs]$ cp /etc/shadow

[root@localhost nfs]$ cp /etc/group

[root@localhost nfs]$ kwrite passwd

root:x:0:0:root:/root:/bin/bash

nick:x:500:500:nick:/home/nick:/bin/bash

[root@localhost nfs]$ kwrite shadow

root:$1$4HvJ5La3$3cVeVSoJkHiWTIfTCJ7rb.:14317:0:99999:7:::

nick:$1$4WqHVCms$S4rswFKuPfex/3oX7SMex1:14317:0:99999:7:::

[root@localhost nfs]$ kwrite group

root:x:0:root

nick:x:500:

3个文件是从Host中拷贝来的,只留下rootnick帐号

 

[root@ /]# thttpd -C /etc/thttpd.conf

你可以在启动文件里增加thttpd的启动命令:thttpd -C /etc/thttpd.conf

Linux主机浏览器上输入开发板ip地址:

在浏览器上可以看到显示的网页

测试CGI的支持

默认配置下,thttpd不可以运行GCI(特别是动态编译的CGI程序)要想使用CGI支持功能,必须更改thttpd.conf的配置:

编写hellocgi.c程序

#vi hellocgi.c  

程序如下:

#include<stdio.h>
#include<stdlib.h>
int main(void)
{
        printf("Content-type: text/html\n\n");
        printf("\n");
        printf("CGI Output\n");
        printf("\n");
        printf("

Hello,world.

\n");
        printf("\n");
        printf("\n");
        exit(0);
}

交叉编译CGI程序

# /usr/local/arm/3.4.1/bin/arm-linux-gcc -o hellocgi  hellocgi.c

hellocgi拷贝至嵌入式板子的/var/www/cgi-bin/下,当在局域网PCIE上输入

http:// 192.168.1.10/cgi-bin/hellocgi

显示出hellocgi的网页。
网页出现 Hello,world.  移植成功!

 

本次移植的主要参考:http://blog.chinaunix.net/u1/34474/showart.php?id=486566

在这里衷心的感谢作者!

 

阅读(5330) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~