How To Install PostfixAdmin on Ubuntu 26.04 LTS

Install PostfixAdmin on Ubuntu 26.04

If you want a clean way to manage virtual domains, mailboxes, and aliases on a mail server, Install PostfixAdmin on Ubuntu 26.04 is the practical path. This guide walks you through a real-world setup that a Linux sysadmin would use, with each command explained so you know not just what to run, but why it matters.

PostfixAdmin gives you a web interface for Postfix-based mail hosting, which makes it much easier to manage users and domains than editing flat files by hand. On Ubuntu 26.04, the usual stack pairs PostfixAdmin with Postfix, Dovecot, MariaDB, PHP, and Nginx or Apache, and that combination remains the most common pattern in current tutorials and documentation.

This article is written for beginner to intermediate Linux users, developers, and sysadmins who want a clear, usable Linux server tutorial without filler. You will see how to prepare the system, install the needed packages, configure the database, set up the web app, and handle common errors before they waste your time.

Prerequisites

Before you start the PostfixAdmin on Ubuntu 26.04 setup, make sure you have the following ready:

  • Ubuntu 26.04 LTS server with sudo access.
  • A registered domain name.
  • Access to DNS records for that domain.
  • A non-root sudo user.
  • Basic command-line access through SSH.
  • A web server stack such as Nginx and PHP.
  • MariaDB or MySQL for the backend database.
  • Enough control over firewall rules to open mail and web ports.

These items matter because PostfixAdmin is only one part of the mail system. The mail server still needs DNS, database access, PHP support, and network rules to function correctly.

Step 1: Update Your System

Refresh Package Lists

Start by updating the package index and upgrading installed packages.

sudo apt update
sudo apt upgrade -y

This command refreshes Ubuntu’s package metadata and installs the latest security patches. You want this first because mail servers expose services to the network, so outdated packages increase risk.

Verify the Server Is Clean

Check that your server boots normally and that you can still log in after updates.

uname -a
lsb_release -a

This confirms that you are really on the expected Ubuntu release. It also helps when you later troubleshoot package versions or PHP behavior.

Why This Step Matters

A mail server depends on stable packages, especially PHP, database libraries, and TLS tools. If you install PostfixAdmin on top of an outdated system, you often end up fixing avoidable bugs later.

Step 2: Install MariaDB and Secure It

Install the Database Server

PostfixAdmin stores domains, mailbox data, aliases, and related settings in a database. Install MariaDB with this command:

sudo apt install mariadb-server -y

MariaDB is a strong choice on Ubuntu because it is well supported and fits common mail server tutorials. It also works well with PostfixAdmin’s database-driven design.

Secure the Database

Run the built-in hardening script next.

sudo mysql_secure_installation

This script helps remove weak defaults, like anonymous users or test databases. That matters because a mail server should never keep unnecessary database exposure around.

Create the PostfixAdmin Database

Log in to MariaDB and create a dedicated database and user.

sudo mysql

Then run:

CREATE DATABASE postfixadmin;
CREATE USER 'postfixadmin'@'localhost' IDENTIFIED BY 'StrongPasswordHere';
GRANT ALL PRIVILEGES ON postfixadmin.* TO 'postfixadmin'@'localhost';
FLUSH PRIVILEGES;
EXIT;

This creates a separate database for mail data and a limited user for the application. That separation is important because least privilege reduces the blast radius if one component gets compromised.

Why This Step Matters

PostfixAdmin needs a place to store virtual domain data, and MariaDB gives it that backend. A dedicated database user also prevents other local services from using the same credentials.

Step 3: Install Nginx and PHP

Install the Web Stack

Now install Nginx and the PHP packages required by PostfixAdmin.

sudo apt install nginx php-fpm php-mysql php-gd php-mbstring php-xml php-curl unzip wget -y

Nginx serves the web interface, while PHP runs the application logic. The extra PHP modules help PostfixAdmin handle strings, database access, XML, and image-related features.

Check the PHP Version

php -v

You should see the installed PHP version in the output. For example:

PHP 8.x.x (cli) (built: ...)

This matters because different Ubuntu releases ship different PHP versions, and you want to confirm the server matches what the package manager installed.

Why This Step Matters

PostfixAdmin is a PHP application, so it cannot work without PHP and its extensions. Nginx and PHP-FPM also split responsibilities cleanly, which is helpful for performance and security.

Step 4: Download PostfixAdmin

Get the Latest Release

Download the project into /opt, which keeps application files away from the public web root.

cd /opt
sudo wget https://github.com/postfixadmin/postfixadmin/archive/refs/tags/postfixadmin-3.3.13.tar.gz

The exact version may change, so always check the current release tag on the official GitHub project page before you deploy your server.

Extract the Archive

sudo tar xzf postfixadmin-3.3.13.tar.gz
sudo mv postfixadmin-postfixadmin-3.3.13 postfixadmin

This gives you a stable application path under /opt/postfixadmin. That makes updates easier and keeps the code separate from the exposed web directory.

Create the Templates Directory

sudo mkdir -p /opt/postfixadmin/templates_c
sudo chown -R www-data:www-data /opt/postfixadmin/templates_c
sudo chmod 755 /opt/postfixadmin/templates_c

PostfixAdmin needs this directory for compiled template files. Without it, the interface may throw permission errors or fail to load pages properly.

Why This Step Matters

Keeping the app in /opt improves organization and security. It also makes it easier to apply upgrades later without mixing application code with public files.

Step 5: Configure PostfixAdmin

Create the Local Config File

Open the config file and define your database settings.

sudo nano /opt/postfixadmin/config.local.php

Add this example:

