#安裝HTTP 伺服器uhttpd <資源輕量>
opkg update
opkg install uhttpd
#設定開機自動啟動
/etc/init.d/uhttpd enable
#立即啟動網頁伺服器
/etc/init.d/uhttpd start
#把檔案傳到192.168.99.3的/www目錄
scp -O PID.html root@192.168.99.3:/www/
透過 192.168.99.3/PID.html 就可以訪問了
#安裝 Apache HTTP Server
sudo apt update
sudo apt install apache2
#調整防火牆
sudo ufw app list
你會看到類似以下的輸出:
Available applications:
Apache
Apache Full
Apache Secure
OpenSSH
Apache: 只開放 Port 80 (HTTP)。
Apache Full: 開放 Port 80 (HTTP) 和 Port 443 (HTTPS)。
Apache Secure: 只開放 Port 443 (HTTPS)。
#防火牆允許Apache Full
sudo ufw allow 'Apache Full'
#確認防火牆狀態
sudo ufw status
#如果防火牆是關閉的,你可以啟用它
sudo ufw enable
# 檢查服務狀態
sudo systemctl status apache2
要停止服務:sudo systemctl stop apache2
要啟動服務:sudo systemctl start apache2
要重啟服務:sudo systemctl restart apache2
要重新載入配置而不中斷服務:sudo systemctl reload apache2
網站的預設根目錄是
/var/www/html
你可以把你自己的網頁檔案 (例如 index.html, styles.css, script.js 等) 放到這個目錄下
設定檔目錄:
主設定檔:/etc/apache2/apache2.conf
埠監聽設定:/etc/apache2/ports.conf (定義 Apache 監聽哪些網路埠,例如 Port 80 和 Port 443)
虛擬主機設定:/etc/apache2/sites-available/ (存放可用的虛擬主機設定檔)
啟用網站設定:/etc/apache2/sites-enabled/ (指向 /etc/apache2/sites-available/ 中已啟用的設定檔)
模組設定:/etc/apache2/mods-available/ (存放可用的模組設定檔)
啟用模組設定:/etc/apache2/mods-enabled/ (指向 /etc/apache2/mods-available/ 中已啟用的設定檔)