Install/Multicraft and Minecraft Server: Difference between revisions

From Playful Exploration
Jump to navigation Jump to search
 
(21 intermediate revisions by 2 users not shown)
Line 1: Line 1:
[[category:Install]]
= Install Multicraft on Debian 8 =
= Install Multicraft on Debian 8 =


Line 5: Line 6:


Open SSH shell. Elevate yourself to super user
Open SSH shell. Elevate yourself to super user
     su -
     su -


Update all existing software to latest
Update all existing software to latest
     apt-get -y update
     apt-get -y update
     apt-get -y upgrade
     apt-get -y upgrade


Set the system time zone.
    dpkg-reconfigure tzdata


== Install the apache2 web server ==
== Install the apache2 web server ==
Line 202: Line 203:
Install and Configure PHP
Install and Configure PHP


    apt-get install php5-fpm php5-mysql
apt-get install php5-fpm php5-mysql
    nano /etc/php5/fpm/php.ini # origin suggests to set cgi.fix_pathinfo=0
  pear install Mail Net_SMTP
    echo '<?php phpinfo(); ?>' > /var/www/html/phpinfo21.php
echo '<?php phpinfo(); ?>' > /var/www/html/phpinfo21.php
nano /etc/php5/fpm/php.ini
 
Modify / uncomment:
cgi.fix_pathinfo=0
include_path=.:/usr/share/php


Navigate to http://m.chaospage.com/phpinfo21.php to enure the php page runs correctly
Navigate to http://m.chaospage.com/phpinfo21.php to enure the php page runs correctly


== Install MediaWiki, on a Nginx Server ==
== Install MediaWiki, on a Nginx Server ==
Line 228: Line 233:


== Configure Postfix ==
== Configure Postfix ==
See https://www.rackspace.com/knowledge_center/article/basic-settings-in-the-postfix-maincf-file .
  nano /etc/postfix/main.cf
  nano /etc/postfix/main.cf


Line 237: Line 244:
  smtpd_tls_auth_only=yes
  smtpd_tls_auth_only=yes
  # Mail will be stored in users ~/mail directories
  # Mail will be stored in users ~/mail directories
  home_mailbox = mail/
  home_mailbox = Maildir/
  # From http://wiki2.dovecot.org/HowTo/PostfixAndDovecotSASL
  # From http://wiki2.dovecot.org/HowTo/PostfixAndDovecotSASL
  smtpd_sasl_type = dovecot
  smtpd_sasl_type = dovecot
Line 259: Line 266:
  # DKIM
  # DKIM
  milter_default_action = accept
  milter_default_action = accept
  milter_protocol = 6
  milter_protocol       = 6
  smtpd_milters = inet:localhost:12345
  smtpd_milters         = inet:localhost:8891
  non_smtpd_milters = inet:localhost:12345
  non_smtpd_milters     = $smtpd_milters


  nano /etc/postfix/master.cf
  nano /etc/postfix/master.cf
Line 296: Line 303:


