Introduction:
Managing domains through the cPanel graphical interface is common, but for system administrators and developers, the command line often provides more speed, flexibility, and opportunities for automation. Using cPanel’s UAPI (Universal API), we can easily add an Addon Domain directly from the command line.
Steps to Add an Addon Domain Using UAPI:
Step 1:
Log in to cPanel server as the cPanel user
ssh username@ServerIP |
Note: Replace username
with the cPanel account’s username.
Step 2:
Before adding a new addon domain, we can list existing domains linked to the cPanel account
uapi –user=username DomainInfo list_domains |
This command will display primary, addon, parked, and subdomains already configured.
Step 3:
Run the following command to add a new addon domain
uapi –user=username SubDomain addsubdomain domain=test.example.com rootdomain=example.com dir=public_html/example |
Explanation of options:
--user=username
→ The username of cPanel account under which we are adding the domain.domain=test.example.com
→ The domain name we want to add.dir=public_html/example
→ The document root (where website files will be stored).subdomain=example
.com → A subdomain automatically created and linked to the addon domain.
Step 4:
After execution, we can confirm the new addon domain was added by running.
uapi –user=username DomainInfo list_domains |
we should now see test.example.com
listed under addon domains
Conclusion:
Adding an addon domain through the cPanel CLI with UAPI provides a fast, scriptable, and efficient way to manage multiple websites from one account. Instead of navigating through the cPanel dashboard, administrators can execute a single command to create addon domains.