-
Notifications
You must be signed in to change notification settings - Fork 1
U. Setting up a subdomain
This chapter is not long delayed although it comes after a huge break, as all my other chapters, it comes from a need - the need for education and difficulty in finding the right resources online.
Funny enough this is also very simple if you know the right steps.
Prerequisites:
-
ubuntu server
-
apache2 webserver
-
godaddy account for the dns
We want to create a subdomain that points to a subdirectory of our webserver. We do not want to create a subdomain that points to a different IP, but if we wanted that we would have changed only the DNS settings.
- We will create the subdomain directory first.
Go to /var/www/html
and create a subdirectory : mkdir education
- a. We will modify the config file:
/etc/apache2/sites-enabled/000-domain.io.conf
!! please be very careful when changing the settings. I suggest also creating a backup file
- b. Backup old file
cp /etc/apache2/sites-enabled/000-domain.io.conf /etc/apache2/sites-enabled/000-domain_BK.conf
- c. Update config by adding the subdomain first
vi /etc/apache2/sites-enabled/000-domain.io.conf
as per below:
<VirtualHost *:80>
ServerName edu.berrynews.org
DocumentRoot /var/www/html/edu
<Directory /var/www/html/edu>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.edu.log
CustomLog ${APACHE_LOG_DIR}/access.edu.log combined
</VirtualHost>
<VirtualHost *:80>
ServerName berrynews.org
DocumentRoot /var/www/html/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
-
Copy the index.html file into the
edu/
directory -
Restart apache2
sudo systemctl restart apache2
Server side config is done. Now moving to GoDaddy config.
I always have problems navigating into their website and it takes me at least 15 minutes to figure out where I made the changes; so this is me writing everything down.
- Log into GoDaddy In the top right corner, click on the dropdown arrow and choose "My Products"
- Manage DNS In your product page, click on the 3 dots for the product you want to add the subdomain
-
Add the subdomain
Click on ADD;
Name: edu (_exact name as subdirectory config_)
Value: berrynews.org (_exact name of your domain_)
Now all that's left is to wait, they say at most 48H to fully replicate (believe them!)
**Congrats, you're done!**
We have learned how to set up a subdomain that is pointing to the same IP as the original domain's IP.
We have also learned that this must be done in apache as well as in your DNS provider's page, and we must restart apache, always!
If you hit a problem or have feedback (which is highly welcomed) please feel free to get in touch, more details in the footer.