Subdomain Configuration on Ubuntu nginx Server

May 23, 2014 1.6k views
Hi, First of all, I'm sorry for my bad English. I'll try to explain my aim as much as possible. I'm using a 2 Core and 2 GB memory VPS with 1 dedicated ip address from Digital Ocean for my project. I'm using nginx as a webserver, MySQL as a database server and bind as a dns server. My project is a free hosting platform for educational purposes. I'll be teaching PHP and MySQL to students from my neighbourhood and i want them to practice on their own subdomain with a PHP and MySQL support. For example, my main domain name is : example.com I'll also setup a wildcard SSL for my domain. For example, student subdomain should be like this : student1.example.com Students will be able to activate their web space with the subdomain they choose automatically using my setup script which is writtern in PHP (a simple page). How can i achive this setup without using any control panel like cPanel or zPanel? How can any subdomain which is choosen by a student resolve my main domain? Can students use their own TLD domain on a setup like this? Do you have any suggestions for this kind of setup? Any help would be very much appreciated regarding this project. Kind Regards.
1 Answer
Hi Emrah!

That sounds like an extremely interesting project. I think the simplest way to accomplish what you're after is to set up a wildcard CNAME for the domain, and then script the creation of new nginx configuration files with server blocks that point to the new subdomain. Of course you wouldn't be able to script students using their own TLD domains with this solution, but I think that it is probably the simplest approach.

Let us know how it goes!
Have another answer? Share your knowledge.