Create Subdomain (on the fly) by using PHP

i try to find way for user to register in my web. they just need to fill in their name,phone,email address and subdomain field
that need to create.

PHP will execute the command to create subdomain if there is no user register under that subdomain after created the subdomain, this information will store in database (name,phone,emailaddress, subdomain) and is it possible to do that?
my webhost control panel are not using cpanel , my domain i already point using Digital Ocean DNS. thanks
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

First, you need to set up your DNS to allow wildcard domains. Your DNS provider should have instructions on how to do that.

Next, you need to update your server configuration to point to a specific folder for the given subdomain (e.g. goes to /websites/ For Apache, you can use the mod_vhost_alias extension to dynamically route traffic:

LoadModule vhost_alias_module modules/

NameVirtualHost *:80

<VirtualHost *:80>
    VirtualDocumentRoot /websites/

You can read the documentation for that extension here:

You don't really need PHP to update any configuration, but you'd probably want it to create the folder structure for the desired subdomain. Just be careful and make sure you sanitize the name (remove any characters besides numbers and letters - there are other characters that are allowed, but numbers/letters are always a safe bet) before you use the name to create the folder. Also, make sure the name doesn't exist already. :)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.