-
Notifications
You must be signed in to change notification settings - Fork 2
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.confas 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](bla bla) file into the
edu/directory - Restart apache2
sudo systemctl restart apache2