== Configure Dovecot for IMAP ==
== Configure Dovecot for IMAP ==
nano /usr/share/dovecot/conf.d/10-ssl.conf
See http://serverfault.com/questions/654789/maildir-new-has-messages-but-inbox-is-empty .
The dovecot.conf file includes all in /etc/dovecot/conf.d/*.conf.  However it's easier to have it all in dovecot.conf:
doveconf -n > /etc/dovecot/dovecot.conf.new  # dump all overrides into new file
mv /etc/dovecot/dovecot.conf /etc/dovecot/dovecot.conf.orig
mv /etc/dovecot/dovecot.conf.new /etc/dovecot/dovecot.conf
nano /etc/dovecot/dovecot.conf


Set:
Change the mail_location to use Maildir
mail_location = maildir:~/Maildir
 
Replace the line *ssl = no* with:
service imap-login {
  inet_listener imap {
    port = 0
  }
  inet_listener imaps {
    port = 993
  }
}
disable_plaintext_auth = yes
  ssl = required
  ssl = required
  ssl_ca = </etc/letsencrypt/live/playfulexploration.com/chain1.pem
  ssl_ca = </etc/letsencrypt/live/playfulexploration.com/chain.pem
  ssl_cert = </etc/letsencrypt/live/playfulexploration.com/cert1.pem
  ssl_cert = </etc/letsencrypt/live/playfulexploration.com/cert.pem
  ssl_key = </etc/letsencrypt/live/playfulexploration.com/privkey1.pem
  ssl_key = </etc/letsencrypt/live/playfulexploration.com/privkey.pem
 
   
Then:
  nano /usr/share/dovecot/conf.d/10-master.conf
 
Uncomment and change this section:
  service auth {
  service auth {
  ...
  # Postfix smtp-auth
   unix_listener /var/spool/postfix/private/auth {
   unix_listener /var/spool/postfix/private/auth {
     mode = 0660
     mode = 0660
    # Assuming the default Postfix user and group
     user = postfix
     user = postfix
     group = postfix
     group = postfix
  }
  }
}


Install DomainKeys Identified Mail (DKIM)
Restart postfix and dovecot and check that ports (25, 587 and 993) are listening:
  apt-get install opendkim opendkim-tools
  systemctl restart postfix
  nano /etc/opendkim.conf
systemctl restart dovecot
  netstat -lnpt


Add these:
These two commands:
  KeyTable          /etc/opendkim/KeyTable
  # not working: openssl s_client -starttls smtp -crlf -connect playfulexploration.com:587
  SigningTable      /etc/opendkim/SigningTable
  openssl s_client -connect playfulexploration.com:993 -CApath /etc/ssl/certs/
ExternalIgnoreList /etc/opendkim/TrustedHosts
InternalHosts      /etc/opendkim/TrustedHosts
LogWhy yes


Then:
Should return 4th line from buttom
mkdir /etc/opendkim
  Verify return code: 0 (ok)
nano /etc/opendkim/TrustedHosts


Enter all domains, hostnames or IP addresses
== Install DomainKeys Identified Mail (DKIM) ==
127.0.0.1
localhost
playfulexploration.com
158.69.197.154


nano /etc/default/opendkim
See: https://www.tty1.net/blog/2014/dkim-with-postfix_en.html
Skip!!Uncomment:
SOCKET="inet:12345@localhost" # listen on loopback on port 12345
Set:
SOCKET="local:/var/spool/postfix/var/run/opendkim/opendkim.sock"


  mkdir /var/spool/postfix/var
  DOM='playfulexploration.com'
  mkdir /var/spool/postfix/var/run/
  apt-get install opendkim opendkim-tools
mkdir /var/spool/postfix/var/run/opendkim
chown opendkim:opendkim /var/spool/postfix/var/run/opendkim
  nano /etc/opendkim.conf
  nano /etc/opendkim.conf
Set:
 
  Domain = playfulexploration.com
Replace content with:
  KeyFile = /etc/opendkim/keys/playfulexploration.com/default.private
AutoRestart            Yes
AutoRestartRate        10/1h
LogWhy                  Yes
Syslog                  Yes
SyslogSuccess          Yes
Mode                    sv
Canonicalization        relaxed/simple
ExternalIgnoreList      refile:/etc/opendkim/TrustedHosts
  InternalHosts          refile:/etc/opendkim/TrustedHosts
  KeyTable                refile:/etc/opendkim/KeyTable
  SigningTable            refile:/etc/opendkim/SigningTable
SignatureAlgorithm      rsa-sha256
Socket                  inet:8891@localhost
PidFile                /var/run/opendkim/opendkim.pid
UMask                  022
UserID                  opendkim:opendkim
TemporaryDirectory      /var/tmp


Generate the pair of public/private keys:
Generate the pair of public/private keys:
  mkdir -p /etc/opendkim/keys/playfulexploration.com
  mkdir -p /etc/opendkim/keys/$DOM
  cd /etc/opendkim/keys/playfulexploration.com
  cd /etc/opendkim/keys/$DOM
  opendkim-genkey -s default -d playfulexploration.com
  opendkim-genkey -s default -d $DOM
  chown opendkim:opendkim default.private
  chown opendkim:opendkim default.private
cat /etc/opendkim/keys/$DOM/default.txt


echo 'default._domainkey.playfulexploration.com mydomain.com:default:/etc/opendkim/keys/playfulexploration.com/default.private' >/etc/opendkim/KeyTable
Add the text to the domain.
echo 'playfulexploration.com default._domainkey.playfulexploration.com' >/etc/opendkim/SigningTable
cat /etc/opendkim/keys/playfulexploration.com/default.txt


The output needs to be added as an DNS entry of type TXT:
Then:
  default._domainkey     IN      TXT    ( "v=DKIM1; k=rsa; "
  echo "default._domainkey.$DOM $DOM:default:/etc/opendkim/keys/$DOM/default.private" >/etc/opendkim/KeyTable
          "p=MIG...QAB" )  ; ----- DKIM key default for playfulexploration.com
echo "*@$DOM default._domainkey.$DOM" >/etc/opendkim/SigningTable
echo "127.0.0.1"                     > /etc/opendkim/TrustedHosts
echo "localhost"                      >>/etc/opendkim/TrustedHosts
echo "*.$DOM"                        >>/etc/opendkim/TrustedHosts
chown opendkim:opendkim /etc/opendkim/KeyTable
chown opendkim:opendkim /etc/opendkim/SigningTable
chown opendkim:opendkim /etc/opendkim/TrustedHosts
 
Restart services and check that ports (25, 587, 993 and 8891) are listening: :
  service opendkim restart
#chkconfig opendkim on
service dovecot restart
service postfix restart
netstat -lnpt


Check DNS records, they should return the the content of default.txt:
Check DNS records, they should return the the content of default.txt:
  dig default._domainkey.playfulexploration.com TXT
  dig default._domainkey.$DOM TXT
dig @ns1.dot5hosting.com default._domainkey.$DOM TXT   #check specific DNS


Create the sender_access file
Do reverse DNS check:
  touch /etc/postfix/sender_access.db
  dig -x +short 158.69.197.154
postmap /etc/postfix/sender_access.db
touch /etc/postfix/recipient_access.db
postmap /etc/postfix/recipient_access.db


Send an empty email to check-auth@verifier.port25.com to check the spammyness:
Send an empty email to check-auth@verifier.port25.com to check the spammyness:
Line 388: Line 422:
  SpamAssassin check: ham
  SpamAssassin check: ham


Do reverse DNS check:
== Add email user ==
  dig -x +short 158.69.197.154
USR=peter
useradd $USR
passwd $USR
 
mkdir /home/$USR
chown $USR:$USR /home/$USR
#dovecot creates the directories with proper permissions
#mkdir /home/$USR/Maildir
#chown $USR:$USR /home/$USR/Maildir
#chmod -R 700 /home/$USR/Maildir
service dovecot restart
addgroup $USR mail
 
Setup aliases
nano /etc/aliases
 
Update the alias database
newaliases
 
== Add a catch-all email ==
See http://tecadmin.net/setup-catch-all-email-account-in-postfix .
 
if /etc/postfix/virtual doesn't exist yet then simply create.
USR=peter
  DOM=playfulexploration.com
if [ ! -f "/etc/postfix/virtual" ]; then echo @$DOM $USR > /etc/postfix/virtual; fi
nano /etc/postfix/virtual
 
Add this to the beginning.  Add exceptions below if needed.
@playfulexploration.com peter
 
Then:
nano /etc/postfix/main.cf
 
Add this if not already there:
virtual_alias_maps = hash:/etc/postfix/virtual
 
Run:
postmap /etc/postfix/virtual
service postfix reload

Latest revision as of 06:16, 25 May 2016

Install Multicraft on Debian 8

Prepare

Open SSH shell. Elevate yourself to super user

   su -

Update all existing software to latest

   apt-get -y update
   apt-get -y upgrade

Set the system time zone.

   dpkg-reconfigure tzdata

Install the apache2 web server

Note: Don't need this when installing Nginx as shown further below.

See also: https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-debian-8

   apt-get -y install apache2 libapache2-mod-php5 php5-sqlite php5-gd
   apt-get -y install zip unzip
   service apache2 restart

At this point the web server is running. Web browser should show a default page.

Install Java from Oracle

   echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee /etc/apt/sources.list.d/webupd8team-java.list
   echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list
   apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886
   apt-get update
   apt-get -y install oracle-java8-installer


Install Multicraft

   wget http://www.multicraft.org/download/linux64 -O multicraft.tar.gz
   tar xvzf multicraft.tar.gz
   cd multicraft
   ./setup.sh               #follow the instructions, defaults are ok except for
                            #the web path use /var/www/html

Complete the browser based installation as instructed.

Hide the 'protected' folder, this download test shall fail: http://158.69.197.154/multicraft/protected/data/panel/schema.mysql.sql

   nano /etc/apache2/sites-enabled/000-default.conf

Add a section for /var/www/html

   <Directory /var/www/html>
       Options -Indexes +FollowSymLinks +MultiViews
       AllowOverride All
       Order allow,deny
       allow from all
   </Directory>

Restart apache:

   service apache2 restart
   # Navigate to http://yourserver/multicraft/setup.php and run the installer.

Start Multicraft:

   /home/minecraft/multicraft/bin/multicraft -v start

If all looks good then delete the setup.php file as instructed.

   rm /var/www/html/multicraft/setup.php


Fix the BukGet list by fixing some php files

   cd /var/www/html/multicraft/
   wget http://multicraft.org/files/bg_update_2014.02.zip
   unzip bg_update_2014.02.zip
   rm bg_update_2014.02.zip


Make Multicraft auto start after reboot

   nano /etc/rc.local

Add this to the end of the file before the exit(0) command:

   /home/minecraft/multicraft/bin/multicraft -v start


Create a server and add the craftbukkit plugins if choice

...


Add Group Manager

This manually adds the the group permissions plugin which doesn't come with the multicraft repository. See http://wiki.ess3.net/wiki/Group_Manager.

   cd /home/minecraft/multicraft/servers/server4/plugins/  # change server4 to actual server location
   wget https://github.com/essentials/Essentials/releases/download/gm-final/EssentialsGroupManager.jar
   chown mc4:mc4 EssentialsGroupManager.jar  # change mc4 to match the user of the other jar files
   chmod 770 EssentialsGroupManager.jar

Using multicraft restart the mc server. This will create a GroupMananger directory in the plugins folder.

   cd /home/minecraft/multicraft/servers/server4/plugins/  # change server4 to actual server location
   cd GroupManager/
   rm globalgroups.yml
   wget https://raw.githubusercontent.com/essentials/Essentials/release/EssentialsGroupManager/src/globalgroups.yml
   chown mc4:mc4 globalgroups.yml    # change mc4 to match the user of the other jar files
   cd worlds/world/
   rm groups.yml
   wget https://raw.githubusercontent.com/essentials/Essentials/release/EssentialsGroupManager/src/groups.yml
   
   chmod 770 *.jar
   chown mc4:mc4 *                   # change server4 to actual server location
   cd /home/minecraft/_
   # rm *
   wget http://dev.bukkit.org/media/files/780/922/Essentials.zip
   wget http://dev.bukkit.org/media/files/780/921/Essentials-extra.zip
   unzip Essentials.zip
   unzip Essentials-extra.zip
   rm EssentialsProtect.jar   # this one prevents deleting block, not sure why, so remove it for now
   chmod 770 *.jar
   chown mc4:mc4 *                   # change server4 to actual server location
   mv *.jar /home/minecraft/multicraft/servers/server4/plugins/


Install spigot essentials

See http://www.instructables.com/id/How-to-install-Essentials-18-for-BukkitSpigot/?ALLSTEPS

   cd /home/minecraft/multicraft/servers/server4/plugins/  # change server4 to actual server location
   wget https://hub.spigotmc.org/jenkins/job/Spigot-Essentials/lastSuccessfulBuild/artifact/Essentials/target/Essentials-2.x-SNAPSHOT.jar -O Essentials-2.jar
   wget https://hub.spigotmc.org/jenkins/job/Spigot-Essentials/lastSuccessfulBuild/artifact/EssentialsSpawn/target/EssentialsSpawn-2.x-SNAPSHOT.jar -O EssentialsSpawn.jar
   wget https://hub.spigotmc.org/jenkins/job/Spigot-Essentials/lastSuccessfulBuild/artifact/EssentialsAntiBuild/target/EssentialsAntiBuild-2.x-SNAPSHOT.jar -O EssentialsAntiBuild.jar
   wget https://hub.spigotmc.org/jenkins/job/Spigot-Essentials/lastSuccessfulBuild/artifact/EssentialsChat/target/EssentialsChat-2.x-SNAPSHOT.jar -O EssentialsChat.jar
   wget https://hub.spigotmc.org/jenkins/job/Spigot-Essentials/lastSuccessfulBuild/artifact/EssentialsGeoIP/target/EssentialsGeoIP-2.x-SNAPSHOT.jar -O EssentialsGeoIP.jar
   wget https://hub.spigotmc.org/jenkins/job/Spigot-Essentials/lastSuccessfulBuild/artifact/EssentialsProtect/target/EssentialsProtect-2.x-SNAPSHOT.jar -O EssentialsProtect.jar
   wget https://hub.spigotmc.org/jenkins/job/Spigot-Essentials/lastSuccessfulBuild/artifact/EssentialsXMPP/target/EssentialsXMPP-2.x-SNAPSHOT.jar -O EssentialsXMPP.jar
   # wget https://hub.spigotmc.org/jenkins/job/Spigot-Essentials/lastSuccessfulBuild/artifact/EssentialsGeoIP/target/original-EssentialsGeoIP-2.x-SNAPSHOT.jar -O original-EssentialsGeoIP.jar
   # wget https://hub.spigotmc.org/jenkins/job/Spigot-Essentials/lastSuccessfulBuild/artifact/EssentialsXMPP/target/original-EssentialsXMPP-2.x-SNAPSHOT.jar -O original-EssentialsXMPP.jar


Add BuyCraft

See https://server.buycraft.net/setup.

   cd /home/minecraft/multicraft/servers/server4/plugins/  # change server4 to actual server location
   wget http://dev.bukkit.org/media/files/900/161/Buycraft.jar

past this into the mc console

   /buycraft secret 786d18a6060ac247667d9380f550202452e7e8f8
   

Install LEMP, linux nginx mysql php

See: https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-on-debian-7 See: http://stackoverflow.com/questions/25591040/nginx-serves-php-files-as-downloads-instead-of-executing-them

   apt-get update
   apt-get install mysql-server    #leave passwords blank
   mysql_install_db
   /usr/bin/mysql_secure_installation
   apt-get install nginx-full
   service nginx start
   nano /etc/nginx/sites-available/default

look for:

   [...]
   server {
       listen   80;

add index.php to index

   index index.php index.html index.htm;

change the server name to server name or ip

   server_name m.chaospage.com;

Change the "location ~ \.php$ {" section, uncomment include snippets/fastcgi-php.conf

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

also protect the multicraft protected folder

   location /multicraft/protected {
       deny all;
       return 404;
   }

Install and Configure PHP

apt-get install php5-fpm php5-mysql
pear install Mail Net_SMTP
echo '<?php phpinfo(); ?>' > /var/www/html/phpinfo21.php
nano /etc/php5/fpm/php.ini

Modify / uncomment:

cgi.fix_pathinfo=0
include_path=.:/usr/share/php

Navigate to http://m.chaospage.com/phpinfo21.php to enure the php page runs correctly

Install MediaWiki, on a Nginx Server

See: http://technology.mattrude.com/2012/02/configuring-mediawiki-to-be-used-with-nginx/

Install a Mail Server on Debian 8 Jessie with Postfix and Dovecot as smtp/imap mail server

See: http://appbead.com/blog/how-to-setup-mail-server-on-debian-8-jessie-with-postfix-dovecot-1.html

See: https://scaron.info/blog/debian-mail-postfix-dovecot.html

Install Postfix and Dovecot

apt-get install dovecot-imapd dovecot-lmtpd
apt-get install postfix postgrey postfix-policyd-spf-python
# choose 'Internet Site'
# choose playfulexploration.com
apt-get purge exim4 exim4-*

Configure Postfix

See https://www.rackspace.com/knowledge_center/article/basic-settings-in-the-postfix-maincf-file .

nano /etc/postfix/main.cf

Change smtpd_tsl.. values:

smtpd_tls_cert_file =/etc/letsencrypt/live/playfulexploration.com/cert1.pem
smtpd_tls_key_file  =/etc/letsencrypt/live/playfulexploration.com/privkey1.pem
smtpd_tls_CAfile    =/etc/letsencrypt/live/playfulexploration.com/chain1.pem
smtpd_use_tls=yes
smtpd_tls_auth_only=yes
# Mail will be stored in users ~/mail directories
home_mailbox = Maildir/
# From http://wiki2.dovecot.org/HowTo/PostfixAndDovecotSASL
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_auth_enable = yes

Also change the smtpd_recipient_restrictions and add policy-spf_time_limit:

smtpd_recipient_restrictions =
   permit_sasl_authenticated,
   reject_invalid_hostname,
   reject_unknown_recipient_domain,
   reject_unauth_destination,
   reject_rbl_client sbl.spamhaus.org,
   check_policy_service unix:private/policy-spf,
   check_sender_access hash:/etc/postfix/sender_access,
   check_recipient_access hash:/etc/postfix/recipient_access,
   permit
policy-spf_time_limit = 3600s

And add this to the end:

# DKIM
milter_default_action = accept
milter_protocol       = 6
smtpd_milters         = inet:localhost:8891
non_smtpd_milters     = $smtpd_milters
nano /etc/postfix/master.cf

uncomment the lines starting with #submission and #smtps:

submission inet n       -       -       -       -       smtpd
 -o syslog_name=postfix/submission
 -o smtpd_tls_security_level=encrypt
 -o smtpd_sasl_auth_enable=yes
 -o smtpd_reject_unlisted_recipient=no
 -o smtpd_client_restrictions=$mua_client_restrictions
 -o smtpd_helo_restrictions=$mua_helo_restrictions
 -o smtpd_sender_restrictions=$mua_sender_restrictions
 -o smtpd_recipient_restrictions=
 -o smtpd_relay_restrictions=permit_sasl_authenticated,reject
 -o milter_macro_daemon_name=ORIGINATING
smtps     inet  n       -       -       -       -       smtpd
 -o syslog_name=postfix/smtps
 -o smtpd_tls_wrappermode=yes
 -o smtpd_sasl_auth_enable=yes
 -o smtpd_reject_unlisted_recipient=no
 -o smtpd_client_restrictions=$mua_client_restrictions
 -o smtpd_helo_restrictions=$mua_helo_restrictions
 -o smtpd_sender_restrictions=$mua_sender_restrictions
 -o smtpd_recipient_restrictions=
 -o smtpd_relay_restrictions=permit_sasl_authenticated,reject
 -o milter_macro_daemon_name=ORIGINATING

Also, add the following line at the bottom of the file:

dovecot   unix  -       n       n       -       -       pipe
  flags=DRhu user=email:email argv=/usr/lib/dovecot/deliver -f ${sender} -d ${recipient}
policy-spf  unix  -       n       n       -       -       spawn
  user=nobody argv=/usr/bin/policyd-spf

Configure Dovecot for IMAP

See http://serverfault.com/questions/654789/maildir-new-has-messages-but-inbox-is-empty . The dovecot.conf file includes all in /etc/dovecot/conf.d/*.conf. However it's easier to have it all in dovecot.conf:

doveconf -n > /etc/dovecot/dovecot.conf.new   # dump all overrides into new file
mv /etc/dovecot/dovecot.conf /etc/dovecot/dovecot.conf.orig
mv /etc/dovecot/dovecot.conf.new /etc/dovecot/dovecot.conf
nano /etc/dovecot/dovecot.conf

Change the mail_location to use Maildir

mail_location = maildir:~/Maildir

Replace the line *ssl = no* with:

service imap-login {
  inet_listener imap {
    port = 0
  }
  inet_listener imaps {
    port = 993
  }
}

disable_plaintext_auth = yes
ssl = required
ssl_ca = </etc/letsencrypt/live/playfulexploration.com/chain.pem
ssl_cert = </etc/letsencrypt/live/playfulexploration.com/cert.pem
ssl_key = </etc/letsencrypt/live/playfulexploration.com/privkey.pem

service auth {
  unix_listener /var/spool/postfix/private/auth {
    mode = 0660
    # Assuming the default Postfix user and group
    user = postfix
    group = postfix
  }
}

Restart postfix and dovecot and check that ports (25, 587 and 993) are listening:

systemctl restart postfix
systemctl restart dovecot
netstat -lnpt

These two commands:

# not working: openssl s_client -starttls smtp -crlf -connect playfulexploration.com:587
openssl s_client -connect playfulexploration.com:993 -CApath /etc/ssl/certs/

Should return 4th line from buttom

 Verify return code: 0 (ok)

Install DomainKeys Identified Mail (DKIM)

See: https://www.tty1.net/blog/2014/dkim-with-postfix_en.html

DOM='playfulexploration.com'
apt-get install opendkim opendkim-tools
nano /etc/opendkim.conf

Replace content with:

AutoRestart             Yes
AutoRestartRate         10/1h
LogWhy                  Yes
Syslog                  Yes
SyslogSuccess           Yes
Mode                    sv
Canonicalization        relaxed/simple
ExternalIgnoreList      refile:/etc/opendkim/TrustedHosts
InternalHosts           refile:/etc/opendkim/TrustedHosts
KeyTable                refile:/etc/opendkim/KeyTable
SigningTable            refile:/etc/opendkim/SigningTable
SignatureAlgorithm      rsa-sha256
Socket                  inet:8891@localhost
PidFile                 /var/run/opendkim/opendkim.pid
UMask                   022
UserID                  opendkim:opendkim
TemporaryDirectory      /var/tmp

Generate the pair of public/private keys:

mkdir -p /etc/opendkim/keys/$DOM
cd /etc/opendkim/keys/$DOM
opendkim-genkey -s default -d $DOM
chown opendkim:opendkim default.private
cat /etc/opendkim/keys/$DOM/default.txt

Add the text to the domain.

Then:

echo "default._domainkey.$DOM $DOM:default:/etc/opendkim/keys/$DOM/default.private" >/etc/opendkim/KeyTable
echo "*@$DOM default._domainkey.$DOM" >/etc/opendkim/SigningTable
echo "127.0.0.1"                      > /etc/opendkim/TrustedHosts
echo "localhost"                      >>/etc/opendkim/TrustedHosts
echo "*.$DOM"                         >>/etc/opendkim/TrustedHosts
chown opendkim:opendkim /etc/opendkim/KeyTable
chown opendkim:opendkim /etc/opendkim/SigningTable
chown opendkim:opendkim /etc/opendkim/TrustedHosts

Restart services and check that ports (25, 587, 993 and 8891) are listening: :

service opendkim restart
#chkconfig opendkim on
service dovecot restart
service postfix restart
netstat -lnpt

Check DNS records, they should return the the content of default.txt:

dig default._domainkey.$DOM TXT
dig @ns1.dot5hosting.com default._domainkey.$DOM TXT   #check specific DNS

Do reverse DNS check:

dig -x +short 158.69.197.154

Send an empty email to check-auth@verifier.port25.com to check the spammyness:

echo "Subject: Test" > email.txt
sendmail check-auth@verifier.port25.com < email.txt

It will return an email like this:

SPF check:          pass
DomainKeys check:   neutral
DKIM check:         pass
DKIM check:         pass
Sender-ID check:    pass
SpamAssassin check: ham

Add email user

USR=peter
useradd $USR
passwd $USR
mkdir /home/$USR
chown $USR:$USR /home/$USR
#dovecot creates the directories with proper permissions
#mkdir /home/$USR/Maildir
#chown $USR:$USR /home/$USR/Maildir
#chmod -R 700 /home/$USR/Maildir
service dovecot restart
addgroup $USR mail

Setup aliases

nano /etc/aliases

Update the alias database

newaliases

Add a catch-all email

See http://tecadmin.net/setup-catch-all-email-account-in-postfix .

if /etc/postfix/virtual doesn't exist yet then simply create.

USR=peter
DOM=playfulexploration.com
if [ ! -f "/etc/postfix/virtual" ]; then echo @$DOM $USR > /etc/postfix/virtual; fi
nano /etc/postfix/virtual

Add this to the beginning. Add exceptions below if needed.

@playfulexploration.com peter

Then:

nano /etc/postfix/main.cf

Add this if not already there:

virtual_alias_maps = hash:/etc/postfix/virtual

Run:

postmap /etc/postfix/virtual
service postfix reload