下图:笔记本电脑是服务器,台式机是客户端:
步骤:
1. 在Ubuntu Server20.04端安装Apache2服务:sudo apt-get install apache2
2. 进入Apache2目录: cd /etc/apache2
3. 输入命令 : sudo vim apache2.conf (配置文件)
4. 在配置文件最后一行输入: ServerName localhost 存盘退出
5. 启动Apache服务: sudo /etc/init.d/apache2 start
启动成功显示:starting apache2 (via systemctl):apache2.service
6. 查看apache服务的进程: ps aux | grep apache
7. 查看apache安装路径: whereis apache2
8. 在Ubuntu Server20.04端安装w3m浏览器:sudo apt-get install w3m w3m-img -y
9. 验证w3m服务是否安装成功: w3m http://www.baidu.com
安装成功,则显示百度的字符界面
10. 网页的默认路径为: /var/www/html/, 也默认路径http://localhost:80
11. 先在Ubuntu Server20.04端验证网页能否打开: w3m http://localhost:80/index.html
12. 拷贝一个简单网站(网站文件夹gouwu)到U盘上,将U盘挂载Ubuntu Server20.04;
挂载方法: mkdir /mnt/usb
sudo mount /dev/sdc1 /mnt/usb 即将U盘(sdc1)挂载到usb目录上
cd /mnt/usb
cp -r gouwu /var/www/html 将网站gouwu复制到服务器端的 /var/www/html目录下
13. 在windows客户端,浏览器:http://192.168.1.10:80/gouwu/gouwu3/gouwu3.html 即可打开服务器端的网站,如下图所示: