Subdomain location

swinnenb

Verified User
Joined
Sep 22, 2008
Messages
11
Has there ever been a solution to this?
Is there a script / file to be eddited, except the sub domain templates, that creates the directories?

Grtzzzzz
Bart
 

floyd

Verified User
Joined
Mar 29, 2005
Messages
5,285
There were two solutions posted. If you do not like those solutions then the answer is no.
 

swinnenb

Verified User
Joined
Sep 22, 2008
Messages
11
But one solution is not working.
Changing the sub domain templates does not help as it does not change the creation of the directories.
And the subdoamin as a domain is a user level difficulty, why having the option to add subdomains if you need to create a domain to get proper functionality.

So a pointer to where to change the creation of the subdomain directories would be great.

Kind regards
 

floyd

Verified User
Joined
Mar 29, 2005
Messages
5,285
Changing the sub domain templates does not help as it does not change the creation of the directories.
Just create the directory yourself. One extra step.

Or you can use a sub domain post create script to do it for you and at the same time delete the wrongly created directory.
 

swinnenb

Verified User
Joined
Sep 22, 2008
Messages
11
Agree with that.
What would be the best way to do this. I read the POST and GET thing earlier in this thread, but did not understand it.
So what is the best place to call that custom script and where to place it?
Do I have to edit existing files (CMD_SUBDOMAIN?action=create&domain=example.be&subdomain=test) ???
Can you give me some guidelines?

Many thanks for your help.
 

floyd

Verified User
Joined
Mar 29, 2005
Messages
5,285
Custom scripts have to be located in /usr/local/directadmin/scripts/custom

Read the README file there for instructions.
 

swinnenb

Verified User
Joined
Sep 22, 2008
Messages
11
Ok I've made following custom subdomain_create_post.sh script.
I know delete the directories it made by default. But what if these directories were not made by adding the subdomain?

For example in my maindoamin.com I have a folder called "help". If I now want to make a separate sub domain help.maindomain.com, the scripts now erases the existing directory in my maindomain.

Any idea how I can check this? Do i have to check all dates of creation or something?

Or an other procedure, idea would be very welcome.

Code:
#!/bin/sh

ORIG_PUB_SUB_PATH="/home/$username/domains/$domain/public_html/$subdomain"
ORIG_PRV_SUB_PATH="/home/$username/domains/$domain/private_html/$subdomain"
SUBDOMAIN_PATH="/home/$username/domains/$subdomain.$domain"

mkdir -m 711 $SUBDOMAIN_PATH
mkdir -m 750 $SUBDOMAIN_PATH/public_html
mkdir -m 755 $SUBDOMAIN_PATH/public_html/cgi-bin
mkdir -m 750 $SUBDOMAIN_PATH/private_html
mkdir -m 755 $SUBDOMAIN_PATH/private_html/cgi-bin
cp $ORIG_PUB_SUB_PATH/index.html $SUBDOMAIN_PATH/public_html/
cp $ORIG_PUB_SUB_PATH/index.html $SUBDOMAIN_PATH/private_html/
chown -R $username:$username $SUBDOMAIN_PATH
rm -rf $ORIG_PUB_SUB_PATH
rm -rf $ORIG_PRV_SUB_PATH
 

ozgurerdogan

Verified User
Joined
Apr 20, 2008
Messages
293
Ok after;
cd /usr/local/directadmin/data/templates
cp virtual_host*.conf custom
cd custom

I edited all virtual_host2 and I added following lines at top of content of conf files:

|*if SUB|
|?DOCROOT=`HOME`/domains/`DOMAIN`/`SUB`|
|*endif|

But still creates in domain folder. Any news for creating subdomains nearby domainname folder or at least not in domain files folder?

Thanks
 

DirectAdmin Support

Administrator
Staff member
Joined
Feb 27, 2003
Messages
8,931
Hello,

Note that in the virtual_host*_sub.conf files, the DocumentRoot is specified with:
Code:
DocumentRoot |DOCROOT|/|SUB|
So if you're specifying the DOCROOT to have the SUB in it already, you'd have toe edit the above line to just show:
Code:
DocumentRoot |DOCROOT|
John
 

WHI

Verified User
Joined
Sep 25, 2008
Messages
59
Could you help me?

We would like to set the same one docroot for 10 different subdomain. How can I do that?
I tried like this at custom httpd.conf:

|*if SUB="subdomain_name"|
|?DOCROOT=/home/userlogin/domains/users_domain/public_html|
|*endif|

public_html is the target folder.

Thanks a lot!
 

mbunal

