Monday, August 29, 2022

[SOLVED] Apache Virtual Host Configuration

Issue

I am using Apache 2.4 on Raspbian and I want to create a virtual host to serve files on my external hard drive on my website. I searched it on the internet and found many guides to make it but this seemed the simplest: http://www.thegeekstuff.com/2011/07/apache-virtual-host/

However, the files "httpd.conf" and "httpd-vhost.conf" which are mentioned in the guide do not exist in my system (I searched the whole system). Therefore I can't configure those files and hence, my virtual host. When I was searching the information about location of https.conf on the internet, I learnt that it does not exist anymore. However, I couldn't find the information about what to do in this situation.

I have been searching it online for hours but I couldn't find the answer. I do not know how to set up my virtual host. I would greatly appreciate your help.


Solution

Debian derivatives keep their config files in /etc/apache2/

To create a new virtual host, create a new config file in /etc/apache2/sites-available/. You can use 000-default.conf as a template (but you'll need to add ServerName directives as you'll be creating a specific default host rather than the fallback).

Then run a2ensite YOUR-CONFIG.conf to turn it on, and service apache2 restart to restart the HTTP server so it picks up the new configuration.



Answered By - Quentin
Answer Checked By - Clifford M. (WPSolving Volunteer)