Possible to have domain point to 1 directory & cpanel to another?

forumfish

Member
Nov 13, 2011
7
0
51
cPanel Access Level
Root Administrator
First, I am new with cpanel but have significant experience with command line. The sites that I am building share the same source code but are owned by different customers.

My goal is to stick with the standard account setup steps of adding an account for each domain name. When the accounts are created I want it to point to different directions though.

Account 1 = DOMAIN-1.com --> ROOT
Account 2 = DOMAIN-2.com --> ROOT

Account 1 = Cpanel --> ROOT/Account-1/folder
Account 2 = Cpanel --> ROOT/Account-2/folder

If anyone knows how this can be accomplished, either by script or modifying configuration of Account Setup the help would be much appreciated.

If a script has to be written, I am willing to purchase the service of a known professional.
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
38
248
somewhere over the rainbow
cPanel Access Level
Root Administrator
Wouldn't it be easier to create these as addon domains off of a main domain. Addon domains can have their own FTP login password.

What is confusing me is the source code portion anyway because you cannot have two accounts able to share the same source code but editing it within their own folder without impacting the source code. What exactly needs to be done for editing purposes or cPanel access purposes? You want the http site to be the same site for these users but the users able to add their own email accounts and edit everything but for the Apache files?
 

forumfish

Member
Nov 13, 2011
7
0
51
cPanel Access Level
Root Administrator
Wouldn't it be easier to create these as addon domains off of a main domain. Addon domains can have their own FTP login password.
My goal is to assign different IP addresses to each domain. So having them as "addon domains" only gives them to share the same IP address.

You want the http site to be the same site for these users but the users able to add their own email accounts and edit everything but for the Apache files?
Yes, I want the ability to give someone access to cPanel for email controls, and I don't want the emails to share same directory.
 

forumfish

Member
Nov 13, 2011
7
0
51
cPanel Access Level
Root Administrator
Wouldn't it be easier to create these as addon domains off of a main domain. Addon domains can have their own FTP login password.
I want to be able to assign seperate IP addresses to each domain / account.

You want the http site to be the same site for these users but the users able to add their own email accounts and edit everything but for the Apache files?
Yes, it is so they can control their own email accounts.
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
38
248
somewhere over the rainbow
cPanel Access Level
Root Administrator
The only way you can get this to work is to either use DSO which allows sharing the same document root due to nobody running the group process for PHP files, or to disable FileProtect under suPHP. Otherwise, different accounts cannot share the same source content.

As for editing the document root path but keeping the account's home directory itself elsewhere so they can't edit the files and only have emails in that other location, you can edit the document root in /var/cpanel/userdata/username/domain.com file where username is the cPanel username and domain.com is the domain name.

After editing the document root in that file, you'd need to do the following commands:

Code:
cp /usr/local/apache/conf/httpd.conf /usr/local/apache/conf/httpd.conf.bak111114
/scripts/rebuildhttpdconf
/etc/init.d/httpd restart
 

forumfish

Member
Nov 13, 2011
7
0
51
cPanel Access Level
Root Administrator
Thank you Tristan for your help.

Is it possible to write a script that will do all the necessary modifications to the httpd.conf file each time an account is created?

I am looking to automate this process the best way possible.
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
38
248
somewhere over the rainbow
cPanel Access Level
Root Administrator
Yes, you can create a script called /scripts/postwwwacct that can make such changes at the end of account creation. You can read our documentation about this script hook at the following location:

ScriptHooks < AllDocumentation < TWiki
 

forumfish

Member
Nov 13, 2011
7
0
51
cPanel Access Level
Root Administrator
I read through the hooks, but seems there is no way to easily manage the document root "postwwwacct", or even on domain addon.

The knowledge you provided has got me on the right track I believe though. I can achieve what I need using "/var/cpanel/userdata/username/domain.com" and changing document root. What I need to accomplish finding a way to create a script that will do the following post-processes:

1) Account Created -> set document root to [source location]
2) Sub-domain Created -> set document root to [source location]

********************************************************
If possible, I would like to throw in an IF / ELSE statement for the sub-domain creation that will set it to [source location] only if something is checked, otherwise will goto username/domain/public_html.

EXAMPLE:

blog.domain.com -> checked -> [source location]
blog2.domain.com -> unchecked -> default (aka [username/domain/public_html])
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
38
248
somewhere over the rainbow
cPanel Access Level
Root Administrator
You are getting into territory that should be posted into the developers section of the forum. Manual configuration changes and what needs to be changed along with simple scripting can be posted here, but once you are asking questions on a script you are writing to modify accounts on creation, that is development.

That forum would be the following:

cPanel Developers