No description
| amavisd | ||
| dovecot | ||
| nginx | ||
| opendkim | ||
| pam.d | ||
| php | ||
| postfix | ||
| root | ||
| skel | ||
| systemd/system | ||
| procmailrc | ||
| README.md | ||
Base Config
Notes:
- The Mail Server requires SSL certificates
- Occurrences of
REPLACEME.TLDwithout comments stating otherwise should have the FQDN substituted for it - Occurrences of
REPLACEMEwithout comments stating otherwise should have the FQDN without the TLD substituted for it
Swap File
- Run
dd if=/dev/zero of=/swapfile bs=1M count=2048thenchmod 600 /swapfilefollowed bymkswap /swapfileandswapon /swapfile - Set the system up to mount the swap file at boot by adding
/swapfile none swap defaults 0 0to the bottom of/etc/fstab
Web Server
Package Requirements for Web Server
nginx php php-apcu-bc php-fpm php-composer php-gd php-imap php-intl php-memcached php-geoip geoip-database geoip-database-extra memcached mariadb npm certbot certbot-nginx
Folders for Web Server
nginx php systemd
Setup Instructions for Web Server
- Install the packages in the
Package Requirementsabove - Copy the folders above that aren't already configured to their equivalent location in
/etc - In
/etc/nginx/sites-available/REPLACEME.TLD.confand/root/letsencrypt.sh - Rename
/etc/nginx/sites-available/REPLACEME.TLD.conf - Add your site files to
/srv/http/REPLACEME.TLDwhere public assets are located in/srv/http/REPLACEME.TLD/public - Create a symlink from
/etc/nginx/sites-available/REPLACEME.tld.confto/etc/nginx/sites-enabled/REPLACEME.tld.conf - Run
openssl dhparam -out /etc/nginx/dhparam.pem 4096to generate the diffie-hellman parameter - Run
systemctl start php-fpm nginxto start the web services andsystemctl status php-fpmandsystemctl status nginxto check for errors - If there were no errors in the previous command, run
systemctl enable php-fpm nginxto enable the web services at boot - Ensure the public web directory exists, update the list of domains in
/root/letsencrypt.shand then run it to generate the SSL certificates - Run
systemctl start certbot-renewal.timerandsystemctl enable certbot-renewal.timerto start and enable the auto-renewal process
MySQL Config
- Run
mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql - Run
systemctl start mysqldandsystemctl enable mysqldto start mysqld and enable it at boot - Run
mysql_secure_installation. - Create a new password.
- Say
yesto everything (e.g. "Remove anonymous users? Disallow root logging remotely? Remove test database and access to it? Reload privilege tables now?")
Mail Server
Package Requirements for Mail Server
dovecot postfix procmail opendkim amavisd-new spamassassin unrar p7zip
Folders for Mail Server
amavisd dovecot pam.d postfix procmailrc skel systemd opendkim
Setup Instructions for Mail Server
- Install the packages in the
Package Requirementsabove - Copy the folders above that aren't already configured to their equivalent location in
/etc - Add an A DNS record for the FQDN and a hostname for the server
- Set the hostname of the server with
hostnamectl set-hostname SOMETHING.REPLACEME.TLDwhereSOMETHINGis a unique name for the server andREPLACEME.TLDis the domain. This will be the server's new hostname. - Add the hostname of the server to the end of the line starting with
127.0.0.1in/etc/hosts - In
/etc/amavisd/amavisd.conf,/etc/dovecot/dovecot.confand/etc/opendkim/opendkim.confreplace occurrences ofREPLACEME.TLDwith the domain, and occurrences ofREPLACEMEwith the first part of the domain - In
/etc/postfix/main.cfreplaceSOMETHING.REPLACEME.TLDwith the hostname of the server andREPLACEME.TLDwith the domain - Run
opendkim-genkey -r -s REPLACEME -d REPLACEME.TLDwhereREPLACEME.TLDis the domain, andREPLACEMEis the first part of the domain - In
/etc/postfix/aliases, replace the instance ofREPLACEMEwith the user that should receive domain-level emails - Run
openssl dhparam -out /etc/dovecot/dh.pem 4096 - Run
newaliasesto update the aliases database with the contents of/etc/postfix/aliases - Run
sa-updateto update spamassassin - Run
systemctl start amavisd postfix dovecot opendkimto start the mail services andsystemctl status amavisd postfix dovecot opendkimto check for errors - If there were no errors in the previous command, run
systemctl enable amavisd postfix dovecot opendkimto enable the mail services at boot - Create an MX DNS record for
REPLACEME.TLDcontaining the hostname (REPLACEME.TLDcan usually be left out of the input field) - Create a TXT DNS record for the host
REPLACEME._domainkey.REPLACEME.TLDcontainingv=DKIM1; k=rsa; s=email; p=PASSWORD, replacing the occurrence ofREPLACEMEwith the first part of the domain,REPLACEME.TLDwith the full domain, andPASSWORDwith the string followingp=in/etc/opendkim/REPLACEME.txt(REPLACEME.TLDcan usually be left out of the input field) - Create a TXT DNS record for the host
REPLACEME.TLDcontainingv=spf1 mx -all(REPLACEME.TLDcan usually be left out of the input field) - Create a TXT DNS record for the host
_dmarc.REPLACEME.TLDcontainingv=DMARC1; p=none(REPLACEME.TLDcan usually be left out of the input field) - Set the reverse DNS record for the VPS to the hostname
- Add
postfix.serviceanddovecot.serviceto theExecStartPostservice reload in/etc/systemd/system/certbot-renewal.serviceand runsystemctl daemon-reload
Add Accounts
- Create an account by running
useradd -m -d /home/REPLACEME -s /bin/bash REPLACEME(replacingREPLACEMEwith the username associated with the mail account) - Set the password by running
passwd REPLACEME(replacingREPLACEMEwith the username associated with the mail account)