Question

Setting up a mail server on Ubuntu 18.04?

Hi person! :-)

I’ve been going through a lot of DO’s forums, OS forums, and server forums, so I’m listing everything here which may address many of the recommendations I’ve come across.

What I’m attempting: personalized family accounts - personal Wordpress websites available through /var/www/html, personal Rainloop e-mail through /var/www/rainloop, personal Filerun storage through /var/www/filerun. Oh, and some server games so we can play each other online through the server, but that’s not important here.

If you see server setup problems or file problems you would change - even if you’re unsure what’s going on with the domain - I’m happy to accept critiques on that, as well.

The current setup:

Ubuntu PhpMyAdmin on 18.04 droplet

  • phpMyAdmin installed and properly accessible via https://mydomain.tld/phpmyadmin
  • MySQL installed
  • Apache2 installed
  • Wordpress installed at /var/www/html and working properly at https://mydomain.tld
  • Rainloop installed at /var/www/rainloop but not working
  • LetsEncrypt SSL certificate

What I’m currently working on is the e-mail. My goal is to reach the webmail at https://email.mydomain.tld

  1. http://email.mydomain.tld just redirects to https://mydomain.tld
  2. With SSL it says, “This site can’t be reached”
  3. http://webmail.mydomain.tld breaks as if the domain doesn’t exist.
  4. With SSL it says, “The site can’t be reached”

(Rainloop’s website uses “webmail.mydomain.tld” for installation. Even if I can just get it installed, I’m still fine with using https://webmail.mydomain.tld, instead of “email”.)

Current DNS record setup:

Type | Hostname | Value | Priority | TTL (seconds)

MX records, added several priorities because I can’t figure it out MX | webmail.mydomain.tld | mail handled by DO.HOST.IP.ADDRESS | 0 | 14400 MX | webmail.mydomain.tld | mail handled by DO.HOST.IP.ADDRESS | 1 | 14400 MX | webmail.mydomain.tld | mail handled by DO.HOST.IP.ADDRESS | 5 | 14400 MX | webmail.mydomain.tld | mail handled by DO.HOST.IP.ADDRESS | 10 | 14400 MX | mydomain.tld | mail handled by DO.HOST.IP.ADDRESS | 0 | 14400 MX | mydomain.tld | mail handled by DO.HOST.IP.ADDRESS | 1 | 14400 MX | mydomain.tld | mail handled by DO.HOST.IP.ADDRESS | 5 | 14400 MX | mydomain.tld | mail handled by DO.HOST.IP.ADDRESS | 10 | 14400 MX | email.mydomain.tld | mail handled by DO.HOST.IP.ADDRESS | 0 | 14400 MX | email.mydomain.tld | mail handled by DO.HOST.IP.ADDRESS | 1 | 14400 MX | email.mydomain.tld | mail handled by DO.HOST.IP.ADDRESS | 5 | 14400 MX | email.mydomain.tld | mail handled by DO.HOST.IP.ADDRESS | 10 | 14400

(Once I can get it properly set up, I intend to start removing these one by one, to figure out which ones I need to keep.)

Wordpress installation, working properly CNAME | wordpress.mydomain.tld | is an alias of mydomain.tld. | 43200

For future storage installation (not there yet) CNAME | mydrive.domain.tld | is an alias of mydomain.tld. | 43200

Linking domain to host IP A | mydomain.tld | directs to DO.HOST.IP.ADDRESS | 3600

To fix “www” CNAME | www.mydomain.tld | is an alias of mydomain.tld. | 43200

Nameservers NS | mydomain.tld | directs to ns1.digitalocean.com. | 1800 NS | mydomain.tld | directs to ns2.digitalocean.com. | 1800 NS | mydomain.tld | directs to ns3.digitalocean.com. | 1800

##Current .htaccess and .conf Setups:

/var/www/.htaccess Options -Indexes

/var/www/html/.htaccess <Directory /var/www/> AllowOverride All </Directory>

RewriteCond %{HTTP_HOST} ^([^.]+).mail.mydomain.tld$ RewriteRule ^/(.*)$ http://mail.mydomain.tld/%1/$1 [L,R]

Options -Indexes DirectoryIndex index.php index.html /example.php

# BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress

/var/www/rainloop/.htaccess None yet, intend to edit once I’ve gotten it set up.

/etc/apache2/apache2.conf ServerName mydomain.tld

**rainloop.conf (VirtualHost :80) and rainloop-le-ssl.conf (VirtualHost :443) Both list the correct domain (ServerName email.mydomain.tld) and point to the correct folder (DocumentRoot /var/www/rainloop).

rainloop.conf

<VirtualHost *:80> ServerName email.mydomain.tld DocumentRoot “/var/www/rainloop/” ServerAdmin my@email.address

ErrorLog “/var/log/apache2/rainloop_error_log” (word just got italicized in this post because of underscores) TransferLog “/var/log/apache2/rainloop_access_log”

<Directory /> Options +Indexes +FollowSymLinks +ExecCGI AllowOverride All Order deny,allow Allow from all Require all granted </Directory>

rainloop-le-ssl.conf

<IfModule mod_ssl.c> <VirtualHost *:443> ServerName email.mydomain.tld DocumentRoot “/var/www/rainloop/” ServerAdmin my@email.address

ErrorLog “/var/log/apache2/rainloop_error_log” TransferLog “/var/log/apache2/rainloop_access_log”

<Directory /> Options +Indexes +FollowSymLinks +ExecCGI AllowOverride All Order deny,allow Allow from all Require all granted </Directory>

SSLCertificateFile /etc/letsencrypt/live/email.mydomain.tld/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/email.mydomain.tld/privkey.pem Include /etc/letsencrypt/options-ssl-apache.conf </VirtualHost> </IfModule>

</VirtualHost>

/etc/apache2/wordpress.conf <Directory /var/www/> Options FollowSymLinks </Directory>

If you see server setup problems or file problems you would change - even if you’re unsure what’s going on with the domain - I’m happy to accept critiques on that, as well.


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Accepted Answer

Okay, so I finally figured it out. For anyone else who wants it:

  1. I set the FQDN of email.mydomain.tld
  2. I deleted the other MX records, but kept just this one: MX | email.mydomain.tld | mail handled by DO.HOST.IP.ADDRESS | 0 | 14400
  3. I added CNAME: CNAME | email.domain.tld | is an alias of mydomain.tld. | 43200
  4. And then for the server to accept e-mails, I followed the instructions here: https://www.tecmint.com/install-postfix-mail-server-with-webmail-in-debian/

Nevermind, forget everything here. I’ve skipped over some steps. This did work at face value, but it didn’t work with receiving mail, nor did it allow for proper subdomaining. Reset everything - just going to keep working through it.

@stevenhost I did finally just Google it and set it properly.

Though I found out I needed Dovecot, Postfix, plus Rainloop. And I had missed the first two.

So I had Rainloop working, but could create users email accounts.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel