Question
How to link subdomain to my droplet (step-by-step)
How to create sub domains:
(with Droplet setting up)
1) cd /var/www/
2) mkdir subdomain
- let’s create the subdomain folder
3) chmod -R 775 subdomain
- giving permission on the folder
4) cd subdomain
5) sudo nano index.php
(inside the file)
<? php
echo ‘subdomain test’;
?>
(control X to save)
- creating an index file to test the subdomain
6) in NETWORKING create A entries for subdomain = subdomain> droplet> 3600
7) in NETWORKING create CNAME entries for subdomain = www.subdomain> subdomain.dominium> 43200
8) cd ~
- to go to root directory
9) cd /etc/apache2/sites-available/
10) type: “cp 000-default.conf subdomain.domain.conf”
- this command copies the default configuration file to one with the subdomain name (required)
11) type: sudo nano subdomain.domain.conf
- edit the copied file
12) Within the copied file, change:
12.1 = remove “#” from ServerName and leave as: “ServerName subdomain.dominium”
12.2 = enter ServerAlias: “ServerAlias www.subdomain.domain”
12.3 = change “DocumentRoot” to: “DocummentRoot / var / www / subdomain”
(control X to save - confirm by pressing Y and then enter the filename subdomain.dominio.conf)
13) type: “sudo a2ensite subdomain.domain.conf”
14) Restart server to terminate = “sudo service apache2 restart”
READY! Now access the subdomain link and see the message from the PHP file from step 5.
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×