How To : Setup a domain alias on Plesk servers
Author: Ryan Sutherland
Publication Date: March 1st, 2005
Intended Audience: Server Administrators
Reading Level: Advanced Technical
As far as I'm concerned, Plesk is by far the best and most advanced
Control Panel out there. However, it has always been lacking one
essential feature: the ability to easily create domain aliases. Due to
this severe shortcoming, I sometimes use Ensim instead. But reliable as
it is, Ensim is not nearly as feature-rich and user-friendly as Plesk.
So, I have struggled for some time to come up with the best way to create
domain aliases, and finally have a solution that I've tested thoroughly to
meet my expectations of a domain alias, which includes HTTP, HTTPS, FTP and also Mail.
// In each of the following steps, be sure replace [domain.com] with your alias domain (eg. mydomain.com) and [parentdomain] with the domain to be aliased (eg. mydomain.net). Be sure to remove the square brackets, of course.
// In each of the following steps, be sure replace ###.###.###.### with your IP address for the parent domain.
// In each of the following steps, be sure replace [NS1.NAMESERVER.NET] with your Primary Nameserver and [NS2.NAMESERVER.NET] with your Secondary Nameserver. Be sure to remove the square brackets, of course.
// Note: I use Plesk 7 Reloaded with authoritative Nameservers.
1. login via SSH and #cd /etc/httpd/conf/
2. create or modify the file "httpd.domainalias.conf" (you will have to
create this file for the first alias, but just modify it for subsequent
ones) by adding code like the following:
Code:
<VirtualHost ###.###.###.###:80>
ServerName [domain.com]
ServerAlias *.[domain.com]
DocumentRoot /home/httpd/vhosts/[parentdomain.com]/httpdocs
<Directory /home/httpd/vhosts/[parentdomain.com]/httpdocs>
AddType application/x-httpd-php .php .php4 .php3 .phtml
php_admin_flag engine on
</Directory>
</VirtualHost>
(Optional) If you want to alias HTTPS requests, also add code like this:
Code:
<VirtualHost ###.###.###.###:443>
ServerName [domain.com]
ServerAlias *.[domain.com]
DocumentRoot /home/httpd/vhosts/[parentdomain.com]/httpsdocs
<Directory /home/httpd/vhosts/[parentdomain.com]/httpsdocs>
AddType application/x-httpd-php .php .php4 .php3 .phtml
php_admin_flag engine on
</Directory>
</VirtualHost>
3. When you first create the file "http.domainalias.conf" you must put an include line in the "http.conf" file like this:
Code:
Include /etc/httpd/conf/httpd.domainalias.conf
I put mine at the bottom of the file, but just above this line:
Code:
Include /etc/httpd/conf/httpd.include
4. go to /var/named/run-root/etc/
5. modify the file "named.conf" by adding the following code:
Code:
zone "[domain.com]" {
type master;
file "[domain.com]";
;
6. go to /var/named/run-root/var/
7. add a file called "[domain.com]" which contains the following code:
Code:
$TTL 86400
@ IN SOA [NS1.NAMESERVER.NET]. admin.localhost.localdomain. (
1016902773 ; Serial
10800 ; Refresh
3600 ; Retry
604800 ; Expire
86400 ) ; Minimum
[domain.com]. IN NS [NS1.NAMESERVER.NET].
[domain.com]. IN NS [NS2.NAMESERVER.NET].
[domain.com]. IN A ###.###.###.###
www.[domain.com]. IN CNAME [domain.com].
ftp.[domain.com]. IN CNAME [domain.com].
[domain.com]. IN MX 10 mail.[domain.com].
mail.[domain.com]. IN A ###.###.###.###
webmail.[domain.com]. IN A ###.###.###.###
.[domain.com]. IN A ###.###.###.###
// Steps 8 through 10 are for Mail...
8. go to /var/qmail/control/
9. modify "rcpthosts" by adding the following code:
10. modify "virtualdomains" by adding the following code:
Code:
[domain.com]:[virtual#id]
where "virtual#id" corresponds to the integer of the virtual domain
that this domain is aliasing (this id is already specified in the same
file).
11. Restart your services:
#service named restart
#service httpd restart
#service qmail restart
12. Repeat this process for however many Domain Aliases you want to create.
// Note: This process does NOT rack up domains against your Plesk
licence, and making changes to the parent domain in Plesk will NOT
adversely affect any of the above steps.
Enjoy!