'Access correct website file from apache web server [closed]

I am running an apache web server on my Raspberry Pi that hosts a website. To get the IP address of the server i used ifconfig and looked for the inet address under wlan0. I typed this address into chromium and reached /var/www/html/index.html. I do not want to reach this file, instead i was hoping to configure the server so that the first site i reach is /var/www/test/index.php.

How can i achieve this?



Solution 1:[1]

If you only have one webpage running on the Pi, you need to change the document root of the apache.

A better solution is, to use virtual hosts with apache. Depending on the OS on the Pi there may be different paths for the Apache config files. I only know it for Debian (Raspbian).

Then you have to enable the virtual host (a2ensite <configfile.conf>) and reload or restart Apache.

If you are running a local Nameserver (like PiHole), you have to add the correct DNS entry for this virtual host. Or if you don't have a local DNS you have to edit the /etc/hosts files on all machines you want to have access to this website. (There is also a hosts file on windows (i think it is in \Windows\System32\drivers\etc)

Thats it :-)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Eugen Spinne