借鉴:
https://www.howtoing.com/how-to-install-the-apache-web-server-on-debian-10
第1步 - 安装Apache
sudo apt update
sudo apt install apache2
第2步 - 调整防火墙
sudo ufw app list
应该看到
...
WWW
WWW Cache
WWW Full
WWW Secure
...
我遇到:
sudo: ufw: command not found
ufw没有安装
关于ufw:
iptables可以灵活的定义防火墙规则, 功能非常强大。但是由此产生的副作用便是配置过于复杂。一向以简单易用著称Ubuntu在它的发行版中,附带了一个相对iptables简单很多的防火墙配置工具:ufw。
安装UFW:
sudo apt-get install ufw
开启/关闭防火墙 (默认设置是’disable’)
#ufw enable|disable
继续:
sudo ufw enable //这句没有是inactive
sudo ufw allow 'WWW'
sudo ufw status
应该在显示的输出中看到允许的HTTP流量:
Status: active
To Action From
-- ------ ----
OpenSSH ALLOW Anywhere
WWW ALLOW Anywhere
OpenSSH (v6) ALLOW Anywhere (v6)
WWW (v6) ALLOW Anywhere (v6)
第3步 - 检查Web服务器
sudo systemctl status apache2
应该是running
apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; disabled; vendor preset: disabled)
Active: active (running) since Sun 2020-08-23 19:51:23 CST; 13s ago
Docs: https://httpd.apache.org/docs/2.4/
Process: 7977 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
Main PID: 7988 (apache2)
Tasks: 7 (limit: 2279)
Memory: 24.7M
CGroup: /system.slice/apache2.service
├─7988 /usr/sbin/apache2 -k start
├─7989 /usr/sbin/apache2 -k start
├─7990 /usr/sbin/apache2 -k start
├─7991 /usr/sbin/apache2 -k start
├─7992 /usr/sbin/apache2 -k start
├─7993 /usr/sbin/apache2 -k start
└─7994 /usr/sbin/apache2 -k start
Aug 23 19:51:22 Debian systemd[1]: Starting The Apache HTTP Server...
Aug 23 19:51:23 Debian apachectl[7977]: AH00558: apache2: Could not reliably determine the server's fu
Aug 23 19:51:23 Debian systemd[1]: Started The Apache HTTP Server.
出错:
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; disabled; vendor preset: disabled)
Active: inactive (dead)
Docs: https://httpd.apache.org/docs/2.4/
解决:
sudo apt-get update
sudo apt-get install -y apache2
sudo service apache2 start