How to Configure a Subdomain in Apache2?
Being a cloud service providing company, in this blog, we taught you about How to set up subdomains on the Apache HTTP server.
A subdomain is a precursor that can be set up on a domain name. For instance, in "key.yoursite.com" the word "key" is the subdomain of the "yoursite.com" domain name.
How To Change Dns Zone File?
Before digging into the server to create a subdomain in apache2, let the domain name registrar know of the subdomains that you wanted to use. To do this, signed onto the registrar's site for managing the domain names, and went to edit the DNS Zone File.
A DNS Zone File is used by Internet routers to keep perfect track of where to send traffic that comes to the domain name. Mail traffic can be sent to the mail server, while FTP traffic could be to a server with a variety of IP addresses, and so on. Because Zone Files are not patriarchal, each subdomain must have its own way of the entry point in the file.
Anyway, when you got to the margin where you could edit my DNS Zone File, looked for the "CName" table, which documents the "alias" records. To create a replacement thanks to entering, add the name of your subdomain under the host column, and an "@" sign under the "points to" column.
The given "@" is shorthand for the IP address of the domain name that we are providing, which was defined in the Host table in the DNS Zone File. And that's it, basically. Except for a bit of waiting.
It usually takes about an hour for the changes to the Zone File to discover across the Net. make sure and correct that if it has been activated by pinging it to see if you get a response back. In the first, the subdomain has been registered within the zone file. In the second, that subdomain that we gave has not been registered. If you're following along, you would possibly be noticed that once you enter the subdomain.domain.com address into a browser -- once the Zone File has propagated across the web -- the server changes the way of you to the main site's home page. That's a start.
How to change Apache settings?
In effect, you've learned how the planet beat a road to your subdomain, and therefore the remainder of the work cares about fixing the server to field the requests correctly! Now, it's time to configure Apache!
At the command line, open the "apache2.conf" in the /etc/apache2 directory. As the name prefers it is the configuration file for Apache. At the down margin of the apache2.conf file, after the last commented text, "#Include the virtual host configurations" is the place that you need to add your additional configuration instructions that Apache will chase once it is restarted.
A virtual host, defined as Apache in code, allows a single instance of Apache to run different sites. Each site that we are hosting gets its own configuration entry in apache2.conf file. In Apache technical follow-up, create multiple name-based virtual hosts for the same IP number.
Depending on how your page of Apache has been set up you may already see an entry for a virtual host, for the main site for the domain. For example, it'll appear as if this:
NameVirtualHost 188.8.131.52 ServerName www.joabj.com ServerAlias joabj.com DocumentRoot /var/www
where the host IP number (184.108.40.206) is assigned to a specific domain name.
To add a support tool for subdomains, create a VirtualHost entry for each subdomain, using the same IP number. So for technique.joabj.com and fishing.joabj.com, add these entries respectively.
ServerName technique.joabj.com DocumentRoot /var/www/Technique ServerName fishing.joabj.com DocumentRoot /var/www/fishing
In these examples, the Host IP number is the same as the actual site. The name of the server entry indicated the name of the fully qualified address of the subdomain and the DocumentRoot indicated where the root directory for this subdomain exists in the server's own file system.
In effect, you could make a full site for the subdomain, based on the root document directory. Note you would like an index.html within the subdomain's root directory for Apache to display some content when subdomain.domain.com is named.
And, as always, remember to restart your Apache server after making any configurations. In Ubuntu, it is done easily at the command line:
service apache2 restart:
If you have any questions about the above topic or have to get server administration services and solutions, setting up a subdomain in apache2 and for more consulting services. Feel free to contact us. AIR ZERO CLOUD will be your strong digital solution. E-mail id:[email protected]
Author - Johnson Augustine
Cloud Architect , Ethical hacker
Founder: Airo Global Software Inc
LinkedIn Profile: www.linkedin.com/in/johnsontaugustine/