Verified User
Joined
Dec 30, 2007
Messages
8
there is conflicting with each other "support.domain.com" and "domain.com/support/". these are totally different. but support.domain.com point domain.com/support.
What do you recommend me?

sorry for google translate.

Baris.
 

zEitEr

Super Moderator
Joined
Apr 11, 2005
Messages
13,900
Location
GMT +7.00
Hello Baris,

You can add support.domain.com as a regular domain. Thus it will have /home/username/domains/support.domain.com/public_html as document root.
 

mbunal

Verified User
Joined
Dec 30, 2007
Messages
8
hello zEitEr

your solution was solved my problem. however da handle it more suitable way. maybe:
.../domain.com/public_html
.../domain.com/sub1
.../domain.com/sub2
.../domain.com/sub3
 

zEitEr

Super Moderator
Joined
Apr 11, 2005
Messages
13,900
Location
GMT +7.00
You can re-organized that with post/pre scripts. Some time ago, I wrote a plugin (not for public usage) with the help of which administrator could change sub-domains location.

It really worked. I'm not sure, where it is now. Perhaps, I could try to find it and share.
 

SeLLeRoNe

Super Moderator
Joined
Oct 9, 2004
Messages
6,789
Location
A Coruña, Spain
im getting interested on this 3d too cause have subdomain separed would be much better... but... ok the post_crete script for move files and create/remove folder and ok for the custom sub_virtualhost

but.. what about when a user delete the subdomain?

If dont check the "delete files and folder" ok, just http conf get change... but... if they check "delete file and folder" what will be erased? I suppose the public_html/subdomain_name folder and that should be a risk, right?

if anyone had implemented a solution for this and, can/want share i would appreciate.

Regards
 

zEitEr

Super Moderator
Joined
Apr 11, 2005
Messages
13,900
Location
GMT +7.00
When adding and deleting sub-domains nothing will be lost or messed in public_html, even if a directory with sub-domain's name already exists. That was was provided for.
 

SeLLeRoNe

Super Moderator
Joined
Oct 9, 2004
Messages
6,789
Location
A Coruña, Spain
well, if directory doesnt exist directadmin create it (and have no sense if you wanna use different path, so, you have to delete it from subdomain_create_post.sh) and if the directory exist when you use the script to move and delete those data will be moved (and maybe the user dont want to...)

when deleting subdomain with file should be interested to know what directory path directadmin use, and where does he take the path, cause if use http conf ok.. will take the right one.. if use the standard path-node.. well, should destroy importand data...

am i wrong?
 

zEitEr

Super Moderator
Joined
Apr 11, 2005
Messages
13,900
Location
GMT +7.00
I'm not sure whether I understand you correct (Sorry, I'm tired a little bit). But some years ago, you can see the first page of this thread, when I wrote a set of POST/PRE scripts for managing sub-domains location everything worked find for me. Original files for sub-domain have never been messed with any data in public_html directory. And value of a checkbox "Remove Directory Contents" was taken into account.

I'll look for these scripts later, if they are not deleted.
 

SeLLeRoNe

Super Moderator
Joined
Oct 9, 2004
Messages
6,789
Location
A Coruña, Spain
Sorry my english is not so good so, im talking exactly about this situation presented from swinnenb :)

Ok I've made following custom subdomain_create_post.sh script.
I know delete the directories it made by default. But what if these directories were not made by adding the subdomain?

For example in my maindoamin.com I have a folder called "help". If I now want to make a separate sub domain help.maindomain.com, the scripts now erases the existing directory in my maindomain.

Any idea how I can check this? Do i have to check all dates of creation or something?

Or an other procedure, idea would be very welcome.

Code:
#!/bin/sh

ORIG_PUB_SUB_PATH="/home/$username/domains/$domain/public_html/$subdomain"
ORIG_PRV_SUB_PATH="/home/$username/domains/$domain/private_html/$subdomain"
SUBDOMAIN_PATH="/home/$username/domains/$subdomain.$domain"

mkdir -m 711 $SUBDOMAIN_PATH
mkdir -m 750 $SUBDOMAIN_PATH/public_html
mkdir -m 755 $SUBDOMAIN_PATH/public_html/cgi-bin
mkdir -m 750 $SUBDOMAIN_PATH/private_html
mkdir -m 755 $SUBDOMAIN_PATH/private_html/cgi-bin
cp $ORIG_PUB_SUB_PATH/index.html $SUBDOMAIN_PATH/public_html/
cp $ORIG_PUB_SUB_PATH/index.html $SUBDOMAIN_PATH/private_html/
chown -R $username:$username $SUBDOMAIN_PATH
rm -rf $ORIG_PUB_SUB_PATH
rm -rf $ORIG_PRV_SUB_PATH
 
Top