1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Vagrant上のUbuntu16.04 Desktop環境でSwift Vapor開発

Posted at

iOSアプリ開発のための言語と思っていたSwiftで何とWebアプリケーションが開発出来るそうで、ひとまず環境を構築してみました。
以前構築したこの環境を使いました。

OS: Ubuntu16.04
Swift: 4.2.3
Vapor: 3.3.0

vagrant環境に接続して、ひたすらコマンドです。


sudo su -
cd /tmp
apt-get update
apt-get install -y clang libpython2.7 libxml2
wget https://swift.org/builds/swift-4.2.3-release/ubuntu1604/swift-4.2.3-RELEASE/swift-4.2.3-RELEASE-ubuntu16.04.tar.gz
tar zxfv swift-4.2.3-RELEASE-ubuntu16.04.tar.gz
mkdir /usr/local/swift
mv swift-4.2.3-RELEASE-ubuntu16.04 /usr/local/swift/
ln -s /usr/local/swift/swift-4.2.3-RELEASE-ubuntu16.04/usr/bin/swift /usr/local/bin/swift
swift --version
  Swift version 4.2.3 (swift-4.2.3-RELEASE)
  Target: x86_64-unknown-linux-gnu
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
apt-get update
apt-get install -y swift vapor

vapor --helpで下記が表示されればインストール済み。


Usage: vapor command

Join our team chat if you have questions, need help,
or want to contribute: http://vapor.team

Commands:
       new Creates a new Vapor application from a template.
           Use --template=repo/template for github templates
           Use --template=full-url-here.git for non github templates
           Use --web to create a new web app
           Use --auth to create a new authenticated API app
           Use --api (default) to create a new API
     build Compiles the application.
       run Runs the compiled application.
     fetch Fetches the application's dependencies.
    update Updates your dependencies.
     clean Cleans temporary files--usually fixes
           a plethora of bizarre build errors.
      test Runs the application's tests.
     xcode Generates an Xcode project for development.
           Additionally links commonly used libraries.
   version Displays Vapor CLI version
     cloud Commands for interacting with Vapor Cloud.
    heroku Commands to help deploy to Heroku.
  provider Commands to help manage providers.

Use `vapor command --help` for more information on a command.

あとはrootユーザは抜けて、プロジェクト作成です。


mkdir webapps
cd webapps/
vapor new web_blank

vapor_prj_create.png

続いて


cd web_blank
vapor build
vapor run serve

まで実行して、localhost:8080にアクセスします。
Screenshot from 2019-03-18 11-57-58.png

OK!

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?