Free php and cpanel scripts to automate your daily routine

Free PHP Scripts :: cPanel Subdomains Creator

Use cPanel Subdomain Creator to create subdomains on cPanel based hosting.

  • cPanel account username
  • cPanel account password
  • cPanel skin (see Determining your cPanel Theme/Skin for more info on how to determine cPanel skin)
  • list of subdomains to be created in the plain text file (if creating from file)
  • Parent domain name (can create subdomains for different domains when creating from file)

Update program header with above settings and script is ready to use.

Usage: (you can use this script in either way)
  • Open script in browser and fill the form data
  • Pass all information via URL (form will not appear in this case)
    Example: cpanel_subdomains.php?cpaneluser=USER&cpanelpass=PASSWORD&domain=DOMAIN&subdomain=SUBDOMAIN
  • List all subdomains to be created in the plain text file

Note: If script cannot find file with subdomains and no parameters passed via URL then it will show input form.

Download cPanel Subdomains Creator


July 14, 2006
I wish I could find it earlier :( Payed $10 for such script recently.
August 1, 2006
can u please make another version that allow me to write the domain name and the user name in a form and then the account is created ??
zubrag August 2, 2006
Now it can handle three ways: input form, parameters via URL, or subdomains list from file.
August 4, 2006
There's no option for which plan to use?
What does this default to when there are several plans available for one domain?
I wouldn't want subdomains to have the same quotas and features as the main account. eg: unlimited, if I'm setting up member subdomains.

zubrag: It just creates subdomains with same quotas and features as the main account. We are going to develop the cPanel WHM User Accounts Creator soon for those who need automatical user accounts set up (mostly hosting resellers). It will be separate script, since it will require access to cPanel Web Host Manager.
Cookie August 9, 2006
I like this script alot but it would be handy if it created a ftp account as well.
zubrag August 9, 2006
Cookie, we are going to implement adding FTP account. Please check back in few days.
August 14, 2006
When you create Cpanel subdomains through WHM, You must choose the package it will be assigned. Otherwise, the subdomain will have the same privelledges and quotas as the parent account.
This is NOT something you want if you are a reseller or if you are prividing userspace.
In order to protect other users and the main account with suexec, limit shell access, define frontpage extensions on/off, etc, the package should be assigned when creating the subdomain ;)
Otherwise, this script would only be suitable for a single user cpanel account.
August 19, 2006
how i can delete subdomein with this script?
cnielson [anti-spam] cmaiinc.com August 20, 2006
I succeeded on first attempt to create a single sub-domain using form..worked great...

How would I write the browser command to use a list?

This is not clear to me..... I understand I could create a list (in say a txt file--listing the sub-domains..) and then what would be the format of the command ....

Great tool...and thanks for your help..
Charlie Nielson


zubrag August 20, 2006
You cannot delete subdomains with this script. It can only create subdomains.

If you want it to create subdomains from file then:
1. you will need to create file named 'domains.txt' which would contain list of subdomains (one per line).
2. use following command:
Above DOMAIN is domain for which you want to create subdomains.
santino [anti-spam] uhupi.com September 8, 2006
I find this script great, but the problem I have is that when I create a subdomain it redirects automatic to the folder with the same name, for example, I do www.sub.domain.com i created the subdomain call SUB, and automaticlly create a folder calls SUB and redirect there, how can I do to add also a diferent redirection in the same time the subdomain register.
Karl September 17, 2006
Wish is was more secure, so that only select people can run the script.
September 23, 2006
Thanks man! It works perfectly!
Will September 25, 2006
Excellent script, thanks!
lungu_bogdan [anti-spam] yahoo.com September 29, 2006
Good ideea! Worked perfectly. Thanks!
abuhark [anti-spam] gmail.com October 19, 2006
Any give me same for hosting contrller pl
buy cheap domains October 20, 2006
Karl, I did what you want with http://www.zubrag.com/scripts/password-protect.php

You'll get password protected domain creator
Hybrid November 5, 2006
This is looking great!
s.anand1 [anti-spam] gmail.com November 8, 2006
Thanks for this script. It was really awesome of you.

I know only very basic PHP..should I delete any of the "define" lines if I am choosing to take one of the options or can i simply copy the code and work?

