mod_vhost_alias and cPanel - Folders as subdomains

N1ghteyes

Active Member
Mar 3, 2014
33
2
58
Reading, UK
cPanel Access Level
Root Administrator
Twitter
EDIT:-- Before anyone points it out, yes i know i can go to cpanel > subdomains, no in this case that is not an option.

I need to config a cpanel account to use mod_vhost_alias to convert folders under /public_html to subdomains.

I.e. if i create the folder /public_html/test i need test.domain.co.uk to just work.

I have the setup working under Elementary OS (its basically Ubuntu 14.04 LTS), i need it to work on a cpanel server though.

So far i have:
- Rebuilt easy apache to include mode_vhost_alias
- for the account i have setup a wildcard DNS entry (A record)
- in the accounts custom config (/var/cpanel/userdata/scweb/domain.co.uk) i have changed the doumentroot to /home/scweb/public_html/%1/ as per the mod_vhost_alias docs.
- in the accounts custom config i have also changed the serveralias to *.scwebdesign.co.uk

i have restarted the httpd service

under public_html i have created a directory called test and inside that an index.html file.

Still, i cant get this to work. Does anyone have any ideas? (full account config):

Code:
---
customlog:
  -
    format: combined
    target: /usr/local/apache/domlogs/domain.co.uk
  -
    format: "\"%{%s}t %I .\\n%{%s}t %O .\""
    target: /usr/local/apache/domlogs/domain.co.uk-bytes_log
documentroot: /home/scweb/public_html/%1/
group: scweb
hascgi: 1
homedir: /home/scweb
ifmoduleconcurrentphpc: {}

ifmoduleitkc: {}

ifmodulemodincludec:
  directoryhomescwebpublichtml:
    ssilegacyexprparser:
      -
        value: " On"
ifmodulemodsuphpc:
  group: scweb
ip: 130.185.146.188
owner: root
phpopenbasedirprotect: 1
port: 80
scriptalias:
  -
    path: /home/scweb/public_html/cgi-bin
    url: /cgi-bin/
  -
    path: /home/scweb/public_html/cgi-bin/
    url: /cgi-bin/
serveradmin: [EMAIL][email protected][/EMAIL]
serveralias: "*.domain.co.uk"
servername: domain.co.uk
usecanonicalname: 'Off'
user: scweb
userdirprotect: ''
 
Last edited by a moderator:

N1ghteyes

Active Member
Mar 3, 2014
33
2
58
Reading, UK
cPanel Access Level
Root Administrator
Twitter
You will still require an A entry for each subdomain. Have you considered this?
There is a wildcard dns A record entry for *.scwebdesign.co.uk, should cover any need for subdomain records, confirmed as working for www. (It resolves to root as expected)
 

N1ghteyes

Active Member
Mar 3, 2014
33
2
58
Reading, UK
cPanel Access Level
Root Administrator
Twitter
My apologies! I'm not much more help than that.
hehe no worries. Im 90% sure i've missed something simple, just not sure what :/
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,268
463
Hello,

You may want to consider simply developing a script that utilizes our API to create a subdomain or addon domain anytime a directory is created (or when a script detects the creation of a directory). The customization you are using is not supported, so you may need to consult with a qualified system administrator for help with getting it implemented properly.

Thank you.