I wanna know how add two projects on zf2 in htdocs.
I have in my /opt/lampp/etc/extra/httpd-vhosts.config this:
<VirtualHost *:80>
DocumentRoot /opt/lampp/htdocs/test1
ServerName test1
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /opt/lampp/htdocs/test2
ServerName test2
</VirtualHost>
and in my hosts file i have:
127.0.0.1 test1.com
127.0.0.1 test2.com
Tanks for reply.
You should really work on the quality of your question. You used completely wrong tags, this question is not at all related to zend-framework2 and projects. I removed those tags and added some other more relevant ones. I assumed you are using apache on windows. If wrong please change it according to your specs. I also changed the title so people with similar issues can actually find your question.
To answer your question:
I would suggest leaving the .com away and then do it like this:
<VirtualHost test1:80>
DocumentRoot /opt/lampp/htdocs/test1
ServerName test1
</VirtualHost>
<VirtualHost test2:80>
DocumentRoot /opt/lampp/htdocs/test2
ServerName test2
</VirtualHost>
so domain_name:80
and then in your hosts:
127.0.0.1 test1
127.0.0.1 test2
Related
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
Currently typing "localhost" into my browser displays a list of projects, all good... I can even do "localhost/mysite" however and I know this is slightly pedantic, but how can I convert this to "localhost.mysite" or for example "projects.local"?
I've attempted editing the hosts files but I'm not having much luck.
httpd.vhosts.conf file contents:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /Applications/MAMP/htdocs
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot “/Users/grant/Sites/mysite/"
ServerName mydomainname.dev
</VirtualHost>
Thanks in advance.
<VirtualHost *.laravel:80>
DocumentRoot "z:\wamp\www\laravel\%1\public"
ServerName %1.laravel
</VirtualHost>
This does not work. What I'm trying to do here is have the documentroot of http://*.laravel/ be z:\wamp\www\laravel\(wildcard * value here)\public
I don't know how to get the value of the wildcard. My windows hosts file is setup correctly to point to localhost
You are looking to use VitualDocumentRoot instead of DocumentRoot
http://httpd.apache.org/docs/2.2/mod/mod_vhost_alias.html#virtualdocumentroot
Also, ServerName is always static (all your dynamic DocumentRoots will have the same exact ServerName). It's one of the problems with dynamic VHs.
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.