I am setting up a LAMP server on my VPS which runs Ubuntu 16.04

The main use of the server will be to serve as a backend for a web application. The Apache will host the PHP files and the mySQL will host the data (testing environment).

I am following the following link to install the required https://www.linode.com/docs/websites/lamp/install-lamp-on-ubuntu-16-04 and in it there is a part where a VIRTUAL HOST is created.

My question is that, is it necessary to create a virtual host if only 1 site will run on the device?

  • Required by whom? Or, required in order to accomplish what purpose? :) – Wildcard Feb 7 '17 at 9:15
  • Required by me, as I will be hosting my php files on it that will fetch things from database and return to my app as JSON. – tony9099 Feb 7 '17 at 9:17
  • 2
    My question was mildly tongue-in-cheek. Obviously if you can accomplish what you are trying to accomplish without creating a virtual host, then it wasn't required. And if you're the one requiring it or not, and you do require it (mandate it), then it is required. There may be tradeoffs involved (performance, security, convenience, scalability), but you may be the best person to answer this. Because, in short: it depends an awful lot what your goal is. – Wildcard Feb 7 '17 at 9:22

If you are sure you only ever want one site running on your Ubuntu server, then the answer is no, it is not necessary to setup vhost configuration and the Linode documentation should put a footnote in there saying something to that effect.


I usually create two vhosts in such situations, namely one that serves as the default vhost which just serves an empty page (or something like "it works"); and another name-based vhost that actually serves the application.

This prevents drive-by scanning from hitting your application; as these usually just target the IP address without actually giving the correct hostname in the Host: header then these requests will be passed to the default vhost which only has a static index.html file. Hence these requests won't cause any load on your webserver / database. It also prevents your access log being dirtied by such scans.

So, no, it's not required, but it has its advantages.

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.