I seem to be having some problem here.
raju November 14, 2006
Nice script, I have extended the script once more. Your visitors can signup for their own email accout and you can set quota for each.
Moreover, I converted into a class for greater inconvience.

visit http://www.rajuru.xenexbd.com/
roachd [anti-spam] roachville.com November 16, 2006
You are the man! Great solution. Keep it up.
nakiox [anti-spam] hotmail.com November 18, 2006
Hi! nice Script.. well.. but I need help.. I need to auto create subdomains when a user sign up to my website.. is secure if I send the cpanel user and pasword by hidden variables? .. can some inteligent user get my cpanel user and password ?..
please reply to my email if you can!
Thanks a lot.
sat_verman [anti-spam] rediffmail.com November 28, 2006
Hi! nice Script.. well.. but I need help.. I need to auto create subdomains when a user sign up to my website.. is secure if I send the cpanel user and pasword by hidden variables? .. can some inteligent user get my cpanel user and password ?..
please reply to my email if you can!
Thanks a lot.
mustatin [anti-spam] yahoo.com December 21, 2006
great script man, but can you give us a solution to delete subdomain also?
Johan January 3, 2007
Great script, even for somebody without knowledge of php, it is easy to handle.
Shouldn't it be easy to change a little in the php source code, so that it can automatically delete the subdomains also?
brandonchall [anti-spam] comcast.net January 4, 2007
I need a custom script created. I would like to speak with you about creating it. Of course, I would be willing to pay for your time. Please contact me at the above email address. Thanks.
January 16, 2007
great script! was playing around with rewriterules to try and fake it... just what i was looking for!
wizard_tn [anti-spam] hotmail.com January 17, 2007
I tried running this to enter multiple subdomains from the text file.

1st run: 4 names in file.. quit after 3 creations

2nd run: 44 names in file.. quit after 5 creations.

Does not seem to handle the creation from the .txt file well.

Any suggestions?
Mastermind January 24, 2007
Thanks for the script, this is very useful!
It works perfect...
Jillian January 24, 2007
Thank you so much, I have been tearing my hair out trying to figure out how to do this...
February 13, 2007
hi, when running the script throgh form error comes: Warning: fsockopen() [function.fsockopen]: unable to connect to localhost:2082 in /home/www/a43837f89b961fe6c2f05ce023e384e2/web/cpanel_subdomains.php on line 87
Socket error . Please help
kevindill [anti-spam] yahoo.com February 14, 2007
Hi, does anyone know a script that can remove multiple subdomains? I installed a bunch and they need to be deleted and reinstalled. Thanks for any information.
Bunny February 22, 2007
HTTP/1.0 404 Not Found Server: cpsrvd/10.9.6 Connection: close Content-type: text/html 404 Not Found Not Found The server was not able to find the document (./frontend/x/subdomain/doadddomain.html) you requested Please check the url and try again. You might also want to report this error to your webhost. cpsrvd/10.9.6 Server at localhost

