Prerequisites
- An Ubuntu 14.04 mail server configured with the guide from DigitalOcean or Linode. Any other MySQL configuration requires edits to PostMaster's database models. Paid support for this is available.
- If you are installing PostMaster on a separate server, you'll need a clean Ubuntu 14.04 installation.
MySQL Preparation
-
Start by logging into the MySQL server that your mail server uses:
mysql -u root -p
-
Once you've logged into MySQL, create a PostMaster MySQL user that has privileges to edit the tables for the servermail database. If you are installing PostMaster on a server other than where your mail server's MySQL server is installed, replace '127.0.0.1' with the server's IP address or DNS that is going to host PostMaster:
GRANT ALL PRIVILEGES ON servermail.* TO 'postmasteruser'@'127.0.0.1' IDENTIFIED BY 'password_changeme';
-
Exit from MySQL:
exit
-
If you are installing PostMaster on a server other than where your mail server's MySQL server is installed, make sure that bind-address is set 0.0.0.0 and not 127.0.0.1 in:
/etc/mysql/my.cnf
Package Installation
The PostMaster package can be found on Bintray at https://bintray.com/stackfocus/deb/PostMaster
This installation method works best on a fresh installation of the operating system.
-
Run this command to add to the
/etc/apt/sources.list
:echo "deb https://dl.bintray.com/stackfocus/deb {distribution} {components}" | sudo tee -a /etc/apt/sources.list
-
Install the PostMaster package:
apt-get update && apt-get install postmaster
-
Start using the new python virtual environment that PostMaster created
source /opt/postmaster/env/bin/activate
-
PostMaster needs to be configured to connect to the MySQL database using the MySQL user created in step 2 of MySQL Preparation. Make sure to replace "password_changeme" with the actual password supplied in step 2 of MySQL Preparation, and if needed, replace '127.0.0.1' with the IP address or DNS specified in step 2 of MySQL Preparation:
cd /opt/postmaster/git python manage.py setdburi 'mysql+pymysql://postmasteruser:password_changeme@127.0.0.1:3306/servermail'
-
PostMaster needs to create a few tables under the servermail database. This is done via a database migration, which means that only the necessary changes to the database are made, and these changes are reversible if something went wrong. To start the migration, run the following command:
python manage.py upgradedb
-
PostMaster uses a secret key for certain cryptographic functions. To generate a random key, run the following command:
python manage.py generatekey
-
You may now exit from the python virtual environment:
deactivate
-
PostMaster should now be running on port 8082. Simply use the username "admin" and the password "PostMaster" to login. You can change your username and password from Manage -> Administrators.
Manual Installation
-
Switch to the server that will host PostMaster if applicable, and login as root:
sudo su -
-
Update the aptitude package list:
apt-get update
-
Install the required packages for PostMaster:
apt-get install python python-pip python-dev libldap2-dev libssl-dev libsasl2-dev libffi-dev apache2 libapache2-mod-wsgi mysql-server
-
Make sure you are running Python 2.7 as your default Python installation, as PostMaster relies on Python 2.7:
python -V
-
Create the required directories for PostMaster:
mkdir /opt/postmaster mkdir /opt/postmaster/logs
-
Find the URL to the latest tar.gz file containing the PostMaster source code at:
https://github.com/StackFocus/PostMaster/releases/latest
-
Then download PostMaster with the URL from the previous step:
https://github.com/StackFocus/PostMaster/archive/[release version].tar.gz -O ~/postmaster.tar.gz
-
Decompress the downloaded tar.gz file:
tar -xzvf ~/postmaster.tar.gz
-
Move the decompressed folder containing the source code to /opt/postmaster/git:
mv PostMaster-* /opt/postmaster/git
-
A python virtual environment is now required. This allows you to separate the system installed python packages from PostMaster's required python packages:
pip install virtualenv virtualenv /opt/postmaster/env
-
Start using the new python virtual environment
source /opt/postmaster/env/bin/activate
-
Install the Python packages required by PostMaster into the python virtual environment:
cd /opt/postmaster/git pip install -r requirements.txt
-
Create the PostMaster configuration file from using the sample file that was included:
cp -pn /opt/postmaster/git/config.default.py /opt/postmaster/git/config.py
-
PostMaster needs to be configured to connect to the MySQL database using the MySQL user created in step 2 of MySQL Preparation. Make sure to replace "password_changeme" with the actual password supplied in step 2 of MySQL Preparation, and if needed, replace '127.0.0.1' with the IP address or DNS specified in step 2 of MySQL Preparation:
cd /opt/postmaster/git python manage.py setdburi 'mysql://postmasteruser:password_changeme@127.0.0.1:3306/servermail'
-
PostMaster needs to create a few tables under the servermail database. This is done via a database migration, which means that only the necessary changes to the database are made, and these changes are reversible if something went wrong. To start the migration, run the following command:
python manage.py upgradedb
-
PostMaster uses a secret key for certain cryptographic functions. To generate a random key, run the following command:
python manage.py generatekey
-
You may now exit from the python virtual environment:
deactivate
-
Provide the proper permissions on the PostMaster files:
chown -R www-data:www-data /opt/postmaster chmod -R 550 /opt/postmaster chmod 770 /opt/postmaster/logs
-
Disable the default Apache site:
a2dissite 000-default.conf
-
Copy the default PostMaster Apache site configuration and give it the appropriate permissions. It is highly recommended that you implement SSL before using PostMaster in production:
cp /opt/postmaster/git/ops/apache.conf /etc/apache2/sites-available/postmaster.conf chmod 644 /etc/apache2/sites-available/postmaster.conf chown root:root /etc/apache2/sites-available/postmaster.conf
-
Enable the PostMaster Apache site:
a2ensite postmaster.conf
-
Restart Apache for the changes to take effect:
service apache2 restart
-
PostMaster should now be running. Simply use the username "admin" and the password "PostMaster" to login. You can change your username and password from Manage -> Administrators.