Configuring Subdomains Apache
Create DNS records.
- One A DNS Record for *.domain.com
- One A DNS Record for domain.com
Apache’s main web folder is /var/www/. There should already be the folder html in here. For this example, we’ll pretend we want to make the subdomain: test.example.com.
- First, you’ll want to create a directory in /var/www/ called “test” using mkdir -p /var/www/test/.
- Next, you’ll want to go to: /etc/apache2/sites-available/. In here there is a file called 000-default.conf. You will want to copy this file in the same directory, and name it: test.example.com.conf in our case.
- In this file, you’ll want to have the following code:
Options Indexes FollowSymLinks
Require all granted
CustomLog /access.log combined
- Then you’ll want to enable the subdomain:
- Finally, you’ll want to do a reload on the apache service to make sure the changes come through.
systemctl reload apache2
Now you should be good to go with your new subdomain!