├── .gitignore ├── LICENSE.md ├── README.md └── Vagrantfile /.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | .tempvagrant 4 | .vagrant 5 | Perfect/* 6 | PerfectLibraries/* 7 | SQLiteDBs/* 8 | webroot/* 9 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Matthew Clarkson 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #Swift and Perfect Server on Linux with Vagrant 2 | 3 | ##NOTE 4 | 5 | This is no longer maintained, as I much prefer the [Vapor](https://github.com/qutheory/vapor) Swift Web Framework. 6 | 7 | ##Introduction 8 | 9 | This is `Vagrantfile` that builds a Ubuntu 15.10 virtual machine with open source [Swift](http://swift.org) and the Swift server [Perfect](https://github.com/PerfectlySoft/Perfect). 10 | 11 | I'm far from a Vagrant specialist and welcome any PRs! 12 | 13 | ##Instructions 14 | 15 | ###Installation 16 | 17 | 1. Ensure you have [Vagrant](https://www.vagrantup.com) configured. 18 | 2. Clone this repository: 19 | `git clone https://github.com/mpclarkson/perfect-swift-ubuntu` 20 | 3. Open the folder: 21 | `cd perfect-swift-linux` 22 | 4. Install the virtual machine: 23 | `vagrant up` 24 | 5. SSH into it: 25 | `vagrant ssh` 26 | 6. Start the PerfectServer: 27 | `cd /vagrant && perfectserverhttp` 28 | 29 | ###PerfectServer Examples 30 | 31 | All of the [Examples](https://github.com/PerfectlySoft/Perfect/tree/master/Examples) are built and are accessible at http://127.0.0.1:8181/ 32 | 33 | ###Swift REPL 34 | 35 | You can access the swift REPL simply by typing `swift` 36 | 37 | ##Author 38 | 39 | By [Matthew Clarkson](http://mpclarkson.github.io/) from [Hilenium](http://hilenium.com). Tweet me [@matt_clarkson](https://twitter.com/matt_clarkson) 40 | -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | Vagrant.configure("2") do |config| 2 | SWIFT_VERSION = "swift-2.2-SNAPSHOT-2016-01-06-a" 3 | 4 | # wget https://swift.org/builds/ubuntu1510/swift-2.2-SNAPSHOT-2016-01-06-a/swift-2.2-SNAPSHOT-2016-01-06-a-ubuntu15.10.tar.gz 5 | # tar -zxvf swift-2.2-SNAPSHOT-2016-01-06-a-ubuntu15.10.tar.gz &> /dev/null 6 | config.vm.define :"perfect-swift-linux" do |config| 7 | config.vm.provider "virtualbox" do |v| 8 | v.name = "perfect-swift-linux" 9 | end 10 | 11 | config.vm.box = "ubuntu/wily64" 12 | config.vm.network :forwarded_port, guest: 8181, host: 8181 13 | config.vm.provision "shell", inline: <<-SHELL 14 | 15 | echo "*** Installing dependencies ***" 16 | sudo apt-get --assume-yes install git clang libicu-dev libssl-dev libevent-dev libsqlite3-dev 17 | 18 | echo "*** Installing Swift ***" 19 | cd /home/vagrant/ 20 | echo "* Downloading "#{SWIFT_VERSION}"..." 21 | wget https://swift.org/builds/ubuntu1510/#{SWIFT_VERSION}/#{SWIFT_VERSION}-ubuntu15.10.tar.gz --progress=bar:force 22 | echo "* Unpacking swift..." 23 | tar -zxvf #{SWIFT_VERSION}-ubuntu15.10.tar.gz &> /dev/null 24 | rm -rf swift 25 | mv #{SWIFT_VERSION}-ubuntu15.10 swift 26 | 27 | echo "* Adding Swift to PATH" 28 | sudo chown -R vagrant:vagrant /home/vagrant/swift/ 29 | [ -f /home/vagrant/.profile ] || touch /home/vagrant/.profile 30 | grep 'PATH=/home/vagrant/swift/usr/bin' /home/vagrant/.profile || echo 'export PATH=/home/vagrant/swift/usr/bin:$PATH' | tee -a /home/vagrant/.profile 31 | 32 | echo "*** Downloading Perfect ***" 33 | rm -rf /vagrant/Perfect 34 | cd /vagrant && git clone https://github.com/PerfectlySoft/Perfect.git 35 | 36 | echo "* Making PerfectLib... " 37 | cd /vagrant/Perfect/PerfectLib && make && sudo make install 38 | 39 | echo "* Making PerfectServer..." 40 | cd /vagrant/Perfect/PerfectServer && make 41 | 42 | echo "* Symlinking..." 43 | sudo rm -r /usr/local/bin/perfectserverfcgi 2> /dev/null 44 | sudo ln -s /vagrant/Perfect/PerfectServer/perfectserverfcgi /usr/local/bin/perfectserverfcgi 45 | sudo rm -r /usr/local/bin/perfectserverhttp 2> /dev/null 46 | sudo ln -s /vagrant/Perfect/PerfectServer/perfectserverhttp /usr/local/bin/perfectserverhttp 47 | 48 | echo "*** Building Perfect Examples ***" 49 | echo "* Making Authenticator..." 50 | cd /vagrant/Perfect/Examples/Authenticator && make 51 | echo "* Making Tap Tracker..." 52 | cd /vagrant/Perfect/Examples/Tap\\ Tracker && make 53 | echo "* Making Upload Enumerator..." 54 | cd /vagrant/Perfect/Examples/Upload\\ Enumerator && make 55 | echo "* Making Upload Websockets Server..." 56 | cd /vagrant/Perfect/Examples/Websockets\\ Server && make 57 | echo "* Making URL Routing..." 58 | cd /vagrant/Perfect/Examples/URL\\ Routing && make 59 | 60 | echo "* Moving Libraries and Templates... " 61 | mkdir -p /vagrant/PerfectLibraries/ 62 | mkdir -p /vagrant/webroot/ 63 | find /vagrant/Perfect/Examples/ -name "*.so" | xargs -i cp {} /vagrant/PerfectLibraries/ 64 | find /vagrant/Perfect/Examples/ -name "*.mustache" | xargs -i cp {} /vagrant/webroot/ 65 | 66 | echo "*** DONE ***" 67 | SHELL 68 | end 69 | end 70 | --------------------------------------------------------------------------------