Since I am total newbie to the Apache’s idea of VirtualHosts, in the Yii 2 Guide, section Preparing application, point “4. Set document roots of your web server:” I am totally missing the information where to put this example configuration file that defines an new virtual host?
Should I put it in:
Apache’s conf\httpd.conf global configuration file (which section)?
The apache\conf\extra\httpd-vhosts.conf file?
The htdocs\.htaccess file?
The path\to\yii-application\frontend\web\.htaccess file?
My experience of virtual host is only “experimental”.
In Ubuntu:
Create a file (somename.conf) for each vhost in /etc/apache2/sites_available
Use a2ensite to enable
Will be included in /etc/apache2/apache.conf
IncludeOptional sites-enabled/*.conf
In Opensuse:
Create the file(s) in /etc/apache2/vhosts.d
Will be included in /etc/apache2/httpd.conf
IncludeOptional /etc/apache2/vhosts.d/*.conf
Something like that, I may have forgotten some step(s).
I believe that under XAMPP for Windows paths will be similar. Can’t find any similarity to /etc/apache2/sites_available, but /etc/apache2/vhosts.d seems somewhat similar to C:\xampp\apache\conf\extra\httpd-vhosts.conf.
Three questions, if you experience allows answering them:
I understand that using vhost configuration file is a must and I cannot have virtual hosts configuration stored in .htaccess file in some folder, right?
Do you know, if using virtual hosts I can define domain-only solution or I can include also some (none existing) path to folder? I.e. Can I have frontend.test/platform or am I limited to frontend.test only?
Can I / should I use virtual hosts to define existing domains and subdomains or is this solution limited to non-existing (virtual?) domains only, i.e. those that also requires addition to hosts file on client machine, as the guide says.
I.e. I have a domain test.lab.example.com that points to my Apache installation. Can I use virtual hosts to point this domain locally to some folder? I.e. projects\test\lab\frontend\web\? Or I should achieve this in some other way, as virtual hosts are not meant to be used this way? Thanks!