Creating Apache virtual hosts
Apache virtual hosts are created with the apache
module with the apache::vhost
 defined type. We will create a new vhost
on our Apache webserver called navajo
, after one of the Apache tribes.Â
How to do it...
Follow these steps to create Apache virtual hosts:
- Create a
navajo apache::vhost
definition as follows:
apache::vhost { 'navajo.example.com': port => '80', docroot => '/var/www/navajo', }
- Create an index file for the new
vhost
:
$navajo = @(NAVAJO) <html> <head> <title>navajo.example.com</title> </head> <body>http://en.wikipedia. org/wiki/Navajo_people </body> </html> | NAVAJO file {'/var/www/navajo/index.html': content => $navajo, mode => '0644', require => Apache::Vhost['navajo.example.com'] }
- Run Puppet to create the new
vhost
:
[root@webserver ~]# puppet agent -t Info: Caching catalog for webserver.example.com ... Notice: /Stage[main]/Main/Node[webserver]/Apache...