Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a domain: example.com. There’s also a subdomain, admin.example.com:

<VirtualHost *:80>
    ServerName admin.example.com
    ServerAlias admin
</VirtualHost>

Now I want to make postfixadmin control panel available at admin.example.com/postfix. The default config in /etc/apache2/conf.d/postfixadmin is:

Alias /postfixadmin /usr/share/postfixadmin

How should I change it? What I want is something like:

Alias admin/postfix /usr/share/postfixadmin

Edit: I know that I can just create a symlink under document root, pointing to /usr/share/postfixadmin, but I’m looking for a solution through the means of Apache config.

share|improve this question

There are probably multiple ways to accomplish this. Two ways I can think of:

Symlink

You could set a document root for the admin VirtualHost and then create a postfixadmin symlink to /usr/share/postfixadmin. Something like:

<VirtualHost *:80>
    ServerName admin.example.com
    ServerAlias admin
    DocumentRoot /var/www/admin

    <Directory /var/www/admin>
        Options +FollowSymLinks
    </Directory>
</VirtualHost>

Directory Security

Keeping the original alias, you could set some diretory security per virtual hosts to only allow the admin virtual host to access the directory. Something like:

Admin VirtualHost

<VirtualHost *:80>
    ServerName admin.example.com
    ServerAlias admin

    <Directory /usr/share/postfixadmin>
        Order Deny,Allow
        Allow from All
    </Directory>
</VirtualHost>

Main VirtualHost

<VirtualHost *:80>
    ServerName example.com

    <Directory /usr/share/postfixadmin>
        Order Deny,Allow
        Deny from All
    </Directory>
</VirtualHost>
share|improve this answer

Leave the original virtualhost definition the way it is and place a directory inside your document root entitled "postfix". Put the postfixadmin files in there. This will then render under your requested admin.example.com/postfix

share|improve this answer

I know it is an old question, but I think it is still relevant. Currently, Postfixadmin is still accessed through the alias Alias /postfixadmin /php/directory/of/postfixadmin. This alias is now located in /etc/apache2/conf-available/postfixadmin.conf - a symlink, but it makes no difference here. So, you can access postfixadmin with the URL path /postfixadmin in any virtual hosts in your server. The same is true with phpmyadmin or with any other application that uses this Alias approach. You need to edit /etc/postfixadmin/config.inc.php and /etc/postfixadmin/dbconfig.inc.php and run /etc/postfixadmin/setup.php only once for all virtual hosts. However, if PHP has a different configuration or runs as a different user or Apache has different directives in some virtual host, you might need to check the configurations that are specific to this virtual host. I suspect that this was the issue that the OP had. I noticed that postfixadmin fails silently when session does not work and, also, the access rights to the config files, especially for the database, are tight. If the PHP user does not have the appropriate privileges, it will fail.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.