triatlas

Member
Jan 27, 2017
19
2
3
Germany
cPanel Access Level
Root Administrator
I am trying to add an Addon Domain via cPanel but I get an error message saying:

"A domain cannot be parked on itself."

This is my current setup:
  • example.com -> Primary Account Domain -> pointing to /#account_user#/public_html/
  • Addon Domains are allowed for this account (WHM Account configuration)
  • The Domain dev.example.com is pointing to the server
  • Allow to create document root outside of public_html folder (Tweak Settings)
There are no errors when I add dev.example.com as subdomain, but this is not what I want.

My goal is:
dev.example.com -> Addon domain -> pointing to /dev.example.com/web/

With the new Addon Domain I want to create the following folder structure in order to place files containing sensitive data one level above the new document root /dev.example.com/web/

...
dev.example.com
- config
- vendor

- web
-> public folder similar to public_html
.env
.gitignore
composer.json
composer.lock
LICENCE.md
README.md
wp-cli.yml

public_html
-> public folder of example.com (primary domain)
...

As you might notice this is the bedrock folder structure created for running a WordPress site with composer and git. Placing the files containing sensitive data like database password are placed one level above the public folder.

So, does anyone has a clue why I cannot create the Addon Domain in my example.com cPanel account?
 
Last edited by a moderator:

triatlas

Member
Jan 27, 2017
19
2
3
Germany
cPanel Access Level
Root Administrator
An addon creates a subdomain and addon domain basically is a parked domain on that subdomain. I believe you cannot create the same addon in the server.
I am not sure if I understand you right, but there is no subdomain dev.example.com installed yet on the server. It is just pointing to the server by IP in order to be able to install it as an addon-Domain. So the creation of a new addon domain dev.example.com should work, shouldn't it?

By the way: I just saw I mixed up example.com and example.com in my initial post. It should all be example.com.
 
Last edited by a moderator:

cPanelLauren

Forums Analyst II
Staff member
Nov 14, 2017
6,816
541
263
Houston
cPanel Access Level
DataCenter Provider
It sounds like you do in fact want a subdomain though, based on the fact you want "dev.example.com to be the domain you're adding - this is literally a subdomain of example.com. Why is there a necessity for the addon instead of the subdomain? You can set the subdomain's documentroot however you'd like when you create it as well.
 

triatlas

Member
Jan 27, 2017
19
2
3
Germany
cPanel Access Level
Root Administrator
It sounds like you do in fact want a subdomain though, based on the fact you want "dev.example.com to be the domain you're adding - this is literally a subdomain of example.com. Why is there a necessity for the addon instead of the subdomain? You can set the subdomain's documentroot however you'd like when you create it as well.
Yes I see, what I wrote sounds like that, as it was meant as an example. Sorry for the confusion.

So to be more specific, my definite setup should look like this:

temp.website.com -> Primary Account, public_html -> not used because I need other file structure, can be completely other domain

website.com -> Addon-Domain with custom document root -> Live site

dev.website.com -> Addon-Domain with custom document root -> Staging site, password protected


So in the end, the folder structure of the account would look like:

website.com
- config
- vendor
- web -> public folder similar to public_html, Addon Domain documentroot will point here
.env
.gitignore
CHANGELOG.md
composer.json
composer.lock
LICENCE.md
README.md
wp-cli.yml​
dev.website.com
- config
- vendor
- web -> public folder similar to public_html, Addon Domain documentroot will point here
.env
.gitignore
CHANGELOG.md
composer.json
composer.lock
LICENCE.md
README.md
wp-cli.yml​
public_html -> public folder of temp.website.com (NOT USED, primary domain, can be completely other domain, will not be used)
...
other cPanel/account files on this level.


So what I want is to be independent of cPanels folder structure, creating subfolders for different sites in one account, which contain each one a "public_html"-like folder called "web". I read using addon Domains is the best practice with cPanel for that and compatible with updates, account migration, etc.

Do you think this is a clean solution in line with the possibilities of cPanel or would you recommend using another strategy to reach my goal?
 
Last edited:

cPanelLauren

Forums Analyst II
Staff member
Nov 14, 2017
6,816
541
263
Houston
cPanel Access Level
DataCenter Provider
If I understand correctly here's a simpler breakdown of what you're trying to do:

Code:
/home/$user:
website.com
- web -> public folder similar to public_html, Addon Domain documentroot will point here
dev.website.com
- web -> public folder similar to public_html, Addon Domain documentroot will point here
public_html -> public folder of temp.website.com (NOT USED, primary domain, can be completely other domain, will not be used)
...
There shouldn't be a problem with this, the only caveat is that the primary domain cannot be a subdomain of any other domain you're adding. For example I used the following to set this up:

domains_docroots.png

The Directory structure looks as follows:

directory_structure.png
 

triatlas

Member
Jan 27, 2017
19
2
3
Germany
cPanel Access Level
Root Administrator
Cool thanks!

I did not want to move all the emails etc. from the existing account (Live Site) under public_html. So I finally solved it like this (I post it here just for the case anyone wants to create a similar setup).


From this post SOLVED - Changing document root for primary domain does not work I did the following steps:

1. Update the "document root" value to the new path in the following files:

Code:
/var/cpanel/userdata/#USERNAME#/website.com
/var/cpanel/userdata/#USERNAME#/website.com_SSL

2. Remove the existing cache files:

Code:
rm /var/cpanel/userdata/#USERNAME#/website.com.cache
rm /var/cpanel/userdata/#USERNAME#/website.com_SSL.cache

3. Rebuild the cache files and the Apache configuration file:

Code:
/scripts/updateuserdatacache
/scripts/rebuildhttpdconf

4. Restart Apache:

Code:
/scripts/restartsrv_httpd
As I am using Apache FPM, the following additional steps had to be done:

In /var/cpanel/userdata/#USERNAME#/website.com.php-fpm.yaml add the following entry in order to set the custom document root:

Code:
php_admin_value_doc_root: { name: 'php_admin_value[doc_root]', value: /home/#USERNAME#/website.com/web }
Then rebuild PHP FPM Config and restart Apache FPM and HTTPD-Service.

Code:
/usr/local/cpanel/scripts/php_fpm_config --rebuild
/usr/local/cpanel/scripts/restartsrv_apache_php_fpm
/usr/local/cpanel/scripts/restartsrv_httpd
That's it, now working with the custom site structure which is open to adding more sites via addon domains or subdomains.
 
  • Like
Reactions: cPanelLauren