3

How to Install Mailtrain Newsletter Application on Debian 9

 2 years ago
source link: https://www.vultr.com/docs/how-to-install-mailtrain-newsletter-application-on-debian-9
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
<?xml encoding="utf-8" ??>

Mailtrain is an open-source self hosted newsletter app built on Node.js and MySQL/MariaDB. Mailtrain's source is on GitHub. This guide will show you how to install Mailtrain on a fresh Debian 9 Vultr instance.

Requirements

Software Requirements:

  • Node.js version 7 or greater
  • MySQL version 5.5
  • Nginx
  • Redis (optional)

Hardware Requirements:

  • 1 vCPU
  • 1024 MB RAM

Check the Debian version.

lsb_release -ds
# Debian GNU/Linux 9.5 (stretch)

Ensure that your system is up to date.

apt update && apt upgrade -y

Install required packages.

apt install -y sudo dirmngr build-essential unzip git

Create a new non-root user account with sudo access and switch to it.

adduser johndoe --gecos "John Doe"
usermod -aG sudo johndoe
su - johndoe

NOTE: Replace johndoe with your username.

Set up the timezone.

sudo dpkg-reconfigure tzdata

Install Node.js and NPM

Install Node.js by utilizing the NodeSource APT repository.

curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt install -y nodejs

Check the Node.js and npm versions.

node -v && npm -v
# v8.11.3
# 5.6.0

Install MariaDB

Install MariaDB.

sudo apt install -y mariadb-server

Check the version.

mysql --version

Run the mysql_secure installation script to improve MariaDB security.

sudo mysql_secure_installation

Connect to the MariaDB shell as the root user.

sudo mysql -u root -p
# Enter password:

Create an empty MariaDB database and user, and remember the credentials.

CREATE DATABASE dbname;
GRANT ALL ON dbname.* TO 'username' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
EXIT;

Install Nginx

Install Nginx.

sudo apt install -y nginx

Check the version.

sudo nginx -v

Configure Nginx as an HTTP or HTTPS (if you use SSL) reverse proxy for Mailtrain application. Run sudo vim /etc/nginx/sites-available/mailtrain.conf and add the following configuration.

server {

  listen [::]:80;
  listen 80;

  server_name example.com;

  charset utf-8;
  client_max_body_size 50M;


  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;
  }

}

Activate the new mailtrain.conf configuration by linking the file to the sites-enabled directory.

sudo ln -s /etc/nginx/sites-available/mailtrain.conf /etc/nginx/sites-enabled/

Test the configuration.

sudo nginx -t

Reload Nginx.

sudo systemctl reload nginx.service

Install Mailtrain

Create an empty document root folder where Mailtrain should be installed.

sudo mkdir -p /var/www/mailtrain

Navigate to the document root folder.

cd /var/www/mailtrain

Change ownership of the /var/www/mailtrain folder to user johndoe.

sudo chown -R johndoe:johndoe /var/www/mailtrain

Download and unzip Mailtrain.

wget https://github.com/Mailtrain-org/mailtrain/archive/master.zip
unzip master.zip
rm master.zip
mv mailtrain-master/* . && mv mailtrain-master/.* .
rmdir mailtrain-master

Run npm install --production in the Mailtrain folder to install required dependencies.

Copy config/default.toml as config/production.toml and update MySQL and any other settings in it.

cp config/default.toml config/production.toml
vim config/production.toml

Run the server.

NODE_ENV=production npm start

Installation is complete. Login with the username admin and the password test. Once logged in, update the user information and password via the Mailtrain web interface.

Want to contribute?

You could earn up to $600 by adding new articles


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK