Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'ashchan/nginx-module'

Conflicts:
	config/stack/apache.rb
	config/stack/ruby_enterprise.rb
  • Loading branch information...
commit c5329cf132f797f743fc509193387b8650cdcde8 2 parents e5934e1 + f6665cd
@benschwarz authored
View
21 README.markdown
@@ -5,8 +5,9 @@ Scripts for [Sprinkle](http://github.com/crafterm/sprinkle/ "Sprinkle"), the pro
## How to get your sprinkle on:
-* Get a brand spanking new slice / host (Ubuntu please)
-* Create yourself a user, add yourself to the /etc/sudoers file
+* Get a brand spanking new slice / host (Debian or Ubuntu please, other apt-based sytems might work too)
+* Install sudo if you are on Debian
+* Create yourself a user (use `adduser`), add yourself to the /etc/sudoers file
* Set your slices url / ip address in deploy.rb (config/deploy.rb.example provided)
* Set username in config/deploy.rb if it isn't the same as your local machine (config/deploy.rb.example provided)
@@ -29,6 +30,13 @@ Other things you should probably consider:
* Close everything except for port 80 and 22
* Disallow password logins and use a passphrased RSA key
+#### "Connection reset by peer"
+
+You can work around this issue by tweaking `/etc/ssh/sshd_config` to include the following on the server:
+
+ ClientAliveInterval 60
+ ClientAliveCountMax 15
+
### Wait, what does all this install?
* Apache (Apt)
@@ -47,7 +55,7 @@ Other things you should probably consider:
* Ruby
* Capistrano
* Sprinkle (github.com/crafterm/sprinkle)
-* An Ubuntu based VPS (known to not work on Debian Etch†)
+* An Ubuntu or Debian based VPS (Ubuntu 9.10 Karmic has proven to make some changes)
## Thanks
@@ -56,12 +64,9 @@ Other things you should probably consider:
* [Nathan de Vries](http://github.com/atnan) for Postgres support
* [Anthony Kolber](http://aestheticallyloyal.com) for the github pages design
* [Stephen Eley](http://github.com/SFEley) for some sanity checks on git dependencies
+* [James Chen](http://github.com/ashchan) for finishing the nginx-module support that I never got to. Awesome!
## Disclaimer
Don't run this on a system that has already been deemed "in production", its not malicious, but there is a fair chance
-that you'll ass something up monumentally. You have been warned.
-
-### Footnotes
-
-† This issue lies between differences in apt between debian and ubuntu, my feedback has been forwarded and discussed with Marcus, the author of sprinkle. I believe he is looking into it.
+that you'll ass something up monumentally. You have been warned.
View
2  config/deploy.rb.example
@@ -1,3 +1,5 @@
+# Rename this file to deploy.rb
+
# Fill slice_url in - where you're installing your stack to
role :app, "your-app-server.com"
View
41 config/install.rb
@@ -1,25 +1,34 @@
-# Require our stack
-%w(essential apache scm ruby_enterprise memcached postgresql mysql).each do |r|
- require File.join(File.dirname(__FILE__), 'stack', r)
+$:<< File.join(File.dirname(__FILE__), 'stack')
+
+# Require the stack base
+%w(essential scm ruby_enterprise memcached postgresql mysql).each do |lib|
+ require lib
end
+# ===============
+# = Web servers =
+# ===============
+
+# Apache and Nginx are interchangable simply by choosing which file should be included to the stack
+
+# Apache has some extra installers for etags, gzip/deflate compression and expires headers.
+# These are enabled by default when you choose Apache, you can remove these dependencies within
+# stack/apache.rb
+
+#require 'apache'
+require 'nginx'
+
# What we're installing to your server
# Take what you want, leave what you don't
# Build up your own and strip down your server until you get it right.
-policy :passenger_stack, :roles => :app do
- requires :webserver # Apache
-
- requires :apache_etag_support # == Apache extras
- requires :apache_deflate_support # Read about these specialties in
- requires :apache_expires_support # stack/apache.rb
-
+policy :stack, :roles => :app do
+ requires :webserver # Apache or Nginx
requires :appserver # Passenger
requires :ruby_enterprise # Ruby Enterprise edition
- requires :database # MySQL or Postgres
- requires :ruby_database_driver # mysql or postgres gems
+ requires :database # MySQL or Postgres, also installs rubygems for each
requires :scm # Git
- requires :memcached # Memcached
- requires :libmemcached # Libmemcached
+ #requires :memcached # Memcached
+ #requires :libmemcached # Libmemcached
end
deployment do
@@ -42,8 +51,8 @@
# Depend on a specific version of sprinkle
begin
- gem 'sprinkle', ">= 0.2.1"
+ gem 'sprinkle', ">= 0.2.3"
rescue Gem::LoadError
- puts "sprinkle 0.2.1 required.\n Run: `sudo gem install sprinkle`"
+ puts "sprinkle 0.2.3 required.\n Run: `sudo gem install sprinkle`"
exit
end
View
14 config/stack/apache.rb
@@ -9,6 +9,7 @@
end
requires :build_essential
+ recommends :apache_etag_support, :apache_deflate_support, :apache_expires_support
end
package :apache2_prefork_dev do
@@ -19,7 +20,11 @@
package :passenger, :provides => :appserver do
description 'Phusion Passenger (mod_rails)'
version '2.2.4'
- gem 'passenger' do
+ binaries = %w(passenger-config passenger-install-nginx-module passenger-install-apache2-module passenger-make-enterprisey passenger-memory-stats passenger-spawn-server passenger-status passenger-stress-test)
+
+ gem 'passenger', :version => version do
+ binaries.each {|bin| post :install, "ln -s #{REE_PATH}/bin/#{bin} /usr/local/bin/#{bin}"}
+
post :install, 'echo -en "\n\n\n\n" | sudo passenger-install-apache2-module'
# Create the passenger conf file
@@ -40,8 +45,8 @@
verify do
has_file "/etc/apache2/extras/passenger.conf"
- has_file "/usr/local/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-#{version}/ext/apache2/mod_passenger.so"
- has_directory "/usr/local/ruby-enterprise/lib/ruby/gems/1.8/gems/passenger-#{version}"
+ has_file "#{REE_PATH}/ext/apache2/mod_passenger.so"
+ binaries.each {|bin| has_symlink "/usr/local/bin/#{bin}", "#{REE_PATH}/bin/#{bin}" }
end
requires :apache, :apache2_prefork_dev, :ruby_enterprise
@@ -60,7 +65,6 @@
push_text config, apache_conf, :sudo => true
verify { file_contains apache_conf, "Passenger-stack-etags"}
- requires :apache
end
# mod_deflate, compress scripts before serving.
@@ -80,7 +84,6 @@
push_text config, apache_conf, :sudo => true
verify { file_contains apache_conf, "Passenger-stack-deflate"}
- requires :apache
end
# mod_expires, add long expiry headers to css, js and image files
@@ -99,5 +102,4 @@
push_text config, apache_conf, :sudo => true
verify { file_contains apache_conf, "Passenger-stack-expires"}
- requires :apache
end
View
6 config/stack/mysql.rb
@@ -1,10 +1,12 @@
package :mysql, :provides => :database do
description 'MySQL Database'
- apt %w( mysql-server mysql-client libmysqlclient15-dev )
+ apt %w( mysql-server mysql-client libmysqlclient-dev )
verify do
has_executable 'mysql'
end
+
+ optional :mysql_driver
end
package :mysql_driver, :provides => :ruby_database_driver do
@@ -15,5 +17,5 @@
has_gem 'mysql'
end
- requires :mysql, :ruby_enterprise
+ requires :ruby_enterprise
end
View
44 config/stack/nginx.rb
@@ -0,0 +1,44 @@
+# =========
+# = Notes =
+# =========
+
+# The phusion guys have made it so that you can install nginx and passenger in one
+# fell swoop, it is for this reason and cleanliness that I haven't decided to install
+# nginx and passenger separately, otherwise nginx ends up being dependent on passenger
+# so that it can call --add-module within its configure statement - That in itself would
+# be strange.
+
+package :nginx, :provides => :webserver do
+ puts "** Nginx installed by passenger gem **"
+ requires :passenger
+
+ push_text File.read(File.join(File.dirname(__FILE__), 'nginx', 'init.d')), "/etc/init.d/nginx", :sudo => true do
+ post :install, "sudo chmod +x /etc/init.d/nginx"
+ post :install, "sudo /usr/sbin/update-rc.d -f nginx defaults"
+ post :install, "sudo /etc/init.d/nginx start"
+ end
+
+ verify do
+ has_executable "/usr/local/nginx/sbin/nginx"
+ has_file "/etc/init.d/nginx"
+ end
+end
+
+package :passenger, :provides => :appserver do
+ description 'Phusion Passenger (mod_rails)'
+ version '2.2.10'
+ binaries = %w(passenger-config passenger-install-nginx-module passenger-install-apache2-module passenger-make-enterprisey passenger-memory-stats passenger-spawn-server passenger-status passenger-stress-test)
+
+ gem 'passenger', :version => version do
+ # Install nginx and the module
+ binaries.each {|bin| post :install, "ln -s #{REE_PATH}/bin/#{bin} /usr/local/bin/#{bin}"}
+ post :install, "sudo passenger-install-nginx-module --auto --auto-download --prefix=/usr/local/nginx"
+ end
+
+ requires :ruby_enterprise
+
+ verify do
+ has_gem "passenger", version
+ binaries.each {|bin| has_symlink "/usr/local/bin/#{bin}", "#{REE_PATH}/bin/#{bin}" }
+ end
+end
View
63 config/stack/nginx/init.d
@@ -0,0 +1,63 @@
+#! /bin/sh
+
+### BEGIN INIT INFO
+# Provides: nginx
+# Required-Start: $all
+# Required-Stop: $all
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: starts the nginx web server
+# Description: starts nginx using start-stop-daemon
+### END INIT INFO
+
+
+PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+DAEMON=/usr/local/nginx/sbin/nginx
+NAME=nginx
+DESC=nginx
+
+test -x $DAEMON || exit 0
+
+# Include nginx defaults if available
+if [ -f /etc/default/nginx ] ; then
+ . /etc/default/nginx
+fi
+
+set -e
+
+case "$1" in
+ start)
+ echo -n "Starting $DESC: "
+ start-stop-daemon --start --quiet --pidfile /usr/local/nginx/logs/$NAME.pid \
+ --exec $DAEMON -- $DAEMON_OPTS
+ echo "$NAME."
+ ;;
+ stop)
+ echo -n "Stopping $DESC: "
+ start-stop-daemon --stop --quiet --pidfile /usr/local/nginx/logs/$NAME.pid \
+ --exec $DAEMON
+ echo "$NAME."
+ ;;
+ restart|force-reload)
+ echo -n "Restarting $DESC: "
+ start-stop-daemon --stop --quiet --pidfile \
+ /usr/local/nginx/logs/$NAME.pid --exec $DAEMON
+ sleep 1
+ start-stop-daemon --start --quiet --pidfile \
+ /usr/local/nginx/logs/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS
+ echo "$NAME."
+ ;;
+ reload)
+ echo -n "Reloading $DESC configuration: "
+ start-stop-daemon --stop --signal HUP --quiet --pidfile /usr/local/nginx/logs/$NAME.pid \
+ --exec $DAEMON
+ echo "$NAME."
+ ;;
+ *)
+ N=/etc/init.d/$NAME
+ echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
+ exit 1
+ ;;
+ esac
+
+ exit 0
View
4 config/stack/postgresql.rb
@@ -5,6 +5,8 @@
verify do
has_executable 'psql'
end
+
+ optional :postgresql_driver
end
package :postgresql_driver, :provides => :ruby_database_driver do
@@ -15,5 +17,5 @@
has_gem 'postgres'
end
- requires :postgres, :ruby_enterprise
+ requires :ruby_enterprise
end
View
16 config/stack/ruby_enterprise.rb
@@ -1,19 +1,18 @@
package :ruby_enterprise do
description 'Ruby Enterprise Edition'
- version '1.8.6-20090610'
+ version '1.8.7-2010.01'
+ REE_PATH = "/usr/local/ruby-enterprise"
- install_path = "/usr/local/ruby-enterprise"
- binaries = %w(erb gem irb passenger-config passenger-install-apache2-module passenger-make-enterprisey passenger-memory-stats passenger-spawn-server passenger-status passenger-stress-test rackup rails rake rdoc ree-version ri ruby testrb)
- source "http://rubyforge.org/frs/download.php/58677/ruby-enterprise-#{version}.tar.gz" do
+ binaries = %w(erb gem irb rackup rails rake rdoc ree-version ri ruby testrb)
+ source "http://rubyforge.org/frs/download.php/68719/ruby-enterprise-#{version}.tar.gz" do
custom_install 'sudo ./installer --auto=/usr/local/ruby-enterprise'
-
- binaries.each {|bin| post :install, "ln -s #{install_path}/bin/#{bin} /usr/local/bin/#{bin}" }
+ binaries.each {|bin| post :install, "ln -s #{REE_PATH}/bin/#{bin} /usr/local/bin/#{bin}" }
end
verify do
has_directory install_path
- has_executable "#{install_path}/bin/ruby"
- binaries.each {|bin| has_symlink "/usr/local/bin/#{bin}", "#{install_path}/bin/#{bin}" }
+ has_executable "#{REE_PATH}/bin/ruby"
+ binaries.each {|bin| has_symlink "/usr/local/bin/#{bin}", "#{REE_PATH}/bin/#{bin}" }
end
requires :ree_dependencies
@@ -21,4 +20,5 @@
package :ree_dependencies do
apt %w(zlib1g-dev libreadline5-dev libssl-dev)
+ requires :build_essential
end
Please sign in to comment.
Something went wrong with that request. Please try again.