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:
conf\httpd.conf global configuration file (which section)?
Or maybe somewhere else?
My experience of virtual host is only “experimental”.
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
Create the file(s) in /etc/apache2/vhosts.d
Will be included in /etc/apache2/httpd.conf
Something like that, I may have forgotten some step(s).
Thank you for sharing this info.
I believe that under XAMPP for Windows paths will be similar. Can’t find any similarity to
/etc/apache2/vhosts.d seems somewhat similar to
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
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!
I only have experience with *Nix systems, zero on Windows. But basically this is what you do:
- Define *.conf file in sites-available folder
- Make your subdomain pointing to specific subfolder in your www folder
- Enable site a2ensite
- Reload/Restart your Apache server
If you need specific help in any of the stages let me know