在 Ubuntu 上启用 Apache2(安装并启动、设置开机自启)通常按下面步骤操作:
如果还没安装:
sudo apt update
sudo apt install apache2
sudo systemctl start apache2
sudo systemctl enable apache2
sudo systemctl status apache2
看到 active (running) 就说明已经启用了。
sudo ufw allow 'Apache'
# 或
sudo ufw allow 80/tcp
在浏览器打开:
http://localhost
或服务器 IP,看到 Apache2 Ubuntu Default Page 即成功。
sudo systemctl stop apache2 # 停止
sudo systemctl restart apache2 # 重启
sudo systemctl reload apache2 # 重新加载配置
如果你是想 启用某个站点(site)或模块(module),也可以告诉我,我给你具体命令(如 a2ensite、a2enmod)。