Ubuntu搭建最简单WEB服务器
- 安装apache2
sudo apt install apache2
- 检查状态
$ sudo systemctl status apache2
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor prese>
Active: active (running) since Thu 2025-03-06 09:51:10 CST; 23s ago
Docs: https://httpd.apache.org/docs/2.4/
Main PID: 21202 (apache2)
Tasks: 55 (limit: 11554)
Memory: 5.6M
CPU: 624ms
CGroup: /system.slice/apache2.service
├─21202 /usr/sbin/apache2 -k start
├─21203 /usr/sbin/apache2 -k start
└─21204 /usr/sbin/apache2 -k start
3月 06 09:51:10 ubuntu22 systemd[1]: Starting The Apache HTTP Server...
3月 06 09:51:10 ubuntu22 apachectl[21201]: AH00558: apache2: Could not reliably>
3月 06 09:51:10 ubuntu22 systemd[1]: Started The Apache HTTP Server.
- 查看配置
/etc/apache2/apache2.conf
- 修改工作目录
默认/var/www/html,直接替换自己的index.html,就可以测试。
修改/etc/apache2/sites-enabled/000-default.conf
- 测试
http://localhost