Creating subdomains in Xampp server windows - xampp

I am trying to create sub-domains on my localhost to be accessed concurrently by my team but only the first project is loaded even when the url for the second domain is typed in the browser.
So far I have tried changing the httpd-vhosts.conf file
<VirtualHost *:80>
ServerAdmin webmaster#smartsacco.localhost.com
DocumentRoot "C:/xampp/htdocs/smartsacco/public"
ServerName smartsacco.localhost.com
ErrorLog "logs/smartsacco.localhost.com-error.log"
CustomLog "logs/smartsacco.localhost.com-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#mfarmer.localhost.com
DocumentRoot "C:/xampp/htdocs/Mfarmer/public"
ServerName mfarmer.localhost.com
ErrorLog "logs/mfarmer.localhost.com-error.log"
CustomLog "logs/mfarmer.localhost.com-access.log" common
</VirtualHost>
And also modified the hosts file
127.0.0.1 localhost
::1 localhost
127.0.0.1 smartsacco.localhost.com
127.0.0.1 mfarmer.localhost.com
Saddly only the contents of smartsacco.localhost.com is loaded even when I type mfarmer.localhost.com. What could Be wrong or and what can I do to have them both working?

Since your code is correct, I suggest you restart Apache server and maybe the entire computer

Related

Laravel Setup Issue even after setting up Virtual Host and its all dependencies

I have installed Laravel Project with all its dependencies. Also, Setup Virtual Hosts for the same. But, When I hit the url like say "dev.laravelProject.com" it immediately opening Xampp Dashboard.
I don't know why is that happened.
Any Help Appreciated
First, change your /etc/hosts file to have a mapping of your desired website name(s) (www.example.com), and target IP address (127.0.0.1). I used my local IP address.
IPAddress Hostname Alias
----------- -------------------------- ------------------
127.0.0.1 www.librarymodule.com librarymodule.com
127.0.0.1 www.dev.librarymodule.com dev.librarymodule.com
So, you can set only one domain
<VirtualHost *:80>
DocumentRoot "/var/www/html/LibraryProject/public"
ServerName librarymodule.com
ServerAlias *.librarymodule.com
<Directory "/var/www/html/LibraryProject/public">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
or add first the main one and then the subdomain:
<VirtualHost *:80>
DocumentRoot "/var/www/html/LibraryProject/public"
ServerName www.librarymodule.com
ServerAlias librarymodule.com
</VirtualHost>
<VirtualHost *:80>
ServerName www.dev.librarymodule.com
ServerAlias dev.librarymodule.com
DocumentRoot "/var/www/html/LibraryProject/public"
</VirtualHost>
As a final step, you may need to add the websites to Apache by issuing the below commands:
# a2ensite librarymodule.com
# a2ensite dev.librarymodule.com
- Reload apache.

localhost/ going to laravel project

I am new to Laravel and while creating a new project, I wanted it to be named in Virtual Host. By this way,
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/logo/public"
ServerName logo.local
</VirtualHost>
I named it, defined IP address for it (127.0.0.1) in HOSTS file but now, when I write localhost/ in the address bar, instead of going to Xampp("Welcome to XAMPP"), it goes to my laravel project. I know that if I will define my localhost the same way, like
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/"
ServerName localhost
</VirtualHost>
the problem will be solved but I don't know the reason of doing this. Why do I need to name C:/xampp/htdocs/ as localhost, if it was default before my laravel project?
if i get your meanings correct, you need add a default virtual host before other virtual host, so in your case, should be like this,
add the code block to end of the httpd.conf
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/logo/public"
ServerName logo.local
</VirtualHost>
and edit hosts file to
127.0.0.1 localhost
127.0.0.1 logo.local

How to setup virtual host in zend apache2.4 and window 7?

