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
Related
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.
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
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
I'm facing below issue while use XAMPP in windows. Same working if I connect with VPN.
Unknown Host
Description: Unable to locate the server named "d8.kali" --- the server does not have a DNS entry. Perhaps there is a misspelling in the server name, or the server no longer exists. Double-check the name and try again.
C:\Windows\System32\drivers\etc: hosts
127.0.0.1 localhost
127.0.0.1 d8.kali
C:\xampp\apache\conf\extra: httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/drupal-8"
ServerName d8.kali
ErrorLog "logs/d8.kali-error.log"
CustomLog "logs/d8.kali-access.log" common
</VirtualHost>
Edit:
I have this setup in my local system.
As per below comment, used IP. Even not working.
127.0.0.1 localhost
#.#.#.#(IP) d8.kali
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.