Creating Apache virtual hosts

Apache virtual hosts are created with the apache module with the defined type apache::vhost. We will create a new vhost on our Apache webserver called navajo, one of the apache tribes.

How to do it...

Follow these steps to create Apache virtual hosts:

  1. Create a navajo apache::vhost definition as follows:
    apache::vhost { '':
        port          => '80',
        docroot => '/var/www/navajo',
  2. Create an index file for the new vhost:
    file {'/var/www/navajo/index.html':
        content => "<html>\\n\n</html>\n",
        mode    => '0644',
        require => Apache::Vhost['']
  3. Run Puppet to create the new vhost:
    [root@webserver ~]# puppet agent -t
    Info: Caching catalog for ...

Get DevOps: Puppet, Docker, and Kubernetes now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.