Automating virtual hosts

If we create a template file for a virtual host, we can easily drop new virtual hosts using a script. First, we need a template file that is similar to the following commands:

<VirtualHost *:80>
  ServerAdmin webmaster@dummy-host.example.com
  ServerName dummy-host.example.com
  DocumentRoot /var/www/dummy-host.example.com
  ErrorLog /var/log/httpd/dummy-host.example.com-error_log
  CustomLog /var/log/httpd/dummy-host.example.com-access_log
  UseCanonicalName Off
  ServerSignature On
  <Directory "/var/www/vhosts/dummy-host.example.com">
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
  </Directory>
</VirtualHost>

If this file is saved as /etc/httpd/conf.d/template, it will not be used as a configuration as it does not ...

Get Learning RHEL Networking 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.