Here Iam doing this by changing document root of Apache on Ubuntu.
STEP 1 – Change document root of Apache on Ubuntu
Create the www directory at /home/user/www. Open Terminal and enter
mkdir www
Set document root in apache2.conf file
sudo nano /etc/apache2/apache2.conf
and look for the following
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
and change the directory to /home/user/www/
Save the file by pressing CTRL+X, then Y and ENTER.
Next step is change the path in 000-default.conf file
sudo nano /etc/apache2/sites-available
Change DocumentRoot /var/www/html to /home/user/www
Save the file by pressing CTRL+X, then Y and ENTER.
STEP 2. Set Up Apache Virtual Hosts on Ubuntu 20.04
On this step, we can create our test site folder. Here Iam creating a folder flashwebost.
sudo mkdir /home/user/www/flashwebhost
Need to change the permissions current non-root user and that read access is permitted to the general web directory and all of the files and folders.
sudo chown -R $USER:$USER /home/user/www/flashwebhost
sudo chmod -R 755 /home/user/www
Then we meed to create new virtual host file by copying the content of /etc/apache2/sites-available/000-default.conf
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/flashwebhost.conf
Edit flashwebhost.conf
sudo nano /etc/apache2/sites-available/flashwebhost.conf
and modify the file
<VirtualHost *:80>
ServerName flashwebhost.test
DocumentRoot /home/user/www/flashwebhost
<Directory "/home/user/www/flashwebhost">
Options All -Indexes
AllowOverride All
Require all granted
Order allow,deny
allow from all
</Directory>
</VirtualHost>
To enable the new virtual host file, run
sudo a2ensite flashwebhost.conf
STEP 3. Setup Host File
sudo nano /etc/hosts
and the following
127.0.0.1 flashwebhost.test www.flashwebhost.test
Restart Apache
sudo systemctl restart apache2
STEP 4. Test site
Create a index.html file and upload to flashwebhost folder and check the site http://flashwebhost.test