Knowledgebase

Setting Up Virtual Hosts for Multiple Sites Print

  • vpsservermanagement, domain, php, dns, guide, howto, solution, zillionkinghost
  • 0

Running several websites on one server.

THE CONCEPT

The web server uses the hostname in each request to decide which site to serve. Each site has a configuration block specifying its domain and its document root.

WITH APACHE

Create a configuration file per site defining the server name, any aliases, the document root, and logging.

Enable the site and reload.

WITH NGINX

Similar, using server blocks. Create the configuration, link it into the enabled directory, test and reload.

WHAT EACH SITE NEEDS

Its own document root Its own log files, so you can diagnose one site without wading through another's traffic Its own system user, for isolation Its own PHP-FPM pool, if you run PHP

THE DEFAULT SITE

Configure what happens when a request arrives for a hostname you do not host. Serving your first site by default is confusing; a blank default is cleaner.

TESTING

Use a hosts file entry to test each site before pointing DNS.

WITH A CONTROL PANEL

All of this is handled when you add a domain. Do not configure it manually alongside.


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot