How to create virtual host in Xampp windows 10 - windows

I want to setup virtual host for my local project.
I added this code into C:\xampp\apache\conf\extra\httpd-vhosts.conffile.
<VirtualHost *:80>
DocumentRoot "c:/xampp/htdocs/bab/"
ServerName bab.local
<Directory "c:/xampp/htdocs/bab/">
</Directory>
</VirtualHost>
I added this code into C:\Windows\System32\drivers\etc\hostsfile.
127.0.0.1 bab.local
please help.....

You need to correct your settings like below :- need to define {projectName}
<VirtualHost *:80>
DocumentRoot "c:/xampp/htdocs/bab/{projectName}"
ServerName bab.local
<Directory "c:/xampp/htdocs/bab/">
</Directory>
</VirtualHost>

Related

csrf_token error in virtual host in Ubuntu

My laravel project working fine on 127.0.0.1 but when trying to run on a virtual host I am getting a csrf_token mismatch error.
This is my .conf file code
<VirtualHost *:80>
ServerAdmin admin#server.in
ServerName test.local
ServerAlias test.local
<Directory /var/www/html/test/development/public>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
DocumentRoot /var/www/html/test/development/public/
</VirtualHost>

xampp and virtual hosts not working properly

my virtual host setup looks like this:
<VirtualHost *:8080>
ServerName localhost
DocumentRoot "D:\xampp\htdocs"
<Directory "D:\xampp\htdocs">
DirectoryIndex index.php
</Directory>
</VirtualHost>
<VirtualHost *:8080>
ServerName mysite.site
DocumentRoot "D:\xampp\htdocs\mysite"
SetEnv APPLICATION_ENV "development"
<Directory "D:\xampp\htdocs\mysite\public">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
and the hosts file:
127.0.0.1 localhost
127.0.0.1 mysite.site
but it actually doens't work. I have to go through localhost/mysite/public to make it work. Why? Instead of getting my site it loads my localhost default site which is xampp's htdocs folder.
EDIT:
Just wanted to add that I have Include conf/extra/httpd-vhosts.conf in httpd.conf already.
Ok, i finally got this. Looks like my port was incorrect. I checked what port is used in httpd.conf under ServerName localhost:80. Then I fixed my virtual host setup:
<VirtualHost *:80>
ServerName mysite.site
DocumentRoot "D:/xampp/htdocs/mysite/public"
SetEnv APPLICATION_ENV "development"
<Directory "D:/xampp\htdocs/mysite/public/">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Now it works. :)

My virtual host in xampp isn't working for laravel

i've set my virtual hosts in xampp for laravel
httpd-vhosts.conf file:
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/shareitbaby.io/public"
ServerName www.shareitbaby.io
ServerAlias shareitbaby.io
<Directory "C:/xampp/htdocs/shareitbaby.io/public">
AllowOverride All
Order allow,deny
Allow from all
</Directory>
and my host file:
127.0.0.1 shareitbaby.io
::1 shareitbaby.io
and when i type shareitbaby.io it's not working

403 Forbidden apache mac os

Help set up a virtual host. In the file /etc/apache2/httpd.conf I uncommented this line here:
# Virtual hosts
Include /private/etc/apache2/extra/httpd-vhosts.conf
Next, the file is opened, and in the end ordered a new virtual host:
<VirtualHost *:80>
ServerName localhost
DocumentRoot "/Library/WebServer/Documents/"
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot "/Users/igor/sites/advanced"
ServerName advanced
ErrorLog "/private/var/log/apache2/lab.domain-error_log"
CustomLog "/private/var/log/apache2/lab.domain-access_log" common
<Directory "/Users/igor/sites/advanced/">
Options Indexes MultiViews
AllowOverride All
Allow from all
Require all granted
</Directory>
</VirtualHost>
Then added to the hosts 127.0.0.1 advanced. Restart Apache, but the browser displays a 403 error! What could it be?

Apache gives me 403 Access Forbidden when DocumentRoot points to two different drives

I am getting an 403 access forbidden when attempting to open a page under a vhost where the document root is sitting on a different drive than where apache is sitting. I installed using the apachefriends release. This is my httpd-vhosts.conf file:
NameVirtualHost 127.0.0.1
<VirtualHost 127.0.0.1>
ServerName foo.localhost
DocumentRoot "C:/xampp/htdocs/foo/public"
</VirtualHost>
<VirtualHost 127.0.0.1>
ServerName bar.localhost
DocumentRoot "F:/bar/public"
</VirtualHost>
When opening bar.localhost in my browser, Apache is giving me 403 Access Forbidden. I tried setting lots of different access rights, even full rights to everyone, but nothing I tried helped.
Edit: Thanks! For future reference, add 'Options indexes' within to show directory indexes.
You did not need
Options Indexes FollowSymLinks MultiViews Includes ExecCGI
AllowOverride All
Order Allow,Deny
Allow from all
Require all granted
the only thing what you need is...
Require all granted
...inside the directory section.
See Apache 2.4 upgrading side:
http://httpd.apache.org/docs/2.4/upgrading.html
Somewhere, you need to tell Apache that people are allowed to see contents of this directory.
<Directory "F:/bar/public">
Order Allow,Deny
Allow from All
# Any other directory-specific stuff
</Directory>
More info
For Apache 2.4.2: I was getting 403: Forbidden continuously when I was trying to access WAMP on my Windows 7 desktop from my iPhone on WiFi. On one blog, I found the solution - add Require all granted after Allow all in the <Directory> section. So this is how my <Directory> section looks like inside <VirtualHost>
<Directory "C:/wamp/www">
Options Indexes FollowSymLinks MultiViews Includes ExecCGI
AllowOverride All
Order Allow,Deny
Allow from all
Require all granted
</Directory>
I have fixed it with removing below code from
C:\wamp\bin\apache\apache2.4.9\conf\extra\httpd-vhosts.conf file
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host.example.com
DocumentRoot "c:/Apache24/docs/dummy-host.example.com"
ServerName dummy-host.example.com
ServerAlias www.dummy-host.example.com
ErrorLog "logs/dummy-host.example.com-error.log"
CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host2.example.com
DocumentRoot "c:/Apache24/docs/dummy-host2.example.com"
ServerName dummy-host2.example.com
ErrorLog "logs/dummy-host2.example.com-error.log"
CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>
And added
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot "c:/wamp/www"
ServerName localhost
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" common
</VirtualHost>
And it has worked like charm
Solved 403: Forbidden when visiting localhost. Using ports 80,443,3308 (the later to handle conflict with MySQL Server installation)
Windows 10, XAMPP 7.4.1, Apache 2.4.x My web files are in a separate folder.
httpd.conf - look for these lines and set it up where you have your files, mine is web folder.
DocumentRoot "C:/web"
<Directory "C:/web">
Changed these 2 lines.
<VirtualHost *:80>
ServerAdmin webmaster#localhost.com
DocumentRoot "C:/web/project1"
ServerName project1.localhost
<Directory "C:/web/project1">
Order allow,deny
allow from all
</Directory>
</VirtualHost>
to this
<VirtualHost *:80>
ServerAdmin webmaster#localhost.com
DocumentRoot "C:/web/project1"
ServerName project1.localhost
<Directory "C:/web/project1">
Require all granted
</Directory>
</VirtualHost>
Add your details in your hosts file
C:\Windows\System32\drivers\etc\hosts file
127.0.0.1 localhost
127.0.0.1 project1.localhost
Stop start XAMPP, and click Apache admin (or localhost) and the wonderful XAMPP dashboard now displays! And visit your project at project1.localhost

Resources