Step-by-step guide to deploy harry's prelaunchr email campaign

This is a simplified step-by-step guide to deploy Harry's prelaunchr email campaign.
If you don't know what Harry's prelaunchr email campaign is, you can read about it here.

Requirements:

  • Unix-based server for hosting the application.
    You can use any linux-based VPS. In this guide, I'm using Ubuntu Server 14.04.
  • Client computer to access the server.
    We're going to use ssh to access the server. For unix-based computers (OS X & Linux), ssh command is available on the standard install, but for Windows-based computer, you'll need something like PuTTY to access the server.
  • Knowledge on how to use Terminal, ssh, bash, vi or nano, git, ssh, Ruby on Rails, Apache and passenger.

Important Notes:

  • This is a simplified guide, there are further steps needed to be done which are not covered by this guide (securities, email setup, best practices, maintainability, etc).
  • If you're not sure what the following commands are going to do, I recommend you to NOT doing this by yourself. Instead, hire someone or team who knows how to implement this, e.g. hire us :) .
  • Additionally, you will have to change any provided artwork to your own brand's before taking the website up and running publicly.

Let's begin!

  1. Open Terminal (on OS X / Linux, or PuTTY on Windows) and ssh into your server:

    ssh root@myserver.com
    
  2. Install core components.

    apt-get update && apt-get -y install curl git-core python-software-properties libcurl4-openssl-dev apache2-mpm-worker apache2-threaded-dev libapr1-dev libaprutil1-dev
    
  3. Install rvm and add root to rvm group (You'll have to logout and re-login after this step's commands)

    \curl -sSL https://get.rvm.io | sudo bash -s stable
    usermod -a -G rvm root
    
  4. After re-logged-in to the server, it's time to install ruby, bundler and passenger.

    rvm install 2.1.2
    gem install bundler passenger --no-rdoc --no-ri
    
  5. Install passenger apache module (deselect Python from the list).

    passenger-install-apache2-module
    
  6. Copy the configurations info from previous command's output to the end of the /etc/apache/apache2.conf file, here's the output from my screen:

    LoadModule passenger_module /usr/local/rvm/gems/ruby-2.1.2/gems/passenger-4.0.48/buildout/apache2/mod_passenger.so
    <IfModule mod_passenger.c>
      PassengerRoot /usr/local/rvm/gems/ruby-2.1.2/gems/passenger-4.0.48
      PassengerDefaultRuby /usr/local/rvm/gems/ruby-2.1.2/wrappers/ruby
    </IfModule>
    
  7. Make Apache aware of the application we're going to run, replace the content of /etc/apache2/sites-available/000-default.conf with this:

    <VirtualHost *:80>
      RailsEnv production
      DocumentRoot /var/www/prelaunchr/public
      <Directory /var/www/prelaunchr/public>
        AllowOverride all
        Options -MultiViews
        Require all granted
      </Directory>
    </VirtualHost>
    
  8. Instead of using the original repo, we're going to use my fork, which includes the fix for assets precompilation error and using sqlite3 instead of postgresql as the database.

    cd /var/www
    git clone https://github.com/sutanto/prelaunchr.git
    cd prelaunchr
    
  9. Install the required gems, prepare database and assets and change owner to www-data.

    bundle install
    bundle exec rake db:migrate assets:precompile RAILS_ENV=production
    chown -R www-data.www-data .
    
  10. Restart Apache and that's it!

    service apache2 restart
    

The application is now up and running. You can access it from your browser by typing the ip address or the domain name of the VPS.

I hope this post helps you to get a basic idea on how to deploy the prelaunchr.