1 下载
下载最新版本源码包,下载地址:http://www.acme.com/software/thttpd/,本文以 thttpd-2.26.tar.gz 版本为例,点击如下链接下载。
2 解压
$ mkdir ~/thttpd
$ cp thttpd-2.26.tar.gz ~/thttpd
$ cd ~/thttpd
$ tar xzf thttpd-2.26.tar.gz
$ cd thttpd-2.26/
命令中的“~”表示当前用户目录,比如在 Linux 主机上工作的用户是:veryarm,那么命令中的“~”就代表路径:/home/veryarm/目录。
3 配置
$ CC=/usr/bin/arm-linux--gnueabi--gcc ./configure
4 编译
$ make # 编译
make 后,当前目录下会生成文件:thttpd ,同样我们还需要用到 contrib/redhat-rpm/thttpd.conf 文件。
5 复制文件
将生成的 thttpd 复制到目标板 /usr/sbin 目录,thttpd.conf 复制到目标板 /etc 目录,并添加 thttpd 为可执行:
$ cp thttpd /usr/sbin # 复制执行文件到目标板
$ cp thttpd.conf /etc/ # 复制配置文件到目标板
$ chmod +x /usr/sbin/thttpd # 添加可执行权限
6 配置
使用 vi 打开 thttpd.conf 文件,并进行配置,如下配置我们仅将“user=httpd”改为“user=root”:
# This section overrides defaults
dir=/home/httpd/html
chroot
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
# nothrottles
# host=0.0.0.0
# charset=iso-8859-1
再在目标板上新建 /home/httpd 和 /home/httpd/html 两个目录,并修改权限为755:
$ mkdir /home/httpd /home/httpd/html
$ chmod 755 /home/httpd
$ chmod 755 /home/httpd/html
切换到 /home/httpd/html 目录下,并新建一个 index.html 文件。
$ cd /home/httpd/html
$ vi index.html
内容为:
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>VeryARM Home Page</title>
</head>
<body>
<h1>Hello VeryARM Visitor!</h1>
<p>We are coming from one world, welcome here!</p>
</body>
</html>
保存退出,然后将 index.html权限改为 644:
$ chmod 644 index.html
7 开启thttpd
配置完之后,在目标板上打开 thttpd,命令:
thttpd -D -C /etc/thttpd.conf &
或thttpd和thttpd,conf在opt
/usr/local/thttpd/sbin/thttpd -C /usr/local/thttpd/conf/thttpd.conf
注意,后面还有一个 &。如果要让 thttpd 开机启动,可以将该命令添加到 /etc/profile 或者 rc.local 文件最后。
8 访问服务器
在浏览器上输入目标板的 IP 地址,就可以看到内容了:
参考链接:
https://blog.csdn.net/yaopingcs/article/details/4480224