by sandipransing
Install RVM first
bash < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvminstaller)
rvm list known
# MRI Rubies
[ruby-]1.8.6-head
[ruby-]1.8.7[-p352]
[ruby-]1.9.3-head
ruby-head
# JRuby
jruby-1.2.0
jruby-head
# Rubinius
rbx-1.0.1
rbx-2.0.0pre
# Ruby Enterprise Edition
ree-1.8.6
ree-1.8.7-head
Install ruby 1.9.3
rvm install 1.9.3-head
rvm gemset create rails311
rvm use 1.9.3-head@rails311 --default
gem install rails -v3.1.1 --no-rdoc --no-ri
gem install heroku
gem install rb-readline
Create new rails project
rails new cdc -m http://railswizard.org/b22092a4358bbebb3a46.rb -J -T
Heroku Deployment Done
http://railsblank.heroku.com/ (production)
Local System nginx-passenger setup
gem install passenger
rvmsudo passenger-install-nginx-module
If you find pcre download error then make sure you libpcre-dev pkg
installed on your system otherwise install it and re-run
sudo apt-get install libpcre3-dev
Nginx Configuration
http {
passenger_root /home/sandip/.rvm/gems/ruby-1.9.3-head@rails311/gems/passenger-3.0.9;
passenger_ruby /home/sandip/.rvm/wrappers/ruby-1.9.3-head@rails311/ruby;
server {
listen 80;
server_name railsblank.local;
root /home/sandip/railsblank/public;
rails_env development;
passenger_enabled on;
}
git source code
git clone git://github.com/sandipransing/rails_blank.git
Read More…
by sandipransing
Edit nginx configuration and look for html block.
Inside html block add following line.
http {
include conf/mime.types;
default_type application/octet-stream;
client_max_body_size 10m;
....
}
In above configuration "application/octet-stream" supports any kind of file upload.
Read More…
by sandipransing
Install nginx server using following command
apt-get install nginx
Edit nginx configuration and add server block inside html block.
server {
listen 80;
server_name boost;
root /home/sandip/rails_app/public;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
if (-f $request_filename/index.html) {
rewrite (.*) $1/index.html break;
}
if (-f $request_filename.html) {
rewrite (.*) $1.html break;
}
if (!-f $request_filename) {
proxy_pass http://thin;
break;
}
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
Install thin server as gem
sudo gem install thin
Building native extensions. This could take a while...
Building native extensions. This could take a while...
Successfully installed eventmachine-0.12.10
Successfully installed thin-1.2.7
2 gems installed
Install thin service
sudo thin install
Installing thin service at /etc/init.d/thin ...
mkdir -p /etc/init.d
writing /etc/init.d/thin
chmod +x /etc/init.d/thin
mkdir -p /etc/thin
Configure thin to start at system boot
sudo /usr/sbin/update-rc.d -f thin defaults
Then put your config files in /etc/thin
sudo /usr/sbin/update-rc.d -f thin defaults
update-rc.d: warning: thin stop runlevel arguments (0 1 6) do not match LSB Default-Stop values (S 0 1 6)
Adding system startup for /etc/init.d/thin ...
/etc/rc0.d/K20thin -> ../init.d/thin
/etc/rc1.d/K20thin -> ../init.d/thin
/etc/rc6.d/K20thin -> ../init.d/thin
/etc/rc2.d/S20thin -> ../init.d/thin
/etc/rc3.d/S20thin -> ../init.d/thin
/etc/rc4.d/S20thin -> ../init.d/thin
/etc/rc5.d/S20thin -> ../init.d/thin
Create thin configuration
sudo thin config -C /etc/thin/<config-name>.yml -c <rails-app-root-path> --servers <number-of-threads> -e <environment>
</environment></number-of-threads></rails-app-root-path></config-name>
In my case,
sudo thin config -C /etc/thin/rails_app.yml -c /home/sandip/rails_app --servers 3 -e production
>> Wrote configuration to /etc/thin/rails_app.yml
thin configuration file will look like
Start/stop/restart Nginx & thin server using command
sudo service nginx start|stop|restart
sudo service thin start|stop|restart
Read More…