Table of Contents

E) Installation: postfixadmin web gui

PostfixAdmin is a neat web GUI that let's you monitor, create domains, accounts and much more on your web server.

USE flags

PostfixAdmin is a PHP application which you will be running with NGINX + PHP-FPM.

Ensure your PHP has the imap USE flag enabled:

echo "dev-lang/php imap" >> /etc/portage/package.use/mailserver 

Manual Installation

PostfixAdmin is available in portage, but installing via emerge would be not really inline with how i manage the webapps on my external server. I will show you how i have installed it manually, which is not that difficult at all.

Download latest release of postfixadmin from here and decompress in a folder accessible to the web user, since i use the web user to run all PHP based software on the external webserver:

su # do this as root! You don't need to make postfixadmin writable by the web user
cd /home/web
mkdir postfixadmin
cd postfixadmin
wget https://github.com/postfixadmin/postfixadmin/archive/refs/tags/postfixadmin-3.3.15.tar.gz
tar xvf postfixadmin-3.3.15.tar.gz
mv postfixadmin-postfixadmin-3.3.15 postfixadmin
#The following folder must be writeable by web user:
mkdir -p postfixadmin/templates_c
chown -R web postfixadmin/templates_c

Reverse Proxy

Of course PostfixAdmin will need to be behind the reverse proxy, both for security and to wrap it with HTTPS. See this page) for more detail on NGINX setup.

For reference, here is my specific configuration:

server {
        server_name mail.mydomain.com;
        listen 443 ssl;
 
        access_log /var/log/nginx/mail.mydomain.com_access_log main;
        error_log /var/log/nginx/mail.mydomain.com_error_log info;
 
        index index.php;
 
        root /home/web/postfixadmin/postfixadmin/public;     
 
# Uncomment the following lines only AFTER setup is complete!         
#        location ~ /(setup.php) {
#                deny all;
#                alias /home/web/postfixadmin/postfixadmin/public;
#        }
 
        location ~ /.*\.php$ {
                try_files $uri =404;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                include fastcgi_params;
                fastcgi_param SCRIPT_FILENAME $request_filename;
                fastcgi_pass 127.0.0.1:9000;
        }
}

Finalization

Restart NGINX and go to the URL https://mail.mydomain.com/setup.php and follow the on-screen instructions to create a password hash that you need to add to the above config.local.php file, then reload the page itself.

Also don't forget to create a superadmin-account. I suggest you call it user@mydomain.com and set a password you will not forget.

Go back, uncomment the lines in the NGINX config file to disable the setup.php, and restart NGINX.

Installation is now complete.