How To Configure Sendy on Ubuntu 16.04 with nginx

How To Configure Sendy on Ubuntu 16.04 with nginx




Introduction


Sendy is a self hosted email newsletter application that lets you send trackable emails via Amazon Simple Email Service (SES). You can host it on your vps. We are going to see how to host the Sendy on Ubuntu server having installed php , mysql and nginx

Prerequisites


Before you begin this guide you'll need the following:
  • VPS with ubuntu 16.04
  • PHP
  • MySQL
  • nginx

Step 1 — Get the licenced copy of sendy

Sendy is a commercial product. You have to purchase it before using it. You can purchase it from http://sendy.co
After purchasing they will send you a copy of the sendy to your email id.
Now transition to the next step by telling the reader what's next.


Step 2 — Configer Sendy

Extract the zip of sendy you get in the email
Update the config.php file
  • You will be able to find config.php file inside the include folder.
  • Update the varialbes inside config.php
    Set the App_PATH & Set the mysql credentials
    /*  Set the URL to your Sendy installation (without the trailing slash) */
    define('APP_PATH', 'url-you-want-to-use-for-your-sendy-server'); /* for example : sender.yourdomain.com */
    
    /*  MySQL database connection credentials (please place values between the apostrophes) */
    $dbHost = 'localhost'; //MySQL Hostname
    $dbUser = 'root'; //MySQL Username
    $dbPass = 'password'; //MySQL Password
    $dbName = 'sendy'; //MySQL Database Name
    



Step 3 — Configure Ubuntu Server for sendy

  • Create mysql database for the sendy. Here create the database the same name as you have written in the config.php
  • Upload the sendy to /var/www/html folder on ubuntu server
  • Change the permission of the upload folder inside the sendy to 777

Step 4 — Domain/Subdomain Setup To access sendy

Setup the url to access the sendy : Here url shoukd be same as you have defined in the APP_PATH.
For example 
your APP_PATH is : sender.mydomain.com
Then you have to first set the subdomain for this.
  • Create a subdomain named sender at your domain provider
  • Make A record with the subdomain pointing to your vps ip address
Now update your nginx host file
  • Go to /etc/nginx/site-available
  • Append this code to default
server {
    listen 80;
    listen [::]:80;
    root /var/www/html/sendy; 

    server_name sender.{yourdomain}.com;

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

    location / {
            if (!-f $request_filename){
                    rewrite ^/([a-zA-Z0-9-]+)$ /$1.php last;
            }
    }
    location /l/ {
            rewrite ^/l/([a-zA-Z0-9/]+)$ /l.php?i=$1 last;
    }
    location /t/ {
            rewrite ^/t/([a-zA-Z0-9/]+)$ /t.php?i=$1 last;
    }
    location /w/ {
            rewrite ^/w/([a-zA-Z0-9/]+)$ /w.php?i=$1 last;
    }
    location /unsubscribe/ {
            rewrite ^/unsubscribe/(.*)$ /unsubscribe.php?i=$1 last;
    }
    location /subscribe/ {
            rewrite ^/subscribe/(.*)$ /subscribe.php?i=$1 last;
    }
    location ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ {
            expires max;
            log_not_found off;
    }
}

Step 5 — Install the sendy

Install the Sendy
After you done the domain settings (Step 4) for the sendy you will be able access the sendy via APP_PATH url.
  • Open this url in browser : http://yourdomain.com/sendy
    It will install the sendy itself. It will ask you for your domain name and the licence key.

    You got via email already at time of purchase.
    • Open this url in browser : http://your_sendy_installation_url/_compatibility.php?i=1 It will display the error if any php dependacy is missing or not. ( Because sendy is not offically for nginx it will show some missing dependency but it is ok.)



Step 6 — Setup cron job to enable scheduling in sendy

Set the cron job using crontab
$ crontab -e
it will open the cronjob file

*/5 * * * * php /var/www/html/scheduled.php > /dev/null 2>&1
add this line to the file save and exit.


Tip for windows

if you are running sendy on windows you will be able to set every thing leaving just one thing.

That is cron of scheduling.

IN this case you have to creat a task in the task scheulder and call bat file having this code inside it




echo running sendy scheduler process >> out.log

Pushd "Path-to-your-php-executable-file" >> out.log

php.exe -f "Path-to-your-sendy-folder\scheduled.php"   >> out.log

echo executed: C:\laragon\bin\php\php-7.1.1-Win32-VC14-x86\php.exe 

 C:\laragon\www\sender\scheduled.php >> out.log

Comments

  1. I am commenting to let you know what a terrific experience my daughter enjoyed reading through your web page. She noticed a wide variety of pieces, with the inclusion of what it is like to have an awesome helping style to have the rest without hassle grasp some grueling matters.
    AWS Training in Bangalore|

    ReplyDelete

Post a Comment

Popular Posts