Skip to content

Instantly share code, notes, and snippets.

@Saruultugs
Forked from danielepolencic/Sendy.md
Last active August 29, 2015 14:10
Show Gist options
  • Save Saruultugs/d0f5843d35eb067deae4 to your computer and use it in GitHub Desktop.
Save Saruultugs/d0f5843d35eb067deae4 to your computer and use it in GitHub Desktop.

Sendy

Sendy is a self hosted email newsletter application that lets you send trackable emails via Amazon Simple Email Service (SES).

Heroku

You can deploy Sendy on Heroku using the following instructions (I assume you've already installed the heroku toolbelt).

  1. On Heroku, create a new app and add the following add on: ClearDB (I chose the free tier).
  2. Create a GIT repository with git init and commit all the files with git add -A and git commit -am "first commit".
  3. Create a new folder in the root of the project named ext. In the same folder, place the mysqli.so file downloadable here. In the root folder, create a new file named php.ini with the following content:
    extension_dir = "/app/www/ext/"
    extension=mysqli.so

This extension is necessary because Heroku doesn't support MySQLi natively. You can read more about MySQLi on Heroku here, and about custom php extensions on Heroku here.

  1. Customise the includes/config.php and include the following snippet to use the ClearDB addon previously selected on Heroku:
    <?php
    define('APP_PATH', 'http://yourdomain.com');

    $url_cleardb = parse_url(getenv("CLEARDB_DATABASE_URL"));

    /*  MySQL database connection credentials  */
    $dbHost = $url_cleardb['host']; //MySQL Hostname
    $dbUser = $url_cleardb['user']; //MySQL Username
    $dbPass = $url_cleardb['pass']; //MySQL Password
    $dbName = substr($url_cleardb["path"],1); //MySQL Database Name

All these settings are necessary to Heroku to automatically hook up the ClearDB add-on. More on the settings here.

  1. Create a new file named .buildpacks in the root of the project with the following content:
    https://github.com/danielepolencic/heroku-buildpack-php.git
    https://github.com/piotras/heroku-buildpack-gettext

These are the scripts that provision and set up the server. The php buildpack uses a slighlty tweaked version than the original php buildpack to support gettext.

  1. Create a new file named Procfile in the root of the project with the following content:
    web: sh boot.sh

This file instruct Heroku on how it should launch the application.

  1. Add a new remote repository to your local repository:
    git remote add heroku git@heroku.com:nameofyourapp.git
  1. Add a custom buildpack to your Heroku application:
    heroku config:add BUILDPACK_URL=https://github.com/ddollar/heroku-buildpack-multi.git --app nameofyourapp

This instructs Heroku to look into the .buildpacks file in the root folder of the project and install all the buildpacks listed there.

  1. Commit all the changes and push to Heroku:
    git add -A .
    git commit -am "Sendy customised for heroku deployment"
    git push heroku master

FAQs

Q: I'm getting 'Application Error' on Heroku
A: From the command line, try to run heroku ps:scale web=1 --app yourappname

Q: I've done what you said and I've got another error:

   Scaling web dynos... failed
    !    No such process type web defined in Procfile.

A: You're missing the Procfile in the root of your directory. Add the file, push your changes to Heroku and re-run heroku ps:scale web=1 --app yourappname

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment