Date: April 2020

If you look at the official documentation and others’ blogs without success, please refer to this article.

If you do not want to toss, advise you or use Go, simple configuration, several commands to complete the configuration. You may need a whole day to make a cup of coffee.

Log in to the remote LINUX server using SSH from a Mac OS X terminal

Open the terminal in Mac, see if it is root, and if not, enter

sudo -i
Copy the code

Enter the login password of root

Connecting to the Host using SSH

SSH [email protected] password(Server password)Copy the code

Download Swift: it may take several hours: it is recommended to hang it in the background

Wget HTTP: / / https://swift.org/builds/swift-5.2.2-release/ubuntu1604/swift-5.2.2-RELEASE/swift-5.2.2-RELEASE-ubuntu16.04.tar.gzCopy the code

Download signature file (required by Apple)

wget https://swift.org/builds/swift-5.2.2-release/ubuntu1604/swift-5.2.2-RELEASE/swift-5.2.2-RELEASE-ubuntu16.04.tar.gz.sig
Copy the code

Three, installation environment (Apple needs)

sudo apt-get install clang libicu-dev
Copy the code

4. Export the key

 wget -q -O - https://swift.org/keys/all-keys.asc | gpg --import -
Copy the code

Update the key

 gpg --keyserver hkp://pool.sks-keyservers.net --refresh-keys Swift
Copy the code

Verify the signature

GPG -- verify swift - 5.2.2 - RELEASE - ubuntu16.04. Tar. Gz. SigCopy the code

Seven, decompression, need a while

Tar XZF swift - 5.2.2 - RELEASE - ubuntu16.04. Tar. GzCopy the code

8. Associate paths

exportPATH = ~ / swift - 5.2.2 - RELEASE - ubuntu16.04 / usr/bin:"${PATH}"
Copy the code

Nine, calibration

root@iZ2zeg7t7xxxx9lrZ:~# swift --versionSwift Version 5.2.2 (swift-5.2.2-release) Target: x86_64-unknown-linux-GNUCopy the code

successful

Git installation takes a few minutes or an hour

apt install git
Copy the code

It will take a few minutes to install the Toolbox

git clone https://github.com/vapor/toolbox.git
cd toolbox
git checkout master
Copy the code

If libcurl returns an error, use this

sudo apt-get install libcurl4-openssl-dev
Copy the code

then

swift build -c release --disable-sandbox
Copy the code

If something goes wrong,

error: missing LinuxMain.swift file inthe Tests directory ! [](https://p1-jj.byteimg.com/tos-cn-i-t2oaga2asx/gold-user-assets/2020/4/25/171acf03ca610177~tplv-t2oaga2asx-image.image )Copy the code

Try this: an island url, which is simply a linuxmain. swif file in the Tests directory

vim LinuxMain.swif
Copy the code

Then paste the copy with the following code:

import XCTest
@testable import MonoGeneratorTests

XCTMain([
     testCase(GeneratorTests.allTests),
])

Copy the code

This may cause a warning, so ignore it.

Other solutions:

The problem of “missing Linuxmain. swift file in the Tests directory” is caused by the lack of objective-C Runtime to dynamically link to the Tests framework. Add –enable-test-discovery to build, no need to create a new linuxmain.swif. (PS: I didn’t try) By juejin.cn/user/245376…

Then, copy to /usr/local/bin:

mv .build/release/vapor /usr/local/bin
Copy the code

Check:

vapor --help
Copy the code

Hey hey build success!

root@iZ2zeg7xxxy9lrZ:~/VaporToolbox/toolbox# vapor --help
Usage:  vapor<command> 

Vapor Toolbox (Server-side Swift web framework)

Commands:
       clean Cleans temporary files.
       xcode Opens an app in Xcode.
       build Builds an app in the console.
      heroku Commands for working with Heroku
  supervisor Commands for working with Supervisord
         new Generates a new app.
         run Runs an app from the console.

Use `vapor <command> [--help,-h]` for more information on a command.
Copy the code

Hey, hey, isn’t that interesting?

Enter: exit to disconnect the SSH link.

This section describes starting a simple Vapor server and then accessing it via IP.

Add V note: nuggets; Get into groups and learn together 🐻