JGuizard
9/22/2017 - 5:52 PM

Apache virtualhost for subdomain

1 - Go in the DNS settings for your domain
2 - Create a new A entry with hostname = [subdomain] and IP = [server_ip]
3 - On your server create a new Apache's virtualhost site on etc/apache2/site-availables/[subdomain].[domain].conf
4 - Paste in the file the following code
  <VirtualHost *:80>
      ServerAdmin admin@example.com
      ServerName [subdomain].[domain]
      ServerAlias www.[subdomain].[domain]
      DocumentRoot /var/www/html/[folder]
      ErrorLog ${APACHE_LOG_DIR}/error.log
      CustomLog ${APACHE_LOG_DIR}/access.log combined
  </VirtualHost>
  
  5 - In terminal, enable the site with: sudo apache2 a2ensite [subdomain].[domain].conf
  6 - Reload apache with: sudo apache2 reload