ubuntu 安装 + 配置 Apache(急速版)
1、sudo apt-get install apache2
2、sudo gedit /etc/apache2/apache2.conf,gedit、vi或者vim,根据习惯和系统自己选择编辑器
#<Directory /var/www/>(原本的)
<Directory /home/wuhao/www/>(修改后自己指定的目录)
3、sudo gedit /etc/apache2/sites-available/000-default.conf
#DocumentRoot /var/www/html(原本的)
DocumentRoot /home/wuhao/www(修改后自己指定的目录)
4、sudo /etc/init.d/apache2 restart
成功: * Restarting web server apache2 [ OK ]
如果重新启动出现下面报错,执行第三步骤,再文件最后添加:ServerName 127.0.0.1
* Restarting web server apache2
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
5、测试1:
wget http://127.0.0.1
--2020-09-11 09:16:06-- http://127.0.0.1/
正在连接 127.0.0.1:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度: 4955 (4.8K) [text/html]
正在保存至: “index.html”
100%[======================================>] 4,955 --.-K/s 用时 0s
2020-09-11 09:16:06 (254 MB/s) - 已保存 “index.html” [4955/4955])
6、测试2:我的ip地址:192.168.18.121
wget http://192.168.18.121
--2020-09-11 09:17:09-- http://192.168.18.121/
正在连接 192.168.18.121:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度: 4960 (4.8K) [text/html]
正在保存至: “index.html.1”
100%[======================================>] 4,960 --.-K/s 用时 0s
2020-09-11 09:17:09 (986 MB/s) - 已保存 “index.html.1” [4960/4960])
7、测试3: