1.安装sinatra
gem install sinatra
2.编码,创建myapp.rb
# app.rb require 'sinatra' require 'puma' get "/hello" do return "Hi, whats up" end
3.运行
ruby myapp.rb
4.安装puma 服务器
gem install puma
5.让sinatra项目运行在puma
ruby app.rb -s Puma
6.安装Nginx
sudo apt-get install nginx
7.配置Nginx代理端口 位置 /etc/nginx/sites-available/default
注释掉原来的配置,填入新的
server { listen 80; listen [::]:80; location / { proxy_pass http://localhost:4567; } }
8.启动Nginx
sudo service nginx start
访问测试
http://localhost/