在 Debian 系统上启动 Apache(通常指 Apache HTTP Server,服务名为 apache2),可以按下面步骤来操作。
dpkg -l | grep apache2
如果没有安装,可以先安装:
sudo apt update
sudo apt install apache2
sudo systemctl start apache2
开机自启:
sudo systemctl enable apache2
查看运行状态:
sudo systemctl status apache2
sudo service apache2 start
停止:
sudo service apache2 stop
重启:
sudo service apache2 restart
在浏览器中访问服务器 IP 或 localhost:
http://服务器IP
如果看到 Apache2 Default Page,说明启动成功。
curl http://localhost
或查看端口:
ss -lntp | grep 80
sudo netstat -tulnp | grep :80
sudo tail -n 50 /var/log/apache2/error.log
sudo apache2ctl configtest
| 功能 | 命令 |
|---|---|
| 启动 | sudo systemctl start apache2 |
| 停止 | sudo systemctl stop apache2 |
| 重启 | sudo systemctl restart apache2 |
| 重载配置 | sudo systemctl reload apache2 |
| 开机自启 | sudo systemctl enable apache2 |
| 禁用自启 | sudo systemctl disable apache2 |
如果你是在 Debian 12 / 11 / 10,或者是在 云服务器 / Docker / WSL 环境里,可以告诉我具体场景,我可以给你更精确的方案。