在搬瓦工VPS上安装 Swift 和他的依赖:修订间差异
来自md5.pw
更多语言
更多操作
安装 Swift, Install Swift |
无编辑摘要 |
||
| (未显示2个用户的5个中间版本) | |||
| 第2行: | 第2行: | ||
安装 Swift 并在服务器上进行编译要求 VPS: | 安装 Swift 并在服务器上进行编译要求 VPS: | ||
- Ubuntu 24.04 <br> | - Ubuntu 24.04 或 22.04(不建议使用更低的版本)<br>- RAM 内存 >= 2GB <br>- vCPU >= 2 | ||
- RAM 内存 >= 2GB <br> | |||
- vCPU >= 2 | |||
当RAM内存过低时容易出现编译失败,详情参考: | |||
[https://github.com/vapor/toolbox/issues/382 vapor/toolbox/issues/382] <br> | [https://github.com/vapor/toolbox/issues/382 vapor/toolbox/issues/382] <br>[https://github.com/vapor/vapor/issues/2722 vapor/vapor/issues/2772] | ||
[https://github.com/vapor/vapor/issues/2722 vapor/vapor/issues/2772] | |||
== | == 2. 安装 == | ||
==== 2.1 安装 Swift ==== | |||
curl -O https://download.swift.org/swiftly/linux/swiftly-$(uname -m).tar.gz && \ tar zxf swiftly-$(uname -m).tar.gz && \ ./swiftly init --quiet-shell-followup && \ . "${SWIFTLY_HOME_DIR:-$HOME/.local/share/swiftly}/env.sh" && \ hash -r | Swift 现在提供了一个便捷的安装工具(Swiftly):<syntaxhighlight lang="bash"> | ||
curl -O https://download.swift.org/swiftly/linux/swiftly-$(uname -m).tar.gz && \ | |||
tar zxf swiftly-$(uname -m).tar.gz && \ ./swiftly init --quiet-shell-followup && \ | |||
. "${SWIFTLY_HOME_DIR:-$HOME/.local/share/swiftly}/env.sh" && \ | |||
hash -r | |||
</syntaxhighlight> | |||
安装完成后,使用 swiftly 查看: <syntaxhighlight lang="bash"> | |||
swiftly --version | |||
</syntaxhighlight> | |||
输出版本号(类似: 1.1.1 ) 即为安装成功。 | |||
==== 2.2 安装必要的一些依赖包 ==== | |||
依赖包的获取方式可以在官方提供的 Dockerfile 中查看: | |||
例如:[https://github.com/swiftlang/swift-docker/blob/main/6.3/ubuntu/24.04/Dockerfile ubuntu-24.04/Dockerfile] | |||
安装完 | 可以看到:<syntaxhighlight lang="dockerfile"> | ||
export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true && apt-get -q update && \ | |||
apt-get -q install -y \ | |||
binutils \ | |||
git \ | |||
unzip \ | |||
gnupg2 \ | |||
libc6-dev \ | |||
libcurl4-openssl-dev \ | |||
libedit2 \ | |||
libgcc-13-dev \ | |||
libpython3-dev \ | |||
libsqlite3-0 \ | |||
libstdc++-13-dev \ | |||
libxml2-dev \ | |||
libncurses-dev \ | |||
libz3-dev \ | |||
pkg-config \ | |||
tzdata \ | |||
</syntaxhighlight>这个就是我们需要安装的依赖包。直接复制在终端运行即可。 | |||
运行完毕后,至此就已全部完成:Swift 安装以及必要依赖包安装。 | |||
[[index.php?title=Category:500 常见应用指南 — Application Guides]] | |||
[[Category:500 常见应用指南 — Application Guides]] | |||
2026年4月15日 (三) 15:11的最新版本
1. 前置要求
安装 Swift 并在服务器上进行编译要求 VPS:
- Ubuntu 24.04 或 22.04(不建议使用更低的版本)
- RAM 内存 >= 2GB
- vCPU >= 2
当RAM内存过低时容易出现编译失败,详情参考:
2. 安装
2.1 安装 Swift
Swift 现在提供了一个便捷的安装工具(Swiftly):
curl -O https://download.swift.org/swiftly/linux/swiftly-$(uname -m).tar.gz && \
tar zxf swiftly-$(uname -m).tar.gz && \ ./swiftly init --quiet-shell-followup && \
. "${SWIFTLY_HOME_DIR:-$HOME/.local/share/swiftly}/env.sh" && \
hash -r
安装完成后,使用 swiftly 查看:
swiftly --version
输出版本号(类似: 1.1.1 ) 即为安装成功。
2.2 安装必要的一些依赖包
依赖包的获取方式可以在官方提供的 Dockerfile 中查看:
可以看到:
export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true && apt-get -q update && \
apt-get -q install -y \
binutils \
git \
unzip \
gnupg2 \
libc6-dev \
libcurl4-openssl-dev \
libedit2 \
libgcc-13-dev \
libpython3-dev \
libsqlite3-0 \
libstdc++-13-dev \
libxml2-dev \
libncurses-dev \
libz3-dev \
pkg-config \
tzdata \
这个就是我们需要安装的依赖包。直接复制在终端运行即可。
运行完毕后,至此就已全部完成:Swift 安装以及必要依赖包安装。 index.php?title=Category:500 常见应用指南 — Application Guides