Skip to content

Instantly share code, notes, and snippets.

@groovelab
Last active May 23, 2016 20:33
Show Gist options
  • Save groovelab/fae744207b96133ebd4a to your computer and use it in GitHub Desktop.
Save groovelab/fae744207b96133ebd4a to your computer and use it in GitHub Desktop.
PerfectのExampleをFastCGIでnginxから動かす

PerfectLibのexampleをnginxで動かす

Swift, PerfectLibのインストール

こっちを参考 -> UbuntuにSwiftとPerfectLibをインストールする

nginxのインストール

$ sudo apt-get install nginx

VirtualHostを追加

$ sudo cp /etc/nginx/sites-available/default your.domain.com
$ sudo vi /etc/nginx/sites-available/your.domain.com
$ cd /etc/nginx/sites-enabled
$ sudo ln -s /etc/nginx/sites-available/your.domain.com

nginxを再起動

$ sudo service nginx start
server {
set $perfect_root "/var/www";
set $root "${perfect_root}/html";
set $sock "unix:${perfect_root}/perfect.fastcgi.sock";
listen 80;
listen [::]:80;
server_name your.domain.com;
access_log /var/log/nginx/your.domain.com.access_log;
error_log /var/log/nginx/your.domain.com.error_log;
root $root;
index index.html index.mustache;
location / {
try_files $uri $uri/ @perfect;
}
location = / {
include fastcgi_params;
fastcgi_pass $sock;
}
location ~ \.mustache$ {
include fastcgi_params;
fastcgi_pass $sock;
}
location @perfect {
include fastcgi_params;
fastcgi_pass $sock;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment