Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save przbadu/7847585eb191bf86d5fae6b24e164a65 to your computer and use it in GitHub Desktop.
Save przbadu/7847585eb191bf86d5fae6b24e164a65 to your computer and use it in GitHub Desktop.
Deployment steps for rails in windows

How to deploy rails application in windows

  1. Download and install required stacks from bitnami ruby stack
  2. Follow https://medium.com/@keokilee/rails-on-windows-with-bitnami-8c04d886eddc if you want advance deployment

Normal Deployment steps

  1. Install ruby stack using bitnami
  2. Open Use Bitnami Ruby Stack terminal that bitnami installed (you can search this program in installed programs). This will run terminal as administrator, and open inside rubystack directory
  3. Clone your project inside "c:<ruby-stack>\projects"
  4. cd into project
  5. Bundle Install: bundle install
  6. Migrate Database bundle exec rake db:create db:migrate RAILS_ENV=production
  7. Assets Precompile bundle exec rake assets:precompile RAILS_ENV=production
  8. Run rails server rails s -p 80 -e production
  9. Visit http://localhost and you should see your application running.

Advance Steps

  • setenv
# Run bundle install
# Run this command
> \Bitnami\rubystack-2.6.5-2\scripts\setenv.bat
# Run bundle install
>\Bitnami\rubystack-2.6.5-2\ruby\bin\bundle install
  1. Create a batch script

c:\<path-to ruby stack>\projects\yourapp\bin\server.bat

@echo off
CALL “C:\<path to ruby stack>\scripts\setenv.bat”
cd C:\<path to ruby stack>\projects\<project dir>
thin start -p “”%1"” -e production
  1. Download NSSM and setup PATH environment variable to execute nssm command from everwhere
  2. Create NSSM service
nssm start <your service name>
# Applicatiion Path: "c:\<path-to ruby stack>\projects\yourapp\bin\server.bat"
# Startup Directory: "c:\<path to ruby stack>\projects\yourapp"
# Arguments: 8080 # this is port number you want your app to run in.

# wait for couple of seconds for rails app to start, and visit http://localhost:8080
  1. Or using sc command:
sc.exe create testingservice123 binpath="c:\<path-to ruby stack>\projects\yourapp\bin\server.bat"
sc.exe start testingservice123
sc.exe delete testingservice123
stop and various other commands
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment