You can reach this IP address 2.186.116.46 (if my computer is online). I want to assign a domain to it so I wonder how is that possible when I have no DNS? I do own my domain which is ".com". My IP is static.
Thanks
You can reach this IP address 2.186.116.46 (if my computer is online). I want to assign a domain to it so I wonder how is that possible when I have no DNS? I do own my domain which is ".com". My IP is static.
Thanks
1. You need to acquire a domain name (or maybe just FQDN) from some DNS provider.
2. Once you have registered the domain name, you will gain access to an administrative panel (like this one shown below), where you will be able (via A records), to redirect the domain name (and all *.
or certain sub domains / FQDNs) to your server's IP address.
Please note that the provider's administrative panel shall looks different, and the provider will give you exact instructions how to use it.
Sometimes the redirection can take up-to 24 hours. You can check if it's successful by the command whois example.com
.
If the server is behind NAT, you must setup port forwarding.
3. Edit your Virtual Host configuration file and add relevant ServerName
and maybe ServerAlias
directives. Let's assume the configuration file is 000-default.conf
that should look as this:
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com localhost
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
<Directory /var/www/html>
# etc ...
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
This step can be omitted, but it is absolutely necessary when you have more than one Virtual Hosts.
Don't forgot to:
sudo a2ensite 000-default.conf
sudo systemctl reload apache2.service
4. In addition for local needs:
You can bind a FQDN to the loopback interface of the server. For this purpose, edit the file /etc/hosts
in a way like this:
127.0.0.1 localhost example.com www.example.com
It is not possible to enter *.example.com
here. You can add an entry also for the IP address of another (local) server's network interface - for example 77.77.77.70
.
If you want to access the FQDN by another computer through the LAN (or by a private computer through Internet), edit its host
file in a way like this:
77.77.77.70 example.com www.example.com
Further reading:
If it is for just local use, you can just put that entry into your hosts file.
On modern Windows, that is usually c:\Windows\System32\Drivers\etc\hosts
.
On Linux, the file is /etc/hosts
.
For the rest of the world, use one of the freely available DNS providers.
Here is an example, with instructions: FreeDNS
ServerName
directive into your/etc/apache2/sites-available/your-virtualhost.conf
file.