Skip to content

Instantly share code, notes, and snippets.

@JackDanger
Created June 23, 2009 22:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JackDanger/134875 to your computer and use it in GitHub Desktop.
Save JackDanger/134875 to your computer and use it in GitHub Desktop.
apt-get update
apt-get install -y apache2
apt-get install -y apache2-prefork-dev
apt-get install -y ruby1.8-dev
apt-get install -y git-core
apt-get install -y irb
# install newest rubygems
wget http://rubyforge.org/frs/download.php/45905/rubygems-1.3.1.tgz
tar xzf rubygems-1.3.1.tgz
cd rubygems-1.3.1
sudo ruby setup.rb
ln -s /usr/bin/gem1.8 /usr/bin/gem
cd ~/
gem install --no-ri --no-rdoc rails
gem install --no-ri --no-rdoc passenger
gem install --no-ri --no-rdoc rack -v 0.4.0
gem install --no-ri --no-rdoc mysql
# configure and install mod_rails (Phusion Passenger)
echo -en '\n\n\n\n\n' | passenger-install-apache2-module
# write to the user conf file for apache2
cat > /etc/apache2/httpd.conf <<EOM
# HTTP
<VirtualHost *:80>
ServerName ec2.adpickles.com
DocumentRoot /wwwroot/deploy/current/public
RailsMaxPoolSize 5
<Directory /wwwroot/deploy/current/public>
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
# HTTPS
<VirtualHost *:443>
ServerName ec2.adpickles.com
DocumentRoot /wwwroot/deploy/current/public
Include /etc/apache2/mods-enabled/deflate.conf
SSLEngine on
SSLCertificateFile /etc/apache2/thawte.crt
SSLCertificateKeyFile /etc/apache2/thawte.key
RailsMaxPoolSize 3
<Directory /wwwroot/deploy/current/public>
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
# Passenger httpd config
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.0.6/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.0.6
PassengerRuby /usr/bin/ruby1.8
EOM
# add rewrite and ssl modules to apache config
ln -s ../mods-available/rewrite.load /etc/apache2/mods-enabled/
ln -s ../mods-available/ssl.load /etc/apache2/mods-enabled/
ln -s ../mods-available/ssl.conf /etc/apache2/mods-enabled/
# make a user and directory where capistrano can release code
useradd -m -d /wwwroot -s /bin/bash app
# copy the ssh credentials AWS assigned to root to this new user
cp -r /root/.ssh /wwwroot/
chown -R app:app /wwwroot/
# run apache under this new 'app' user
cat > /etc/apache2/envvars <<EOM
export APACHE_RUN_USER=app
export APACHE_RUN_GROUP=app
export APACHE_PID_FILE=/var/run/apache2.pid
EOM
# start the server (there will be warnings because /wwwroot/deploy/current doesn't exist yet)
/etc/init.d/apache2 stop
/etc/init.d/apache2 start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment