Skip to content

Instantly share code, notes, and snippets.

@danielepolencic
Last active October 2, 2017 20:09
Show Gist options
  • Save danielepolencic/6983030 to your computer and use it in GitHub Desktop.
Save danielepolencic/6983030 to your computer and use it in GitHub Desktop.

Please read the new and updated version.

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 [email protected]: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

@trigun0x2
Copy link

Do you feel like there are any performance limits on Heroku?

Copy link

ghost commented Feb 19, 2014

How is this deployment going, any lessons learned. I'm intrigued, are you still up and running in Heroku?

Copy link

ghost commented Mar 26, 2014

Works like a dream, running well on a single free dyno using ignite on ClearDB. Thanks

@santoshkt
Copy link

What is the list size you are using ?

Copy link

ghost commented Apr 23, 2014

Email list? Approximately 6000 subscribers currently but I’ve just recently had to upgrade ClearDB to 1GB (ClearDB ‘Punch' I think they call it)

@rdetert
Copy link

rdetert commented Jun 26, 2014

These instructions seem to work but I'm still getting errors like these from the heroku logs:

2014-06-26T08:09:25.186634+00:00 app[web.1]: [Thu Jun 26 08:09:24 2014] [error] [client 10.185.130.200] PHP Warning:  mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in /app/www/includes/update.php on line 362, referer: http://domain.com/_install.php

@danielepolencic
Copy link
Author

referer: http://domain.com/_install.php

Have you correctly set up your domain? the warning shouldn't stop you from using sendy.

@rdetert
Copy link

rdetert commented Jul 10, 2014

Odd, it just kinda started working. I was using ClearDB add on, maybe there was a permissions issue going on or something.

@AymericG
Copy link

AymericG commented Aug 8, 2014

I love you. This guide was very helpful!

@AymericG
Copy link

How would you use Heroku's Scheduler to set up the cron thingy? Sendy keeps timing out (I have 10000 subscribers)

@dzuelke
Copy link

dzuelke commented Aug 14, 2014

You should update these instructions, @danielepolencic; PHP on Heroku now supports both mysqli and gettext (enable via composer.json), no need for multipack or your custom buildpack.

@dovy
Copy link

dovy commented Aug 21, 2014

UPDATED THESE DOCS TO REFLECT @dzuelke's suggestion:
https://gist.github.com/dovy/3a82773ffc73b2c725d7

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