8.
安裝Nginx(非必須)
- 安裝
apt install nginx
- 觀看狀態
systemctl status nginx
- 若有
nginx.service: Failed to parse PID from file /run/nginx.pid: Invalid argument
的錯誤
mkdir /etc/systemd/system/nginx.service.d
printf "[Service]\nExecStartPost=/bin/sleep 0.1\n" > /etc/systemd/system/nginx.service.d/override.conf
systemctl daemon-reload
systemctl restart nginx
- 手動啟動
systemctl start nginx
- 自動啟動
systemctl enable nginx
- 查看版本
nginx -v
- 檢查設定是否正確
nginx -t
- 在網頁目錄建立預設網頁:
vi /var/www/html/index.html
- index.html的內容為
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
網頁已開通!
</body>
</html>
- 可開啟瀏覽器,輸入IP,試試是否OK。
http://網址或IP/