android busybox httpd搭建简单web服务器

安卓手机利用busybox中的httpd命令可以创建一个简单的web服务器。

我们可以在终端模拟器中输入一下命令查看httpd的使用帮助。

busybox httpd --help

1|u0_a84@cancro:/ $ busybox httpd --help

BusyBox v1.20.2-MIUI (2012-08-20 20:59:32 CST) multi-call binary.

 

Usage: httpd [-ifv[v]] [-c CONFFILE] [-p [IP:]PORT] [-u USER[:GRP]] [-r REALM] [-h HOME]

or httpd -d/-e STRING

 

Listen for incoming HTTP requests

 

        -i              Inetd mode

        -f              Don't daemonize

        -v[v]           Verbose

        -p [IP:]PORT    Bind to IP:PORT (default *:80)

        -u USER[:GRP]   Set uid/gid after binding to port

        -r REALM        Authentication Realm for Basic Authentication

        -h HOME         Home directory (default .)

        -c FILE         Configuration file (default {/etc,HOME}/httpd.conf)

        -e STRING       HTML encode STRING

        -d STRING       URL decode STRING

 

1|u0_a84@cancro:/ $ busybox httpd --help >/sdcard/111.txt

BusyBox v1.20.2-MIUI (2012-08-20 20:59:32 CST) multi-call binary.

 

Usage: httpd [-ifv[v]] [-c CONFFILE] [-p [IP:]PORT] [-u USER[:GRP]] [-r REALM] [-h HOME]

or httpd -d/-e STRING

 

Listen for incoming HTTP requests

 

        -i              Inetd mode

        -f              Don't daemonize

        -v[v]           Verbose

        -p [IP:]PORT    Bind to IP:PORT (default *:80)

        -u USER[:GRP]   Set uid/gid after binding to port

        -r REALM        Authentication Realm for Basic Authentication

        -h HOME         Home directory (default .)

        -c FILE         Configuration file (default {/etc,HOME}/httpd.conf)

        -e STRING       HTML encode STRING

        -d STRING       URL decode STRING

 

下面大家可以使用一下命令来创建一个简单的web服务器:

busybox httpd -p 8080 -h /sdcard/www/ 

命令解释:

-p 8080 是设定端口,因为没有root的手机无法使用1024一下的端口,我们这里使用了8080端口,大家也可以根据自己的爱好选择其他1024以上的端口。

-h /sdcard/www/ 是设定服务器的主目录。

 

我们在sd卡根目录下创建www文件夹,并在www文件夹中创建index.html随便编辑一些内容如

<p>Hello World!</p>

在浏览器中输入地址:http://127.0.0.1:8080 就能看到效果了。

 

PS:如何关闭这个httpd服务器?

在终端中执行ps命令查看httpd的pid

busybox ps | grep httpd

6573 httpd

使用kill命令杀死httpd的进程即可

kill 6573

来源:安卓后院 >> android busybox httpd搭建简单web服务器http://www.top139.com/diy/114.html

