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

Issue

I have a virtual private server running Debian with DirectAdmin.

I have edited the vhost template files used by DirectAdmin so that subdomains aren't placed in the main domain's public_html. As per the instructions, I have asked DirectAdmin to rewrite the vhosts, which it did. After adjusting the directory structures, all sites work like a charm.

However, adding new domains builds the default directory structure and adding subdomains spits out an error.

Detailed description

Let me explain in detail. Here's the docroots my custom templates create.

virtual_host2.conf:

|?DOCROOT=`HOME`/domains/`DOMAIN`/www/public_html|

virtual_host2_sub.conf:

|?DOCROOT=`HOME`/domains/`DOMAIN`/`SUB`/public_html|

After creating the domain test.pl, I get the following (incorrect) directories:

/home/myuser/domains/test.pl/.htpasswd
/home/myuser/domains/test.pl/public_ftp
/home/myuser/domains/test.pl/public_html

and the vhost entry lists the following (correct) docroot:

DocumentRoot /home/myuser/domains/test.pl/www/public_html

Adding a subdomain works the same - old incorrect directory structure is created, but the vhost uses the new, correct template. After I correct the domain's directory structure:

/home/myuser/domains/test.pl/www/.htpasswd
/home/myuser/domains/test.pl/www/public_ftp
/home/myuser/domains/test.pl/www/public_html

I try to add a subdomain again. This result in 3 errors and a failure to create the subdomain:

Error creating /home/myuser/domains/test.pl/public_html/mysub
A directory component in /home/myuser/domains/test.pl/public_html/mysub does not exist or is a dangling symbolic link

Error creating /home/myuser/domains/test.pl/public_html/mysub/cgi-bin
A directory component in /home/myuser/domains/test.pl/public_html/mysub/cgi-bin does not exist or is a dangling symbolic link

Error creating /home/myuser/domains/test.pl/private_html/mysub
A directory component in /home/myuser/domains/test.pl/private_html/mysub does not exist or is a dangling symbolic link

Question

How to notify DirectAdmin of the new directory structure when creating domains and subdomains?

share|improve this question

closed as off-topic by Ward, HBruijn Feb 23 at 9:04

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

up vote 1 down vote accepted

Changing your VHost template won't make DirectAdmin create the directory structure you want, it will only make Apache set a different document root for that domain or subdomain.

You might want to take a look at this and this other feature.

As you can see there, you can write a custom script to be executed after creating a domain or subdomain so that it creates the directory structure you want.

For example, if it is for a subdomain you could create the script /usr/local/directadmin/scripts/custom/subdomain_create_post.sh with something like this:

#!/bin/sh
rm -rf /home/$username/domains/$domain/public_html/$subdomain
mkdir -p /home/$username/domains/$domain/$subdomain/public_html
chown $username:$username /home/$username/domains/$domain/$subdomain/public_html
exit 0;
share|improve this answer
    
I don't exactly see how I can achieve what I'm after; would you mind elaborating a bit more? – mingos Dec 28 '12 at 3:08
    
@mingos I edited my answer, please check it out now. – El Barto Dec 28 '12 at 13:48
    
The problem is that the directory public_html/$subdomain is not created at all because public_html does not exist. The issue is that creating the subdomain fails. This would only work for me if I decided to have domains in domains/$domain/public_html and subdomains in domains/$subdomain.$domain/public_html or similar. Thanks for pointing out the method though as it might be very useful for configuring my clients' servers ;). – mingos Dec 30 '12 at 17:27
    
Oh, wait, with *_create_pre, I can temporarily create the public_html... alright, seems you saved the day! Thanks, mate! – mingos Dec 30 '12 at 17:30

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