网络设置:打开互ping
安装所需的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
sudo adduser railsu
sudo usermod -G passenger,www-data,sudo railsu
su - railsu
bash < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
加载rvm (只需第一次安装时加载)
source .bashrc
安装ruby
rvm install 1.9.2
rvm 高阶应用可以参考这里的指南
rvm use 1.9.2 default
gem install passenger
rvmsudo passenger-install-nginx-module
所有都选默认,包括nginx安装目录业选择默认 /opt/nginx/
menxu@debian:~$ sudo apt-get install nginx-common
wget https://raw.github.com/gist/1548664/53f6d7ccb9dfc82a50c95e9f6e2e60dc59e4c2fb/nginx
sudo cp nginx /etc/init.d/
sudo chmod +x /etc/init.d/nginx
sudo update-rc.d nginx defaults
配置文件在 /opt/nginx/config/nginx.conf
@debian:~$ ls /etc/nginx/
conf.d koi-win naxsi.rules scgi_params uwsgi_params
fastcgi_params mime.types nginx.conf sites-available win-utf
koi-utf naxsi_core.rules proxy_params sites-enabled
@debian:~$ cp /etc/nginx/nginx.conf /etc/nginx/nginx_copy.conf
cp: 无法创建普通文件"/etc/nginx/nginx_copy.conf": 权限不够
@debian:~$ sudo cp /etc/nginx/nginx.conf /etc/nginx/nginx_copy.conf
gem install passenger rvmsudo passenger-install-nginx-module
sudo apt-get install libcurl4-openssl-dev
:~$ ls /nginx/conf/
:~$ sudo gedit nginx/conf/nginx.conf
server {
listen 80;
server_name www.yourhost.com;
root /home/railsu/project/public; # <--- 这里是你项目的public目录
passenger_enabled on;
}
用来precompile rails assets
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
cd ~/project
rake assets:precompile
sudo /etc/init.d/nginx start
原文地址: http://hisea.me/p/rails31-ubuntu-passenger-nginx-quick-deploy
@debian:~/文档/bushu/blogs$ touch tmp/restart.txt 重新加载
@debian:~/文档/bushu/blogs$ tail -f log/production.log 查看日志
@debian:~/文档/bushu/blogs$ rake assets:precompile 生成css文件
-----------------------------------
server {
listen 443;
server_name www.menxublog.com;
# ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_timeout 5m;
# ssl_protocols SSLv2 SSLv3 TLSv1;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
#root /home/menxu/文档/ruby/blogs/public;
root /home/menxu/文档/bushu/blogs/public;
passenger_enabled on;
}
http {
passenger_root /home/menxu/.rvm/gems/ruby-2.0.0-p0/gems/passenger-4.0.2;
passenger_ruby /home/menxu/.rvm/wrappers/ruby-2.0.0-p0/ruby;