Created
May 24, 2012 12:42
-
-
Save marekjelen/2781362 to your computer and use it in GitHub Desktop.
Nginx configuration for Ruby @ OpenShift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ==== .openshift/action_hooks/start | |
cd ${OPENSHIFT_DATA_DIR} | |
ENV=${OPENSHIFT_DATA_DIR}env | |
PATH=$ENV/bin:$PATH | |
if [ ! -d "$ENV" ]; then | |
mkdir $ENV | |
wget http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz | |
wget http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p194.tar.gz | |
tar xf yaml-0.1.4.tar.gz | |
tar xf ruby-1.9.3-p194.tar.gz | |
rm yaml-0.1.4.tar.gz | |
rm ruby-1.9.3-p194.tar.gz | |
cd yaml-0.1.4 | |
./configure --prefix=$ENV | |
make | |
make install | |
cd .. | |
rm -rf yaml-0.1.4 | |
cd ruby-1.9.3-p194 | |
./configure --prefix=$ENV --enable-shared --disable-install-doc --with-opt-dir=$ENV | |
make | |
make install | |
cd .. | |
rm -rf ruby-1.9.3-p194 | |
gem update --no-ri --no-rdoc | |
gem install passenger --version 3.0.12 --no-ri --no-rdoc | |
passenger-install-nginx-module --auto --prefix=$ENV --auto-download | |
mkdir $ENV/etc | |
cd $ENV/etc | |
curl -o nginx.erb https://raw.github.com/gist/2781362/24202b7e59cf2388cc85dcdfe83f85c55fa482ff/nginx.erb | |
gem install bundler --no-ri --no-rdoc | |
fi | |
cd $OPENSHIFT_REPO_DIR | |
bundle install | |
# For Rails applications | |
# | |
# bundle exec rake db:migrate RAILS_ENV="production" | |
# bundle exec rake assets:precompile RAILS_ENV="production" | |
ruby -e "require 'erb'; template=ERB.new(File.read(File.join(ENV['OPENSHIFT_DATA_DIR'], 'env', 'etc', 'nginx.erb'))); puts template.result(binding)" > ${OPENSHIFT_DATA_DIR}env/conf/nginx.conf | |
${OPENSHIFT_DATA_DIR}env/sbin/nginx | |
# ==== .openshift/action_hooks/stop | |
${OPENSHIFT_DATA_DIR}env/sbin/nginx -s stop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
worker_processes 1; | |
events { | |
worker_connections 1024; | |
} | |
http { | |
passenger_root <%= ENV['OPENSHIFT_DATA_DIR'] %>env/lib/ruby/gems/1.9.1/gems/passenger-3.0.12; | |
passenger_ruby <%= ENV['OPENSHIFT_DATA_DIR'] %>env/bin/ruby; | |
include mime.types; | |
default_type application/octet-stream; | |
sendfile on; | |
keepalive_timeout 65; | |
server { | |
listen <%= ENV['OPENSHIFT_INTERNAL_IP'] %>:<%= ENV['OPENSHIFT_INTERNAL_PORT'] %>; | |
root <%= ENV['OPENSHIFT_REPO_DIR'] %>public; | |
passenger_enabled on; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment