在 Ubuntu 上安装 Apache2 非常简单,按照以下步骤操作即可:
sudo apt update
sudo apt install apache2
sudo systemctl start apache2
sudo systemctl enable apache2
sudo systemctl status apache2
看到 active (running) 就说明成功了。
允许 HTTP 和 HTTPS 流量:
sudo ufw allow 'Apache Full'
在浏览器访问:
http://localhost
或服务器 IP:
http://你的服务器IP
看到 Apache2 Ubuntu Default Page 就说明 OK 了。
sudo systemctl stop apache2
sudo systemctl restart apache2
sudo systemctl reload apache2
默认网页目录在:
/var/www/html
如果你是想搭 PHP / MySQL 环境,或者做虚拟主机配置,也可以继续问我。