I’ve just setup a serveralias for one of my domains on my PLesk managed server. e.g. example.co.uk aliases to example.com

To do this properly, you need to add the lines

ServerAlias www.example.co.uk
ServerAlias example.co.uk

to /home/httpd/vhosts/example.com/conf/vhost.conf

Then
# /usr/local/psa/admin/sbin/websrvmng –reconfigure-vhost –vhost-name=example.com

That should sort http stuff… you also need to edit some qmail files for mail to work also.

add example.co.uk to this file
/var/qmail/control/rcpthosts

and add example.co.uk: to this file where is the suffix of the example.com domain
/var/qmail/control/virtualdomains

Then stop and start qmail and pop/imap either using the control panel, or
service qmail stop
service qmail start

Sorted..

Here’s the content and links that helped me with this…

SWSoft.com KB article 41 894
SWSoft.com forum thread 22992

Stored below in case stuff disappears…

*** edit
I’ve since discovered that you could well need a symlink for your alias domain pointing to the primary domain in /var/qmail/mailnames to get email addresses on the alias domain working as well as on the primary.

ln -s /var/qmail/mailnames/example.com /var/qmail/mailnames/example.co.uk

*** edit end

This is below

Here is how I do it.
BACKUP BACKUP BACKUP
I am not responsible for any problems that may arise from following these instructions. I am not an expert, but hey it works for me. Please let me know if there are any security issues as I am paranoid. Also does anyone know if these files get overwritten with a Plesk or software upgrade.

pico -w /home/httpd/vhosts/[domain.com]/conf/vhost.conf

add ServerAlias domain.net

run update command
/usr/local/psa/admin/sbin/websrvmng –reconfigure-vhost –vhost-name=domain.com

pico -w /var/named/run-root/etc/named.conf

add new zone for domain.net (easiest way is to copy zone for domain.com and replace all refs .com to .net)

restart named
service named restart

FOR EMAIL
either add domain.net to rcpthosts or add to morercpthosts

pico -w /var/qmail/control/morercpthosts

add domain.net

rebuild qmail database
/var/qmail/bin/qmail-newmrh

add domain.net to virtualdomains to receive email for domain.net through domain.com
pico -w /var/qmail/control/virtualdomains
add domain.net:11 (where number is the same as that for domain.com)

if you wish to reject bounced messages for domain.net you need to edit your .qmail-default for that domain.

cd /var/qmail/mailnames
add domain.net folder – check permissions/owner
add .qmail-default file
pico .qmail-default

add following line
|forward ${DEFAULT}@domain.com

add domain.net to rejection list
pico -w /var/qmail/control/rejectnonexist
add domain.net

service qmail restart

DONE
if you do not add a .qmail-default file but add domain.net to rejectnonexist then all email for domain.net will bounce.

Now if you have me@domain.com mailbox all mail to me@domain.net will go into that box. You should be able to read mail using either domain.com or domain.net mail addresses. Remember they are one in the same.

Roo

Categories: LAMP

Jonathan Adjei

Jon's expertise in web development is legendary and he oversees all technical aspects of our projects from development to hosting (all through the command line!) Jon is excited by the latest techniques and keeps the company on track by finding ways to adopt new practices into our workflow.