1、首先安装apache2工具
sudo apt-get update
sudo apt-get install apache2
apache2安装成功后,我们可以在/var/www/html/目录下看到一个index.html文件,我们只需要重启apache2服务,使用同一局域网的设备登录ubuntu的ip地址就能访问到它的网页页面了。
caizd@ubuntu:/home/share$ ls -l /var/www/html/index.html
-rw-r--r-- 1 root root 11510 Jun 29 19:09 /var/www/html/index.html
2、重启apache2
sudo /etc/init.d/apache2 restart
3、查看一下本机的ip地址
caizd@ubuntu:/home/share$ ifconfig
eth0 Link encap:Ethernet HWaddr 00:0c:29:ba:e0:ab
inet addr:192.168.11.137 Bcast:192.168.11.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:feba:e0ab/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:6271722 errors:0 dropped:0 overruns:0 frame:0
TX packets:4702316 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:4764352747 (4.7 GB) TX bytes:8909578315 (8.9 GB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:219 errors:0 dropped:0 overruns:0 frame:0
TX packets:219 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:16495 (16.4 KB) TX bytes:16495 (16.4 KB)
然后使用同一个局域网的PC机就可以访问这个http地址了
http://192.168.11.137/
4、如果想管理或者查看我ubuntu下面 /home/share/http_source 目录的文件,
caizd@ubuntu:/home/share/http_source$ pwd
/home/share/http_source
则需要在/var/www/html目录下建立一个文件夹软链接(管理的文件目录),
caizd@ubuntu:/var/www/html$ sudo ln -sf /home/share/http_source file
执行完sudo ln -sf /home/share/http_source file命令之后,得到如下结果:
caizd@ubuntu:/var/www/html$ sudo ln -sf /home/share/http_source file
caizd@ubuntu:/var/www/html$ ls -l
total 12
lrwxrwxrwx 1 root root 23 Jun 29 19:14 file -> /home/share/http_source
-rw-r--r-- 1 root root 11510 Jun 29 19:09 index.html
到这里,使用 http://192.168.11.137/file 就可以访问该文件夹了,也可以点击文件,直接打开文件查看,还可以通过网页进入下载文件,也可以通过wget获取http上面的文件。
5、如果想下载192.168.11.137服务器上的update_rk3399.tgz文件,可以使用以下命令,-c表示断点续传
wget -c http://192.168.11.137/file/update_rk3399.tgz ./