Subdomain Configuration on Ubuntu nginx Server

  • Posted on May 23, 2014
  • emrahAsked by emrah


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 : I’ll also setup a wildcard SSL for my domain.

For example, student subdomain should be like this :

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.

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hi Emrah! <br> <br>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. <br> <br>Let us know how it goes!