File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -50,6 +50,27 @@ $ErrorActionPreference = 'Stop'
5050$modulePath = Join-Path $PSScriptRoot ' Manage-NginxConf.psm1'
5151Import-Module $modulePath - Force
5252
53+ # Check prerequisites
54+ if (-not (Get-Command nginx - ErrorAction SilentlyContinue)) {
55+ Write-Error " 错误: 未检测到 Nginx。此脚本需要 Nginx 才能运行。"
56+ Write-Host " 请根据您的发行版安装 Nginx:" - ForegroundColor Cyan
57+ Write-Host " Debian/Ubuntu: sudo apt update && sudo apt install -y nginx"
58+ Write-Host " RHEL/CentOS: sudo yum install -y nginx"
59+ Write-Host " Fedora: sudo dnf install -y nginx"
60+ Write-Host " Arch Linux: sudo pacman -Syu nginx"
61+ exit 1
62+ }
63+
64+ if ($BasicUser -and -not (Get-Command htpasswd - ErrorAction SilentlyContinue)) {
65+ Write-Error " 错误: 未检测到 htpasswd 工具。Basic Auth 配置需要此工具。"
66+ Write-Host " 请根据您的发行版安装工具包:" - ForegroundColor Cyan
67+ Write-Host " Debian/Ubuntu: sudo apt install -y apache2-utils"
68+ Write-Host " RHEL/CentOS: sudo yum install -y httpd-tools"
69+ Write-Host " Fedora: sudo dnf install -y httpd-tools"
70+ Write-Host " Arch Linux: sudo pacman -S apache"
71+ exit 1
72+ }
73+
5374Write-Output " 即将启用配置: $Name "
5475if (-not $RepoConfPath ) {
5576 $RepoConfPath = Join-Path (Join-Path $PSScriptRoot ' sites-available' ) (" $Name .conf" )
You can’t perform that action at this time.
0 commit comments