thttpd服务器移植到ARM Linux教程

16 篇文章 1 订阅

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

 

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

往事只能回味味道

如果对你有帮助,一块钱鼓励一下

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值