Friday, September 11, 2020

How To Install Mailtrain Newsletter App with Nginx Web Server On Ubuntu 18.04 LTS

Video Tutorial -  https://youtu.be/EhaBZGV5JxM

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

 Mailtrain is an open source, self-hosted newsletter application built from Node.js. Mailtrain is built on top of Nodemailer and it supports MySQL/MariaDB database backends.
Mailtrain is an alternative to commercial email marketing services such as Mailchimp, Sendgrid e.t.c.
Offcial Website: https://mailtrain.org/
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Our Server Specification-     
Os:Ubuntu 18.04 LTS Bionic Beaver 64Bit   | IP address- 192.168.1.50  | Hostname :www.yourdomain.com
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
lsb_release -cd ; hostname ; hostname -I ; whoami ; getconf LONG_BIT ; apt update ; apt install -y build-essential software-properties-common git curl gdebi net-tools wget sqlite3 dirmngr nano lsb-release apt-transport-https -y

apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8 ; add-apt-repository 'deb [arch=amd64,arm64,ppc64el] http://mirror.biznetgio.com/mariadb/repo/10.4/ubuntu bionic main'
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
apt-get update ; apt-get install nodejs yarn zlib1g-dev build-essential libpq-dev libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev libffi-dev mariadb-server mariadb-client -y

systemctl start nginx mariadb ; systemctl enable nginx mariadb ; mysql_secure_installation

mysql -u root -p
create database db;
grant all on db.* to 'dbuser'@'localhost' identified by 'dbpass';
flush privileges;
quit

cd ~/ ; wget https://github.com/Mailtrain-org/mailtrain/archive/master.zip
unzip master.zip ; mv mailtrain-master mailtrain
cp ~/mailtrain/config/default.toml ~/mailtrain/config/production.toml
nano ~/mailtrain/config/production.toml
cd ~/mailtrain ; npm install --production


nano /etc/systemd/system/mailtrain.service
[Unit]
Description=Mailtrain Server
Requires=mariadb.service
After=syslog.target network.target

[Service]
Environment="NODE_ENV=production"
WorkingDirectory=/root/mailtrain
ExecStart=/usr/bin/node index.js
Type=simple
Restart=always
RestartSec=10
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=mailtrain

[Install]
WantedBy=multi-user.target

systemctl daemon-reload ; systemctl enable mailtrain ; systemctl start mailtrain ; systemctl status mailtrain

apt install nginx -y
nano /etc/nginx/conf.d/yourdomain.conf
server {
    listen [::]:80;
    listen 80;
    server_name www.yourdomain.com;

    location / {
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_pass http://127.0.0.1:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_next_upstream error timeout http_502 http_503 http_504;
    }
}
rm /etc/nginx/sites-enabled/default
nginx -t  ; echo "192.168.1.50 www.yourdomain.com" >> /etc/hosts ; systemctl restart nginx  
http://www.yourdomain.com
Username: admin | Password: test

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

No comments:

Post a Comment