In all instructions I found to setup vhosts on Ubuntu LAMP you need to create a new vhost conf file for each vhost. Can I declare all my vhosts in one single file and what I need to do for it?

  • Yeah, you can do more than one in a file. It doesn't require anything special, just open and close the sections as though they were in different files – Eric Renouf May 31 '17 at 0:54

You can do one big file, and if you only have a host name or two to worry about it will work fine. Even with LOTS of hosts one file will technically work.

BUT ... when you have lots of hosts (more than 2 or 3 for me), having each one in its own file, named after the FQDN w/ a SSL indicator (ie ssl-webapp3.example.com.conf or webapps.example.com.conf or www.example.com.conf) will make your life MUCH easier and be "more maintainable" in the long term, and it makes enabling/disabling individual hosts/sites easier as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.