# Virtual Host File

### Moodle Virtual Host File

1. Create a virtual host configuration file for Moodle, like the example below (replacing subdomain.domain.com with an appropriate name). For more information on how to do this, see [Apache Virtual Hosts](https://docs.azandi.co.za/books/centos-server---configs/page/apache-virtual-hosts)

```
<VirtualHost subdomain.domain.com:80>
        ServerName subdomain.domain.com

        Redirect permanent / https://subdomain.domain.com

</VirtualHost>

<VirtualHost subdomain.domain.com:443>
        ServerName subdomain.domain.com

        DocumentRoot "/var/www/subdomain.domain.com"
        <Directory "/var/www/subdomain.domain.com">

        Options Indexes FollowSymLinks MultiViews
        # AllowOverride controls what directives may be placed in .htaccess files.
        AllowOverride All

        # Controls who can get stuff from this server file
        Order allow,deny
        Allow from all

        </Directory>

        <IfModule mpm_peruser_module>
                ServerEnvironment apache apache
        </IfModule>

</VirtualHost>

```