Friday, September 11, 2020

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

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

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

 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 apache2 -y

systemctl start apache2 mariadb ; systemctl enable apache2 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

a2enmod proxy proxy_http rewrite
leafpad /etc/apache2/sites-available/yourdomain.conf &>/dev/null
<VirtualHost *:80>
    ServerName www.yourdomain.com
    ServerAdmin admin@yourdomain.com
    ProxyPreserveHost On
    ProxyPass / http://127.0.0.1:3000/
    ProxyPassReverse / http://127.0.0.1:3000/
    TransferLog /var/log/apache2/yourdomain_access.log
    ErrorLog /var/log/apache2/yourdomain_error.log
</VirtualHost>

a2ensite yourdomain ; a2dissite 000-default.conf  ; apache2ctl configtest ; echo "192.168.1.50 www.yourdomain.com" >> /etc/hosts ; systemctl reload apache2

http://www.yourdomain.com
Username: admin | Password: test

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

No comments:

Post a Comment