i got above error when i creating subdomain
please help me
February 25, 2007
Set "x2" as cPanel Skin (without ")
hmqasimali201 [anti-spam] yahoo.co.in February 28, 2007
please help sokket error
enjoygame [anti-spam] hotmail.com - http://www.virtualdarpan.com April 28, 2007
thanks its fine in cpanel but i couldn't get success with vdeck. and its nightmare using vdeck for subdomain coz u are told to create unlimited[i mean allowed] but there is no space than 10. it would be great if this script help with vdeck.
Pink May 23, 2007
Can you please explain the process step by step what exactly i have to do after downloading the file , if i want to run and test the creation of sub domain like suman.example.com.
eddie June 2, 2007
Are you interesting to write about redirect system with cpanel subdomain include member system? I agree pay money for it!
my-email is eddie0936031870@gmail.com
xivworker [anti-spam] yahoo.com August 4, 2007
thanks a lot
Qenzoz August 25, 2007
I get Socket error
what shall i enter in Domain: ?
infosgsl [anti-spam] dbzmail.com September 1, 2007
I want a free subdomain hosting to test my website
narenderkota [anti-spam] yahoo.com September 26, 2007
Is this the way of, which the blogger blogspot will create subdomains ?
Sony "mobitrek" AK September 30, 2007
Hi Zubrag, great script, i'm using the script for our subdomain creation at mobitrek.com for our community. Keep the good work!! (Sony AK from Mobitrek Mobile Solutions Indonesia http://m.mobitrek.com)
Glyn October 19, 2007
Instead of creating folder on the root, how about within a subfolder?
for example, testing.domain.com, instead of /public_html/testing, can we have /public_html/folder1/folder2/testing

Glyn October 19, 2007
btw, my email is tantaikooi[anti-spam]gmail.com
mattruler [anti-spam] gmail.com November 11, 2007
Hi, is there any way to change the default directory for the subdomain??
acromm [anti-spam] gmail.com November 16, 2007
yes, send the &dir parameter in the URL with,
alongkorn.s [anti-spam] gmail.com December 15, 2007
I 'm very thank you for your scripts, its help me to solve problem about mass domains addon.
Finally that it's success.

webmaster [anti-spam] ourwedding.in December 26, 2007
We use your scripts to create subdomain. The hosting services provider has upgraded to ver 11 (cpanel). Your scripts fail now. We were advised to specify the default path when we create the subdomains (these were created in root folder and should have been created in public_html or the www folder).

Let's know how we define the 'path' .

Thanks in advance for your time.
December 28, 2007
This script took down my entire server.
hulkbaba [anti-spam] hulkbaba.com December 29, 2007
Hi, great work but my server gone down too =(
GTXPC December 31, 2007
Code is good, but something needs to be check because after the script it't run makes Server go down something changes in teh httpd file or config, that is not good. has to be a way to fix this. zubrag please check the code. thank you gtxpc
iman.khaghani [anti-spam] gmail.com January 6, 2008
this code cause the server to be down. i tried this code on payamtejarat.net which cause their apache server to be down two times and they suspend my account. my hosting Cpanel is cpanel 11-X3 zubrag it is very necessary to fix the bug or give a solution for it
January 11, 2008
Server getting down. Actually sth wrong with apache.
Also as soon as subdomain is created, the folder is also being created. But, there is a funny sign at the end of the folder.

Dan January 14, 2008
This crashed 2 different servers. It kills the httpd server process. We tried this on both of our servers with the same results. Strange since about 3 months ago this worked fine on our server and now it crashes it every time? Any fix yet?
January 23, 2008

I'm a newbie on this stuff. What is a subdomain?
January 23, 2008
waiting to fix bug then download, otherwise...

= zubrag = January 23, 2008
Looks like subdomains create process has been changed in cPanel 11. This forum thread has info on how to fix if you are on cPanel 11. Meanwhile i'm trying to automate the process somehow. Please do not post your questions here, post them on the forum. Thank you!

Aila January 27, 2008
Sorry for breaking your rule. my internet connection is down at the moment and alot of links that i go to don't work. well, um... i'm kinda knew to adding subs n stuff so yea...

oh, and i filled out the form thing then i pressed create subdomain or something like that, and i got this error.

HTTP/1.0 401 Access Denied Still Working Connection: close Set-Cookie: logintheme=cpanel; path=/ Set-Cookie: cprelogin=no; path=/ Set-Cookie: cpsession=closed; path=/ Server: cpsrvd/11.2.2 Content-type: text/html cPanel® 11 Login Username Password © cPanel, Inc. 2006-2008

please reply when u have the chance. most appreciate it if u can reply on my site.

developer.suresh [anti-spam] gmail.com April 7, 2008

i am try this cpanel sub domain creater script.really good.i got one issue.
i can see all sub domain in cpanel after using this script.

but, sub domain folder not created in FTP.plese help me.
mkomcihael [anti-spam] yahoo.com May 16, 2008
i need the best of the cpanel
Chris May 22, 2008
as for deleting domain this url can be used i think:
admin [anti-spam] 2-wap.net June 3, 2008
zubrag in cpanel 11.23 it didnot work even i changed all themes and

$name = 'test';
$server_name = 'mysite.com';
$cpanel_login = 'login';
$cpanel_pass = 'password';
$cpanel_server = 'www.mysite.com';
$dir = 'public_html/' . $name;

file("http://" . $cpanel_login . ":" . $cpanel_pass . "@" . $cpanel_server . ":2082/frontend/x3/subdomain/doadddomain.html?domain=$name&rootdomain=$server_name&dir=$dir");

i do have vps server if u want check i will give you login if you want make it workable thanks
a June 17, 2008
June 21, 2008
Found something is adding this charecter to httpd.conf ^M

Still investigating...
melbinsolomon [anti-spam] gmail.com July 29, 2008
I checket it on cPanel 11.23 and it worked.

First in crashed the server, then i modified the code as below
$request = "/frontend/$cpanel_skin/subdomain/doadddomain.html?domain=$subdomain&rootdomain=$rootdomain";
melbinsolomon [anti-spam] gmail.com July 29, 2008
It created the subdomain and subfolders as well
leon_artan [anti-spam] yahoo.com August 19, 2008
can i modify it so i can create addon domain?

create addon domain is almost similar with sub-domain, but i don't know how to modify it so also can create addon domain name.
= zubrag = August 23, 2008
August 29, 2008
Looks like subdomains create process has been changed in cPanel 11. This forum thread has info on how to fix if you are on cPanel 11. Meanwhile i'm trying to automate the process somehow. Please do not post your questions here, post them on the forum. Thank you!
tartub [anti-spam] hotmail.com August 30, 2008
انا عندي موقع اشتريته والحينه يوم غيرة الباسورد نسيت الباسورد لاني ما سويت اد له
شو اسوي عشان اقدر ارجعه
neex1233 [anti-spam] aol.com September 12, 2008
Hi. I would really like to know what this script does. It seems useful.
Anil September 26, 2008
You are great providing such a useful scripts
info [anti-spam] classifiedsgoa.com October 16, 2008
Nice Script
sneha_pooja114985 [anti-spam] yahoo.co.in November 3, 2008
I am preparing for BSNL TTA exam please tell me is your practice paper EC vol I & II are helpful for me or not
Gen January 24, 2009
Gamex February 28, 2009
Great tool...and thanks for your help.

vaibhav.nadgonde1980 [anti-spam] gmail.com March 19, 2009
well I was just wondering but can anybody give me some idea that how can I move all the files and folders in my main domain to this newly created sub domain through such a php script.
kurniawanchan [anti-spam] yahoo.com.sg March 25, 2009

this is a great script. I really needed it for my member site.
The creation of subdomain is successfull but the only problem is that subdomain is cannot be accessed. Please help me...
maleosx [anti-spam] gmail.com April 4, 2009
hello is this script safe for create a multiple hundred thousand of subdomain?
jon April 6, 2009
hi. im on a free host and only allowed 1 sub domain. it is already used but can i with this script make more sub domains?
April 29, 2009
Plz Help this script create sub domain but not create directory with sub domain name in root directory
April 30, 2009
Hello: I tried to create sub domain through this script, sub domain is created successfully. However name of directory created for each sub domain is not valid. There are few more characters being added with in directory name or some time few characters are removed. I did not edited the default script. Just uploaded script in my domain and used that. But I am facing issue with directory name, Any advise? Thanks
flappi282 [anti-spam] yahoo.co.uk June 28, 2009
Do you have to create a folder as well. When i went on File Manager, i got DATA ERROR.
karthik.shanmugam [anti-spam] g-antssoft.com July 8, 2009

i am try this cpanel sub domain creater script.really good.i got one issue.
i can see all sub domain in cpanel after using this script.

but, sub domain folder not created in FTP.plese help me.
July 22, 2009
Hi. This is a really pleasant script. Thank you.
August 12, 2009
:( I can't seem to get it to open in a browser.....
derbl001 [anti-spam] Sgfl.org.uk August 24, 2009
How do i create admin user
would this allow free sub domains?
writetunji [anti-spam] yahoo.com August 31, 2009
i have a domain (for example, www.go.com) but am puzzled on how to do any of the following with:
1. creating subdomains to external users by filling the form by these users and will be automatically created.
2. creating subdomains after the first subdomains, e.g sub2.sub1.go.com
What are the critical cases i may be having with my host server?
Thanks in anticipation

michel [anti-spam] facilinfor.be September 4, 2009

It seems that it is a wonderful script, but... I use it only without file, i.e. via the form. And I encounter the following problem : the subdomain is well created, but the folder that is created contains a carriage return in its file name. So, if I create the subdoamin test of mydomain.com, when I go in it, the navigator displays in the address bar mydomain.com/test%0D/. And of course, it causes some other problems...

Does anybody knows this problem ?


michel [anti-spam] facilinfor.be September 4, 2009
I read previous comments : it seems that I am not the only one with this problem !
Mathew September 21, 2009
Did you CHMOD the .php file to 0777 for it to have access and create it?
arunharidas [anti-spam] gmail.com September 27, 2009
heyy my server down for hrs after running this script .. Data center said that the script is messing with core files.
i think the 'dir' parameter is missing with the script.
October 7, 2009
Me too i had to remove the script again from my site. www.brainemple.org
November 27, 2009
ok, so, is it free, and does it have any viruses?
December 19, 2009
Mir December 25, 2009
This script is pretty old, if you need to do this, just look at the cpanel API.
ketan January 18, 2010
this scipt works its outstanding azaing thankx a lot
burf2000 [anti-spam] gmail.com February 16, 2010
Brilliant script!
March 23, 2010
Enter * into cpanel for unlimited sub domains.

This is the wild card character.

Tip from: internetmarketingcoding.com
Thobib March 26, 2010
This script is helpful. i love it.

shiva March 29, 2010
I have siteground hosting server i try to create the subdomain but i am unable to create is the parameter /frontend/ differ for each hosting server.

Waiting for reply....
hexl April 12, 2010
where to install, how to use? can any one help please
maurice May 29, 2010
I modified this script a bit to be able to change the default directory. You should include that too.

$cpuser = 'Username';
$cppass = 'Password';
$cpdomain = 'domain.com';
$cpskin = 'x3';

//defining constructor
function cpsubdomain($cpuser,$cppass,$cpdomain,$cpskin='x',$cpdirect){

and also changed this
jewelhuq [anti-spam] ymail.com June 3, 2010
Thankx to this script
pedma June 18, 2010
Hallo Maurice,

Could you please send me the modified scripts to: pedmajungne[anti-spam]gmail.com ?

Many thanks
- pedma -
pedma June 18, 2010

Thanks to the scripts. Great !! One question, how to change the directory ?

I use this :

But it create the 'testing' directory always under 'public_html' , not 'public_html/mydir' .

I think the "&dir= .... " didn't work.
How to solve this ?

- pedma -
pedmajungne [ anti-spam ] gmail.com
yongsheng July 2, 2010
pedma, that is because the page (cpanel_subdomain.php) does not read dir param.

easier way out would be go in the file and change $request to:
$request = "/frontend/$cpanel_skin/subdomain/doadddomain.html?rootdomain=$domain&domain=$subd&dir=public_html/mydir/$subd";

for this example, if you creating subdomain 'you', it will automatically create as 'mydir/you'.
abaaba2010 [anti-spam] gmail.com August 8, 2010
Have you got a template of your script with its form?
microprocessor August 24, 2010
Hello everyone.

I used this code before. it works! perfectly. but now, my hosting using latest cpanel, which has cpsess, a session for cpanel. the session is for security reason (against XSRF attacks).

this makes the code cannot be used anymore as each and every login will have new session and the new session will be append at the URL path.

to overcome this problem, i manage to find a good solution here:


please download xmlapi.php and link the file to the code

$xmlapi = new xmlapi('');
print $xmlapi->api1_query('accountname','SubDomain','addsubdomain',array('sub','domain.com',0,0,'/public_html/folder'));

refer here for detail: http://forums.cpanel.net/f42/add-subdomain-using-api-119609.html

i tried, it works!
Om Technologies August 27, 2010

In case you have a cpanel based account, then you can easily create subdomain using php. Here is the link that shows how to create subdomain using PHP.


This site has more quick php tutorials to various other whm and cpanel functionalies so you can check them out too...

Om Technologies
The best web development php company
Patrick November 30, 2010
@santino -- I Was able to get around the script automatically making its own folder of the same name for the ftp account by configuring my make-ftp-account script to immediately delete the files and folders made by this script and then creating a sym link to the root of the site, where I originally wanted the subdomain to point (because I'm running Drupal and all sites on domains and subdomains point to the same folder).
cifi21 [anti-spam] yahoo.com December 11, 2010
Great script
phpcpanel [anti-spam] gmail.com December 24, 2010

Hi! PHPcPanel is an opensource tool for automatically manage cPanel without requiring manually login.

It can automatically manage your cpane for creating FTP and mysql accounts. If you are a web master, you could easily combine PHPcPanel to your projects. Enjoy!

(1) Automatically login your cpanel without goto cpanel;

(2) Create/Edit ftp account by using PHP function;

(3) Create/Edit mysql account by using PHP function;

(4) It is easily combine PHPcPanel to your own php project to manage your cPanel..
PHPcPanel [anti-spam] gmail.com December 27, 2010


PHPcPanel is a opensource program used to manage your cPanel without requiring login manually. This package can let you easily open a new ftp account or mysql account.



(1) automatically login your cpanel ;

(2) easily create/edit/delete ftp account;

(3) easily create/editdelete mysql account;

(4) easily create/delete floder;

(5) easily create/delete sub-domain;

(6) text file based, no need of database support.

(7) It is easily combined in your php project for managing cPanel.
vicky.soni [anti-spam] ymail.com February 26, 2011
i want a modified script of it by which i can call a php function like-
and this will autometically creat a subdomain plz anybody help me
mrjazzz [anti-spam] gmail.com April 24, 2011
Very happy to see that so many people use it successfully... That means, it works... But for some reason, it does not work for me... I have a cpanel host mod_rewrite anable, I have turned around all the possibilities of the form, tried skin x x1 x2 x3 x4... x3 gives different answer but still nothing works... I seriously need such a script to work, if anyone is volunteer to help, I could give a fair donation through paypal...

skin x3 sends back:

HTTP/1.0 200 OK Server: cpsrvd/11.28.87 Connection: close Cache-Control: no-cache Pragma: no-cache Content-type:
earthworldlink [anti-spam] yahoo.com June 23, 2011
Great script. Will try this on http://sco.cc
gg July 6, 2011
this is just what i need :)
wanttobe July 19, 2011
Great, it works (for one of my domain). but in the end of creating subdomain the page show something similar to success page if we create on cpanel, but in text format (include html code).
how to remove that?
sebastian July 22, 2011
Great script, thank you for that.
Installed on www.infohost.ro and created a few subdomains. Thank you again.
mstevens [anti-spam] drrp.net October 3, 2011
when your script creates a sub-domain, unlike a cpanel creation, it does not load the index page from the cpane.3-skel directory. can your script do this? i create 100s of subs at a time and it is very time consuming to ftp the index.php into each new sub. your script is great and works without a hitch, except for this unless it is something we are not doing correctly
php.ajay [anti-spam] gmail.com October 31, 2011
Hi , this script is very useful. But i have a problem that how to point the subdomain to root domain in this script.I need all subdomains need to point to root domain. But in this script it is not pointing to the document_root.It is pointing to public_html/subdomain , but i need pulic_html/. Can you assist me in this regard. Thanks in advance
lingeshram.cse [anti-spam] gmail.com November 17, 2011
good job dear. Thank you ..
aminmajid.aminmajid [anti-spam] yahoo.com November 27, 2011
do i have to edit in it?
herusoni [anti-spam] yahoo.com December 1, 2011
hi... ask, how about cname creator? with PHP.. can you help me?
ankeshhimesh [anti-spam] gmail.com December 20, 2011
nice script through
i had paied 50$ for it before and now i find this free here
nikworld.tk [anti-spam] gmail.com March 2, 2012
This script is creating subdomain , but do not set NS CNAME A MX records. please make this
thanga209 [anti-spam] gmail.com March 7, 2012
I really say thanks, i downloaded the sub domain creator script, it works well as i expected.

Thanks again.
erikoblovid [anti-spam] yahoo.com April 13, 2012
Hey. Thanks for these great scripts. I am particularly interested in the Mass Subdomain Creator Script but I can't get it to work.
Is it working? Please provide some further directions to help me.
I get this message when I try:

HTTP/1.1 401 Access Denied Connection: close Set-Cookie: logintheme=cpanel; path=/; HttpOnly; port=2082 Set-Cookie: cprelogin=no; path=/; HttpOnly; port=2082 Set-Cookie: cpsession=xrRmOTeawhE0q5fVIDpeklnyXRUhWLzYeYUimci3OIlI_aOO_9k3bYF3662ZkUPA; path=/; HttpOnly; port=2082 Server: cpsrvd/ Content-type: text/html cPanel® 11 Login Username Password // © cPanel, Inc. 2011

May 31, 2012
go fawk yourself with this script!
Dee June 11, 2012
I managed to get some performance from this script by adding the following at the top:

// Ignore user aborts and allow the script
// to run forever
$page = $_SERVER['PHP_SELF'];
$sec = "10";
header("Refresh: $sec; url=$page");

function cutline($filename,$line_no=-1) {



if($line_no==-1) $skip=$size-1;
else $skip=$line_no-1;


return $strip_return;

Then at the end I changed $show too:

$show = strip_tags($result);
$out = substr($show, -870);
$out2 = substr($out, 0, 200);
print $out2;
flush(); @ob_flush();
echo ("<br /><br />");
flush(); @ob_flush();

cutline('domains.txt',1); // deletes line 6 in foo.txt

Have fun!
toto_bod [anti-spam] yahoo.com October 16, 2012
This script works great!

You need to change the SKIN if you get 'Connection Close' or something.
dvir April 23, 2013
this is the great!
bru June 17, 2013
I managed to create the subdomain but now I can't reach it without the www (www.subdomain.domain.com)
All the dns settings seems to be ok... what can i do?
July 7, 2013
owe you a beer! great script!
maij_shaikh [anti-spam] rediffmail.com July 27, 2013
noorahmedf9 [anti-spam] gmail.com November 1, 2013
unable to connect to localhost:2082

this is the warning.
leclicdelasouris [anti-spam] free.fr May 1, 2014
hello I can write to you because I think your really great scripts I would like to know how to I can just offer my clients just create a subdomain name and also as proposed by dns on (www.azote.org) would you advice or script already please
to answer me "leclicdelasouris@free.fr"
noelcat [anti-spam] allsites.com May 16, 2014
Maybe this should be obvious as long as I have been using WHM, but where do you install this script on the server? Everywhere I try getting security token errors.
User August 10, 2014
Thank you very much for Amazing script!!
Dawood October 20, 2014
Please help me. I get error <b>Socket Error.</b>
shervin_445 [anti-spam] yahoo.com January 19, 2015
http://www.khaleghjoo.com site design, windows programming, network programming, microcontroller programming by shervin khaleghjoo
andrihantya [anti-spam] gmail.com February 1, 2015
nice, i've done make thousands of subdomain. but then the hosting banned me, lol. so i decided to rent vps, but since the license fee of vps cpanel is so expensive, bigger than the vps monthly fee, so i use webuzo. i hope You can make subdomain creator for webuzo, thx.
anamuddin162 [anti-spam] yahoo.com February 20, 2015
The connection was reset?
Amit Sandal May 7, 2015
The Code does not work plus there is no connection between the function called. I don't how it work for others. The first function only check the subdomain text file is there or not and other function does get any values in the variables. If i am doing something wrong please help.
Amit Sandal May 7, 2015
I am sorry. It perfectly . just get the wrong path . but ut made the sub domain. Thanks alot for the script.
info [anti-spam] test.school July 7, 2015
thanks for sharing, .. helpful . even more so it would be if it would be possible to batch add-on domains to cpanel ? and then with this script create subdomains out of those .. any suggestion would be great, im stuck.
minibox68 [anti-spam] gmail.com October 18, 2015

Hello everybody! I am not well versed in php , still learning . Can you help me change this script formations subdomain with ip redirects ( http://123.456.789.00 ) . thank you!
rahulraghav1989 [anti-spam] rediffmail.com March 28, 2016
why i am getting this error?

HTTP/1.1 301 Moved Server: cpsrvd/ Connection: close Content-length: 162 Location: /frontend/x3/subdomain/doadddomain.html?rootdomain=wforall.com&domain=tech Content-type: text/html; charset="utf-8" Cache-Control: no-cache, must-revalidate Pragma: no-cache
Bohdan April 4, 2016
Got this script working https://gist.github.com/g3d/f7b912fc72dc080855021b44ee2346f0
Mike August 24, 2016
It works well, but how can i get to specify my document root. for example i want my document root to be created in public_html folder
daniel [anti-spam] gmail.com May 24, 2017
not well
Thanks December 6, 2017
Thanks, I looked everywhere and found only two versions that works: yours and another in this blog ( domainoverflow dot com ). So many years. thanks for sharing.
shivneetns [anti-spam] gmail.com February 10, 2018
Not working any more giving error page moved 302
khokon May 12, 2021
Hi, just wanted to let you know that, this method doesn't work anymore, can you share an updated version?