I am setting virtual host in my local but not success. pls help me check.
Server local info.
Zend apache2.4
system: window 7.
my config:
the content of file httpd.conf:
....
include extra/httpd-vhost.conf
....
file httpd-vhost.conf:
<VirtualHost *:80>
ServerAdmin girl.test
DocumentRoot "C:\localhost\source"
ServerName girl.test
ServerAlias www.girl.test
ErrorLog "logs\girl-error.log"
CustomLog "logs\girl-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin boy.test
DocumentRoot "C:\localhost\source"
ServerName boy.test
ErrorLog "logs\boy-error.log"
CustomLog "logs\boy-access.log" common
</VirtualHost>
File: etc/hosts I add two line
127.0.0.1/source girl.test
127.0.0.1/source boy.test
After I restart service and go to:
girl.test get message
This site can’t be reached girl.test’s server IP address could not be
found.
127.0.0.1/source is work.
pls help me check, Many thanks.
I have fixed this issue when change file etc/hosts to 127.0.0.1 girl.test 127.0.0.1 boy.test

Setting up virtual hosts on El Capitan

What I've done is:
Added this to httpd-vhosts.conf:
<VirtualHost *:80>
DocumentRoot "/Library/WebServer/Documents/site1"
ServerName site1.loc
ServerAlias www.site1.loc
ErrorLog "/private/var/log/apache2/dummy-host.example.com-error_log"
CustomLog "/private/var/log/apache2/dummy-host.example.com-access_log" common
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Library/WebServer/Documents/site2"
ServerName site2.loc
ServerAlias www.site2.loc
ErrorLog "/private/var/log/apache2/dummy-host.example.com-error_log"
CustomLog "/private/var/log/apache2/dummy-host.example.com-access_log" common
</VirtualHost>
<VirtualHost *:80>
ServerName localhost
DocumentRoot /Library/WebServer/Documents/
</VirtualHost>
And in hosts file, I added this:
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
127.0.0.1 site1.localhost
127.0.0.1 site2.localhost
And finally in httpd.conf I uncommented this line:
# Virtual hosts
Include /private/etc/apache2/extra/httpd-vhosts.conf
I have restarted apache after this and after I have tried to run something like this:
http://site1/index.html
or http://site2 I get an error which saying:
This site can’t be reached
I am missing something very obvious? It was a long time I did this on Windows, so I guess I made some silly mistake. Also I get :
You don't have permission to access / on this server.
when I try to reach localhost.
Actually it worked after I have changed these:
127.0.0.1 site1.localhost
127.0.0.1 site2.localhost
to this:
127.0.0.1 site1.loc
127.0.0.1 site2.loc

need help with xampp virtual host

I am using XAMPP, Apache 2.2.17. I have added virtual host but my virtual host and localhost both point to the same location. Here is my code in httpd-vhosts.conf
<VirtualHost www.domain.tld:80>
ServerName www.domain.tld
ServerAlias domain.tld *.domain.tld
DocumentRoot "C:/xampp/htdocs/workspace/testsite"
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/xampp"
ServerAlias localhost
ServerName localhost
</VirtualHost>
With the above code, I get testsite with www.domain.tld so that is good. But If i type localhost, it will go to testsite as well. If I move ahead of test site then localhost goes to localhost good and www.domain.tld goes to localhost too. I tried different setting for localhost as like
<VirtualHost *>
<VirtualHost localhost:80>
and removing *.domain.tld from domain.tld but nothing works. Am I missing something obvious?
My own answer: The following code fixed the problem
<VirtualHost *:80> <--- * fixed the problem, apache 2.2 doc does say it must match www.domain.tld, which caused problem for other Virtual hosts
ServerName www.domain.tld
ServerAlias domain.tld
DocumentRoot "C:/xampp/htdocs/workspace/patriot2"
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/xampp"
ServerAlias localhost
ServerName localhost
</VirtualHost>
please change your ServerName from virtualhost to a local IP address such as 127.0.0.2.
ServerName domain.tld is an example of using "domain.com" where .tld is replaced by .com for your domain.

Resources