In most Apache installations, the default root directory is typically located at
/var/www/html on Linux systems. This means that the
index.html file should be placed in the
/var/www/html directory for it to be served as the default file when accessing the web server.
When you develop something in your apache2 server that time this
var/www/html directory might not be suitable for you. So if you can alias your directory where you want to develop or write your program it will help you develop your program.
First, check that is your apache2 server active or not using
service apache2 status. If apache2 server is stopped then activate apache2 server using this command
service apache2 start
apache2.conf file in your vs code editor using this command -
Hope, you will find this code below -
<Directory /var/www/> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory>
Bellow this code add your code which alias your custom directory location.
Alias /yoursite /yourDirectory <Directory /yourDirectory> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory>
For better understanding, I share my settings. Hope you will understand now.
Alias /local-wp /home/sajiudr/all-wp <Directory /home/sajidur/all-wp> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory>
Now, restart your apache2 server using this command
service apache2 restart. Then check apache2 server status
service apache2 status.
If you create a file
yourDirectory you can show this in your browser to hit this link
Hope you will understand. If you face any problem please comment bellow my post.
Happy coding, fellow Devs! Until next time, bye and keep building amazing things!