How to create a website by pressing a button? With one button "create a website" while the user press that button it will create another website which is exactly the same like the first one. The only difference is that it will allow the user to select any name as they want which is followed by the same domain name.

For example:

user1.domain.com
user2.domain.com

How to do that? Is that possible? I am using codeigniter / laravel

I think your question is overly broad. You run the risk of folk telling you to watch https://www.youtube.com/watch?v=tNfGyIW7aHM as such a system would have a lot of machinery (code, apps, systems, payment system, databases and more) in the background. To the uninitiated it might seem like a Rube Goldberg design.

But there is hope. It's called System Design. That used to be a class in our programming courses in which you would document how a system works or create a new system. Not everything back then could be automated but today I know we can do it (see video?)

So there it is. You document how it is done now then automate it till it's distilled to that one button.

People move websites to different domains all the time. You just copy all the relevant files and databases and stick it where it needs to go. It's pretty fast. One click? Not quite THAT fast and generally there's at least a LITTLE thinking involved, but I imagine there are scripts out there. I feel quite confident there are. It has to be easy enough to do that code monkeys with minimal training can do it. Otherwise GoDaddy and HostGator would go out of business.

I highly doubt that it's written using CodeIgniter or Laravel. It's almost certainly written using shell scripts that zip up the contents, copy the zip file somewhere, then unzip. Ditto databases, etc. The only place Laravel or any other Framework comes into play is that you have to make sure that's where it needs to be in the destination and if not, zip that up, copy, and unzip too. You might use PHP to create the button and then, once clicked, that shell script is executed.

commented: I made a hammer in PHP, everything looks like a nail. +0

You might use PHP to create the button and then, once clicked, that shell script is executed.

Can you gives example of the script to make that works?

1) Once button press
2) From name request ex: name.domain.com
3) Use that name to create a website
4) Website is ready under name.domain.com

Everyone can create that same website with different name.domain.com (all of the same domain.com).

Should I use share hosting for this ? All different control panel? WHM

or

The same control panel different folders

Which is correct?

Assuming both websites are on the same server, I imagine for an easy website the shell script would create a public_html folder using the mkdir command, set some ownership and permissions on the new folder with the chown and chmod commands, use the tar command to tar/zip the public_html folder of the original site, use the cp or mv command to put the zip file in public_html, then the tar command again to unzip the files into the new destination folder. Plus everything else you have to do to get everything to work.

Everything you'd do manually on the command line as a system administrator to copy the website and get it working. Stick all the commands in a shell script. Pushing the button starts a server-side process that thru PHP that executes that shell script on the server.

You'll likely need to have a chat with your web hosting company's tech folks before you can do this. They likely know exactly what you need to do. I doubt you can do it without their help on Shared Hosting since this script might need root privileges.

There might be one-click options already thru CPanel or whatever. Why write it yourself?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.