转载于:https://www.cnblogs.com/flycn/p/3677835.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Busybox for Android v1.20.2 Stable built by Linus Yang [Aug 12, 2012 Update] - Update to 1.20.2 stable [Features] - Tested on Android 2.1, 2.3, 4.0 and 4.1. Should be capable with all Android devices (Use at your own risk) - ELF armv5te binary (statically linked) - More suitable for Android than the prebuilt ARM binaries from busybox.net - IPv6 support, using own DNS resolver, correct user name display and more improvements for Android [Install] wget http://yangapp.googlecode.com/files/busybox-1.20.2 mv busybox-1.20.2 busybox chmod 755 busybox ./busybox --install [INSTALL_DIR] You can build by yourself from my github's project: (forked from tias/android-busybox-ndk) https://github.com/linusyang/android-busybox-ndk [Information] BusyBox v1.20.2-linusyang (2012-08-12 21:41:27 CST) multi-call binary. Copyright (C) 1998-2011 Erik Andersen, Rob Landley, Denys Vlasenko and others. Licensed under GPLv2. See source distribution for full notice. Usage: busybox [function] [arguments]... or: busybox --list[-full] or: busybox --install [-s] [DIR] or: function [arguments]... BusyBox is a multi-call binary that combines many common Unix utilities into a single executable. Most people will create a link to busybox for each function they wish to use and BusyBox will act like whatever it was invoked as. Currently defined functions: [, [[, acpid, adjtimex, ar, arp, arping, ash, awk, base64, basename, bbconfig, beep, blkid, blockdev, bootchartd, brctl, bunzip2, bzcat, bzip2, cal, cat, catv, chat, chattr, chgrp, chmod, chown, chpst, chroot, chrt, chvt, cksum, clear, cmp, comm, cp, cpio, crond, crontab, cttyhack, cut, date, dc, dd, deallocvt, depmod, devmem, df, dhcprelay, diff, dirname, dmesg, dnsd, dnsdomainname, dos2unix, dpkg, dpkg-deb, du, dumpkmap, dumpleases, echo, ed, egrep, env, envdir, envuidgid, ether-wake, expand, expr, fakeidentd, false, fbset, fbsplash, fdflush, fdformat, fdisk, fgconsole, fgrep, find, findfs, flash_lock, flash_unlock, flashcp, flock, fold, free, freeramdisk, fsck, fsck.minix, fsync, ftpd, ftpget, ftpput, fuser, getopt, grep, groups, gunzip, gzip, halt, hd, hdparm, head, hexdump, hostname, httpd, hush, hwclock, id, ifconfig, ifdown, ifup, inetd, init, inotifyd, insmod, install, ionice, iostat, ip, ipaddr, ipcalc, ipcrm, ipcs, iplink, iproute, iprule, iptunnel, kbd_mode, kill, killall, killall5, klogd, less, linuxrc, ln, loadkmap, logread, losetup, lpd, lpq, lpr, ls, lsattr, lsmod, lsof, lspci, lsusb, lzcat, lzma, lzop, lzopcat, makedevs, makemime, man, md5sum, mdev, mesg, microcom, mkdir, mkdosfs, mke2fs, mkfifo, mkfs.ext2, mkfs.minix, mkfs.reiser, mkfs.vfat, mknod, mkswap, mktemp, modinfo, modprobe, more, mount, mountpoint, mpstat, mv, nameif, nanddump, nandwrite, nbd-client, nc, netstat, nice, nmeter, nohup, nslookup, od, openvt, patch, pgrep, pidof, ping, ping6, pipe_progress, pivot_root, pkill, pmap, popmaildir, poweroff, powertop, printenv, printf, ps, pscan, pstree, pwd, pwdx, raidautorun, rdate, rdev, readlink, readprofile, realpath, reboot, reformime, renice, reset, resize, rev, rm, rmdir, rmmod, route, rpm, rpm2cpio, rtcwake, run-parts, runsv, runsvdir, rx, script, scriptreplay, sed, sendmail, seq, setconsole, setkeycodes, setlogcons, setserial, setsid, setuidgid, sh, sha1sum, sha256sum, sha512sum, showkey, slattach, sleep, smemcap, softlimit, sort, split, start-stop-daemon, stat, strings, stty, sum, sv, svlogd, swapoff, swapon, switch_root, sync, sysctl, syslogd, tac, tail, tar, tcpsvd, tee, telnet, telnetd, test, tftp, tftpd, time, timeout, top, touch, tr, traceroute, traceroute6, true, tty, ttysize, tunctl, tune2fs, ubiattach, ubidetach, ubimkvol, ubirmvol, ubirsvol, ubiupdatevol, udhcpc, udhcpd, udpsvd, umount, uname, uncompress, unexpand, uniq, unix2dos, unlzma, unlzop, unxz, unzip, uptime, usleep, uudecode, uuencode, vconfig, vi, volname, watch, watchdog, wc, wget, which, whoami, whois, xargs, xz, xzcat, yes, zcat, zcip

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值