Skip to content

Instantly share code, notes, and snippets.

@LinuxDevOpsGirl
Created April 10, 2020 09:52
Show Gist options
  • Save LinuxDevOpsGirl/d69b7d6d3c909d85a2fd61dc740ae34e to your computer and use it in GitHub Desktop.
Save LinuxDevOpsGirl/d69b7d6d3c909d85a2fd61dc740ae34e to your computer and use it in GitHub Desktop.
Swift and Vapor on Ubuntu 18.04
what is Swift and Vapor?
Vapor is an open source web framework written in Swift. It can be used to create RESTful APIs, web apps, and real-time applications using WebSockets. In addition to the core framework, Vapor provides an ORM, a templating language, and packages to facilitate user authentication and authorization.
##Step 1 — Installing Swift
sudo apt-get update
sudo apt-get install clang libicu-dev libpython2.7
wget https://swift.org/builds/swift-5.1.2-release/ubuntu1804/swift-5.1.2-RELEASE/swift-5.1.2-RELEASE-ubuntu18.04.tar.gz
gpg --keyserver hkp://pool.sks-keyservers.net \
--recv-keys \
'7463 A81A 4B2E EA1B 551F FBCF D441 C977 412B 37AD' \
'1BE1 E29A 084C B305 F397 D62A 9F59 7F4D 21A5 6D5F' \
'A3BA FD35 56A5 9079 C068 94BD 63BC 1CFE 91D3 06C6' \
'5E4D F843 FB06 5D7F 7E24 FBA2 EF54 30F0 71E1 B235' \
'8513 444E 2DA3 6B7C 1659 AF4D 7638 F1FB 2B2B 08C4' \
'A62A E125 BBBF BB96 A6E0 42EC 925C C1CC ED3D 1561' \
'8A74 9566 2C3C D4AE 18D9 5637 FAF6 989E 1BC1 6FEA'
wget https://swift.org/builds/swift-5.1.2-release/ubuntu1804/swift-5.1.2-RELEASE/swift-5.1.2-RELEASE-ubuntu18.04.tar.gz.sig
tar xzf swift-5.1.2-RELEASE-ubuntu18.04.tar.gz
sudo mv swift-5.1.2-RELEASE-ubuntu18.04 /usr/share/swift
echo "export PATH=/usr/share/swift/usr/bin:$PATH" >> ~/.bashrc
source ~/.bashrc
swift --version
swift
:exit
#Step 2 — Installing Vapor
sudo apt-get install software-properties-common python-software-properties
wget -q https://repo.vapor.codes/apt/keyring.gpg -O- | sudo apt-key add -
echo "deb https://repo.vapor.codes/apt $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/vapor.list
sudo apt-get update
sudo apt-get install swift vapor
#Step 3 — Create a Vapor app
vapor new demo --template=web
#Step 4 — Compile and Run the Vapor Application
cd demo
vapor build
vapor run serve
http://localhost:8080
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment