加入第一篇,推坑用swift寫後端(剛發展也很多坑),這是其中社群發展最快之一的框架Vapor,熟AWS跟後端的大大可以幫我改進,我拿來做我App的後端框架,有空再寫Vapor的架構Orz
- Ubuntu 16.04 as operating system
- AWS EC2 cloud instances
- Swift 3.3.1 as programming language
- Vapor 2.0 as web framework
- PostgreSQL as Database
- Proxying Vapor HTTP servers behind Nginx.
- Using Supervisor for start, stop, and restart your Vapor app.
Update the server, install auto-upgrades and a time service and finally initiate a reboot.
<script src="https://gist.github.com/conscientiousness/c5da7886660c899cfdda260dc85e0df8.js"></script>依照官網說明快速安裝, 因為有用到PostgreSQL, 如果沒安裝libpq-devcd會有編譯錯誤.
<script src="https://gist.github.com/conscientiousness/a98e1ca3ea2d72fe78186f6371c84f87.js"></script>Verify Installation
eval "$(curl -sL check.vapor.sh)"
基本安裝
sudo apt-get update
sudo apt-get install nginx
Add a rule to firewall to allow TCP connections on port 80. (Only needs to be done if firewall is enabled)
sudo ufw allow 'Nginx HTTP'
sudo ufw status
Check if Nginx is running systemctl status nginx
Change the default configuration file in /etc/nignx/sites-available so that it looks like the following snippet.
vim /etc/nginx/sites-available/default
基本安裝
sudo apt-get update
sudo apt-get install supervisor
Create a new config file for your app /etc/supervisor/conf.d/APP_NAME.conf`
sudo vim /etc/supervisor/conf.d/APP_NAME.conf
Don’t forget to replace “USER_NAME”, "APP_NAME" and directory with your setting and also update the project directory path.
<script src="https://gist.github.com/conscientiousness/8acbd8881e2aa87514961c42dd69f71b.js"></script>Load the configuration file and run "APP_NAME" in background using supervisor.
sudo supervisorctl reread
sudo supervisorctl add APP_NAME
sudo supervisorctl start APP_NAME
sudo supervisorctl status