To save the index.html file in nano, do the following
Press CTRL +O to write to file, press enter to confirm
Press CTRL +X to exit nano
Next we need to take ownership of the folder and files in the mysite folder.
If you run the ls -l command you will see that root has ownership of the folder and file
ls -l /var/www/mysite
drwxr-xr-x 2 root root 4096 Jun 25 14:03 mysite
Enter the following command to change ownership to your username. Replace username with your real username
sudo chown -R username:username /var/www/mysite/
Run the ls -l command again
ls -l /var/www/mysite
drwxr-xr-x 2 username username 4096 Jun 25 14:03 mysite
Next change the permissions of the folder and file to enable read, write
sudo chmod -R 755 /var/www/mysite/
So that apache2 points to your new mysite folder, we need to copy the 000-default.conf file
The main 000-default.conf file is located in the following directory /etc/apache2/sites-available/ so cd to that directory using the command below
cd /etc/apache2/sites-available/
Copy the 000-default.conf file using the cp command and create a new .conf file named mysite.conf
sudo cp 000-default.conf mysite.conf
Open and edit the mysite.conf file using nano
sudo nano mysite.conf
Locate the line DocumentRoot /var/www/html
Change this to DocumentRoot /var/www/mysite
To save the configuration file in nano, do the following
Press CTRL +O to write to file, press enter to confirm
Press CTRL +X to exit nano
Next we need to enable the mysite.conf file
We first need to disable the 000-default.conf using the ad2dissite command
sudo a2dissite 000-default.conf
Then we need to enable the mysite.conf file using the a2ensite command
sudo a2ensite mysite.conf
Next we need to restart apache2 using the following command
sudo systemctl reload apache2
Enter localhost or 127.0.0.1 in the address of your webrowser. You will now see your Apache holding page.