Search

How to Install Sendy inside a Folder for Nginx

Listen to this article

sendy-installation-nginxEmail marketing is a cost-effective way to promote your services or products. Colloquially, email marketing is referred to as newsletters. A newsletter is a publication you send out periodically, to subscribers of your website. You must’ve heard of MailChimp or SendGrid, or probably use such a service. These are email marketing services, which help you manage your email marketing activities.

At WisdmLabs, we use Sendy. Sendy gives us complete control over the entire activity, because it provides access to its codebase. MailChimp or SendGrid on the other hand, allow limited control, because their code is locked.

[space]

Sendy: The Email Newsletter Application

To tell you a bit about Sendy, it is a self hosted email newsletter application. It can be used to send emails via Amazon Simple Email Service (SES). You can of course get more information by visiting Sendy’s official website. And you can follow the ‘Get Started‘ guide, to install the application.

Now, Sendy works like a charm for Apache. However, for Nginx we need to make some changes in the Nginx configuration file.

[space]

Installing Sendy on Nginx

sendy-apache-faq
Sendy needs to update their FAQ

You have two options when you install Sendy. You can install it on a separate domain (or a subdomain), or you can install it in a folder. Either way, you’d need to make some changes in your Nginx configuration file.

To install Sendy in another domain or subdomain, you’d need this Nginx configuration file (thanks Tyler Brownell). But instead, if you would prefer to install sendy in a folder, then you’d have to follow a different procedure.

Installing Sendy in a Folder

To install Sendy in a folder, you’d need to make some changes in the configuration file of your primary domain. Say for example, you have a domain abc.com, and want to access Sendy under abc.com/newsletters. You will have to make some changes in the Nginx configuration file of abc.com.

  1. To begin, follow all procedures mentioned in the Sendy Installation Guide, except the .htaccess changes mentioned.
  2. Once those are done, open up the Nginx configuration file of your main domain. This file should be found at which should be available in /etc/nginx/sites-available/ directory.
  3. Add the below rules in the server block of that configuration file. I’m assuming, you’ve copied all Sendy files in the /home/abc/public_html/newsletters directory. And you want to access Sendy at abc.com/newsletters. You can make respective changes (to the domain and folder names) to get desired results.
 #Sendy configuration

       location ^~ /newsletters {

               root /home/abc/public_html/;

               error_log /var/log/nginx/sendy.error.log;

               index index.php index.html index.htm;

               try_files $uri $uri/ $uri.php?$args;

               rewrite ^/newsletters/w/([a-zA-Z0-9/]+)$ /newsletters/w.php?i=$1 last;

               rewrite ^/newsletters/l/([a-zA-Z0-9/]+)$ /newsletters/l.php?i=$1 last;

               rewrite ^/newsletters/t/([a-zA-Z0-9/]+)$ /newsletters/t.php?i=$1 last;

               rewrite ^/newsletters/subscribe/([a-zA-Z0-9/]+)$ /newsletters/subscribe.php?i=$1 last;

               rewrite ^/newsletters/unsubscribe/([a-zA-Z0-9/]+)$ /newsletters/unsubscribe.php?i=$1 last;

               location ~ \.php$ {

                       try_files $uri =404;

                       fastcgi_split_path_info ^(.+\.php)(/.+)$;

                       fastcgi_pass php;

                       fastcgi_index index.php;

                       include fastcgi_params;
               }

               location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
                       access_log off;

                       log_not_found off;

                       expires 30d;
               }
       }

Done!

Now, it’s time to test!

Test the Application Setup

  1. Test an Email Preview: Login to your Sendy application, create a new template, and try to preview it. If it shows the preview, then it is working. (Awesome! But there’s more)
  2. Test Email Links: Add a link in your template (maybe to a page on your website), and send out a test email. Sendy cloaks links with its own url, but on click it should smoothly take you to the desired URL. If get a ‘404 Page not Found’ error, then rewrite rules are not setup correctly. You might want to rectify those.

[space]

That’s it for now! Should you have any doubts, feel free to leave them as comments 🙂

Sumit Pore

Sumit Pore

7 Responses

  1. Wonderfully Explained Sumit.
    Hope I would have found this earlier. But, we have started using service from EasySendy, they have complete Sendy Hosting Solution, so, don’t have to take care of all these tech and I completely concentrate on email marketing. 🙂

    1. Great that you liked the article and too bad that you didn’t find it earlier. EasySendy seems a good option to setup and get Sendy running quickly without much technical knowledge 🙂

  2. Awesome write up. Thank you, the nGinx configuration worked for me with the exception of the php block which had to be changed to look like this

    location ~ \.php$ {
    try_files $uri =404;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
    }

    This change was done to prevent the situation where files were trying to be downloaded instead of being opened in the normal way

Leave a Reply

Your email address will not be published. Required fields are marked *

Get The Latest Updates

Subscribe to our Newsletter

A key to unlock the world of open-source. We promise not to spam your inbox.

Suggested Reads

WordPress Development

Custom WordPress Solutions, for You

LearnDash Development

Custom LearnDash Solutions, for You

WooCommerce Development

Custom WooCommerce Solutions, for You

WordPress Plugins

Scale your WordPress Business

WooCommerce Plugins

Scale your WooCommerce Business

LearnDash Plugins

Scale your LearnDash Business

Label

Title

Subtext

Label

Title

Subtext

Join our 55,000+ Subscribers

    The Wisdm Digest delivers all the latest news, and resources from the world of open-source businesses to your inbox.

    Suggested Reads

    WordPress Tips & Tricks
    Ketan Vyawahare

    How to Make Responsive Tables using CSS without Tag Read More »