<?php
$CONF['database_type'] = 'mysqli';
$CONF['database_host'] = 'localhost';
$CONF['database_user'] = 'postfixadmin';
$CONF['database_password'] = 'StrongPasswordHere';
$CONF['database_name'] = 'postfixadmin';
$CONF['configured'] = true;
?>

This file tells PostfixAdmin where to find the database and confirms that you have finished the initial setup. The configured flag matters because it enables the application to run normally.

Why This Step Matters

PostfixAdmin cannot read mailbox and domain data unless it knows how to reach the database. This file is also the right place to keep local settings separate from upstream source files, which makes upgrades safer.

Set Safe Permissions

sudo chown root:root /opt/postfixadmin/config.local.php
sudo chmod 640 /opt/postfixadmin/config.local.php

This reduces the chance that an unneeded user can read your database password. For a mail system, credential hygiene is not optional.

Step 6: Set Up the Web Server

Create the Nginx Site Config

Now create a virtual host for the panel.

sudo nano /etc/nginx/sites-available/postfixadmin

Use a simple server block like this:

server {
    listen 80;
    server_name mail.example.com;

    root /opt/postfixadmin/public;
    index index.php index.html;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php-fpm.sock;
    }
}

Adjust the PHP socket path if your Ubuntu install uses a versioned socket. You can confirm the exact socket path in /run/php/.

Enable the Site

sudo ln -s /etc/nginx/sites-available/postfixadmin /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx

The nginx -t command checks for config errors before reload. That is a fast way to catch typos before they break your site.

Why This Step Matters

Nginx must pass PHP requests to PHP-FPM or the site will not render correctly. The try_files rule also helps prevent bad routing and keeps the site behavior clean.

Step 7: Run the Initial Setup

Open the Setup Page

Browse to your server name, such as:

http://mail.example.com

If the web server and PHP are working, you should see the PostfixAdmin setup screen. That page confirms the app can read the code and talk to the database.

Create the First Admin Account

Use the setup page to generate the setup password hash and create the super admin user. The exact screen and flow may vary by release, but the purpose stays the same: establish the first account with full control.

Why This Step Matters

A mail admin panel without a secure first administrator is unfinished. The setup page gives you a controlled way to create that account and verify the installation.

Step 8: Add Postfix and Dovecot Integration

Connect Postfix to the Database

PostfixAdmin manages users, but Postfix still needs database lookup files for domains and aliases. Create the MySQL map files used by Postfix.

sudo nano /etc/postfix/mysql-virtual-mailbox-domains.cf

Example content:

user = postfixadmin
password = StrongPasswordHere
hosts = 127.0.0.1
dbname = postfixadmin
query = SELECT domain FROM domain WHERE domain='%s' AND active = '1'

Do the same for mailbox and alias lookups.

Configure Dovecot Authentication

Dovecot also needs SQL-based authentication if you want virtual mailboxes. That lets users log in with the mailbox credentials stored in the database, not system accounts.

Why This Step Matters

PostfixAdmin is only the control panel. Postfix and Dovecot still do the actual mail delivery and login work. Without database integration, the panel would create data that the mail services cannot use.

Step 9: Protect the Panel with TLS

Install Certbot

sudo apt install certbot python3-certbot-nginx -y

This gives you an easy way to request a trusted certificate for your mail host.

Request the Certificate

sudo certbot --nginx -d mail.example.com

Certbot will edit Nginx and set up HTTPS for you. That protects login credentials and makes the admin panel safer to use.

Why This Step Matters

An admin panel over plain HTTP is a bad idea on any public server. TLS protects the password you use to manage domains, aliases, and mailbox accounts.

Step 10: Test the Setup

Check the Web Interface

Log in to PostfixAdmin and create a test domain.

example.com

Then add a mailbox and an alias. This confirms that the database, web UI, and account workflow all connect correctly.

Test the Mail Stack

After the panel works, verify that Postfix and Dovecot can see the same data. The exact mail tests depend on your wider setup, but the goal is simple: create, send, receive, and authenticate successfully.

Why This Step Matters

A successful page load does not mean the mail system is complete. Real validation happens when the panel, SMTP service, and mailbox login all work together.

Troubleshooting

1. The Page Shows a Database Error

This usually means the database name, user, or password is wrong. Recheck config.local.php and confirm that MariaDB contains the database and user you created.

2. Nginx Shows 502 Bad Gateway

This often points to a PHP-FPM socket mismatch. Check your PHP socket path with:

ls /run/php/

Then update the fastcgi_pass line in your Nginx config.

3. PostfixAdmin Cannot Write to templates_c

This usually means the directory ownership is wrong. Fix it with:

sudo chown -R www-data:www-data /opt/postfixadmin/templates_c

4. Login Works, but Mail Delivery Fails

This usually means Postfix or Dovecot is not fully connected to the database. Recheck your SQL map files and confirm that the query matches the table structure.

5. HTTPS Certificate Does Not Load

This usually means DNS does not point to the server yet, or Certbot could not edit the site config. Confirm the A record for mail.example.com and rerun Certbot after Nginx is valid.

[su_box title=”VPS Manage Service Offer” style=”bubbles” box_color=”#000000″ radius=”10″]If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal![/su_box]

r00t is a Linux Systems Administrator and open-source advocate with over ten years of hands-on experience in server infrastructure, system hardening, and performance tuning. Having worked across distributions such as Debian, Arch, RHEL, and Ubuntu, he brings real-world depth to every article published on this blog. r00t writes to bridge the gap between complex sysadmin concepts and practical, everyday application — whether you are configuring your first server or optimizing a production environment. Based in New York, US, he is a firm believer that knowledge, like open-source software, is best when shared freely.

Related Posts