Author Topic: How can i assign a subdomain  (Read 1877 times)

Loren Tedford

  • Jr. Member
  • **
  • Posts: 58
  • I love Amateur Radio, VPS and Minecraft!
    • View Profile
    • Welcome to Lorentedford.com
How can i assign a subdomain
« on: November 01, 2015, 02:25:01 pm »
Looking to assign a  subdomain to the webmail2 subdomain.. example assign mail.domain.com to ip/ehcp/webmail2/

Idk.. Maybe i am over thinking this maybe I should just create the subdomain and make links to the webmail idk.. Just was looking for an easy way out..

earnolmartin

  • Administrator
  • Sr. Member
  • *****
  • Posts: 304
    • View Profile
Re: How can i assign a subdomain
« Reply #1 on: November 01, 2015, 11:43:20 pm »
Looking to assign a  subdomain to the webmail2 subdomain.. example assign mail.domain.com to ip/ehcp/webmail2/

Idk.. Maybe i am over thinking this maybe I should just create the subdomain and make links to the webmail idk.. Just was looking for an easy way out..

It is possible.  You just have to create another VirtualHost entry for that server alias / servername so that its home directory is /var/www/new/ehcp/webmail2.  You would do this by logging in as "admin" to the EHCP panel and edit the Apache2 template for the domain you want to create a subdomain for.   I'm thinking in nginx mode for the moment, but here is an Apache2 example... you can add to the top of the template or bottom... doesn't really matter. 


Code: [Select]
<VirtualHost *>
        ServerName  webmail.{YOURDOMAIN}.com

        DocumentRoot /var/www/new/ehcp/webmail2

        LogFormat "%v:%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
        CustomLog  /var/log/apache_common_access_log vhost_combined

</VirtualHost>

I think you also need to create an A DNS record for the subdomain in the DNS template. 

Be careful.  If the above example doesn't work and messes up your Apache2 configuration for some reason... do this:

Code: [Select]
sudo -i
> /var/www/new/ehcp/apachehcp.conf
service apache2 restart

Then you need to login to PHPMYADMIN http://yourip/phpmyadmin as the EHCP user and clear the custom template from the database in the domains table...

Then, login to EHCP and run the Sync Domains operation.

Please let me know if you need help or if the example above doesn't work... (I didn't test it, so use at your own risk).