中文
VPS/VDS 主机

在 Windows VPS 上安装 Chocolatey

使用 PowerShell 安装 Chocolatey 包管理器,便于命令行快速安装 Git、7-Zip、Node.js 等工具。

约 1 分钟阅读

Chocolatey 是 Windows 的包管理器,在 VPS 上很实用:通过命令行安装或更新软件,无需逐个点击多个安装程序。

前提条件

  • Windows Server 或较新的 Windows
  • 以管理员身份运行的 PowerShell
  • 允许运行安装脚本的执行策略(见下文)

允许运行脚本(当前会话)

打开 PowerShell(管理员):

PowerShell
Set-ExecutionPolicy Bypass -Scope Process -Force

安装 Chocolatey

仍以管理员身份运行官方命令(更新请参阅 chocolatey.org/install):

PowerShell
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072 iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

关闭并重新打开 PowerShell,然后验证:

PowerShell
choco -v

安装示例

PowerShell
choco install git -y choco install 7zip -y choco install vscode -y

升级所有 Chocolatey 软件包:

PowerShell
choco upgrade all -y

最佳实践

  • 在非交互式服务器部署中使用 -y。
  • 只安装所需的软件,以减少攻击面。
  • 为生产环境记录版本,并测试升级。

我们的 Windows VPS 提供相同的 8 个机房位置:法国 Windows VPS、德国 Windows VPS、荷兰 Windows VPS、英国 Windows VPS、美国 Windows VPS、加拿大 Windows VPS、土耳其 Windows VPS 和 香港 Windows VPS。同时也提供桌面版本:Windows 10 RDP 和 Windows 11 RDP。

故障排查

  • 拒绝访问:确保 PowerShell 已提升权限。
  • 企业代理:配置系统代理,或使用 Chocolatey 文档中说明的代理选项。

Chocolatey 属于第三方生态系统;安装前请在社区软件库中核实软件包的详细信息。

最新教程

及时了解最新的优惠、折扣和特别促销活动。

查看促销

我们使用Cookie

我们使用 Cookie 来衡量和改进本网站。 隐私政策