-
安装nginx所需的linux包
sudo apt-get install build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libxml2-dev libxslt-dev autoconf libc6-dev zlib1g-dev libssl-dev build-essential curl git-core libc6-dev g++ gcc
-
添加一个user 并赋予其全部权限
sudo adduser railsadmin
授权,输入
visudo
在编辑器中找到如下内容:
root ALL=(ALL:ALL) ALL
在下面加一行
railsadmin ALL=(ALL:ALL) ALL
-
安装 passenger/nginx
gem install passenger rvmsudo passenger-install-nginx-module
-
安装nginx 启动脚本
https://gist.github.com/hisea/1548664/raw/53f6d7ccb9dfc82a50c95e9f6e2e60dc59e4c2fb/nginxsudo cp nginx /etc/init.d/ sudo chmod +x /etc/init.d/nginx sudo update-rc.d nginx defaults
-
配置nginx
配置文件在 /opt/nginx/config/nginx.confserver { listen 80; server_name higame.com; location / { root /home/railsadmin/ROR/bancheng.com/current/public; index index.html index.htm; passenger_enabled on; } }
-
如果出现 memory out error
https://www.digitalocean.com/community/articles/how-to-add-swap-on-ubuntu-12-04
参考
https://hisea.me/p/rails31-ubuntu-passenger-nginx-quick-deploy
网友评论