Codementor Events

Creating and using Subdomains.

Published Mar 17, 2020

Creating and using Subdomains.

I use an instance on Google cloud and the instance is setup to restart every day.

We configured a python api on that server.

We now have to configure angular 8 website on the same server.

If we configured the api as a virtual host, then this website can be configured as another host.

However, our configuration of apache has been for domains.
We cannot mix and match domain type configurations and virtual host type configurations.

We need to configure our website as another subdomain. like
site.hopto.org

For this, added another A record in noip.com
like this:
Name IP
site.hopto.org <ip address of google instance>

Now the apache configurations.

  1. create a directory /var/www/<subdomain>.hopto.org
  2. Copy the website contents to the directory /var/www/<subdomain>.hopto.org
  3. Edit the file /etc/apache2/sites-available/<subdomain>.hopto.org
    This is now my file looks like:

<VirtualHost *:80>
ServerName subdomain.hopto.org

DocumentRoot /var/www/subdomain.hopto.org

Alias /awstatsclasses "/usr/share/awstats/lib/"
Alias /awstats-icon "/usr/share/awstats/icon/"
Alias /awstatscss "/usr/share/doc/awstats/examples/css"

ScriptAlias /awstats/ /usr/lib/cgi-bin/
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch

<directory /var/www/subdomain.hopto.org/>
Require all granted
Options FollowSymlinks
</directory>
</VirtualHost>

Now, enable this site like so:
sudo a2ensite subdomain.hopto.org.conf

Restart Apache:
sudo apachectl restart

The website will now be accessible at subdomain.hopto.org

Discover and read more posts from Rajaram K
get started
post commentsBe the first to share your opinion
Show more replies