If you're reading my question, thanks, I appreciate your help
I'm using Wamp on Windows Vista.
I've created 2 project folders:
www/project1/
www/project2/
My virtual hosts file looks like this:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "C:/wamp/www/project1/"
ServerName project1.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/wamp/www/project2/"
ServerName project2.com
</VirtualHost>
Can someone advise how I can go about doing this?
You need to specify ServerName in VirtualHost like this (and additionally ServerAlias) for each hostname:
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host2.localhost
DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/docs/dummy-host1.localhost"
ServerAlias *.first.com first.com
ServerName www.first.com
ErrorLog "logs/dummy-host1.localhost-error.log"
CustomLog "logs/dummy-host1.localhost-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host2.localhost
DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/docs/dummy-host2.localhost"
ServerAlias *.second.com second.com
ServerName www.second.com
ErrorLog "logs/dummy-host2.localhost-error.log"
CustomLog "logs/dummy-host2.localhost-access.log" common
</VirtualHost>
Here is a full tutorial, hope it helps. Let me know if you run into any problems.
http://kintek.com.au/blog/configuring-multiple-domains-within-wamp-for-local-development/
Related
I am trying to setup the zend skeleton application in my Windows 10 machine. However, since port 80 was not available, I am trying to configure on port 8080. But every time I do not get the zend skeleton page. I only get the apache page that says "It works". Pls suggest what I am doing wrong.
In apache httpd.conf, I made below changes:
Listen 8080
ServerName localhost:8080
In httpd-vhosts.conf:
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host.example.com
DocumentRoot "${SRVROOT}/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 "${SRVROOT}/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>
<VirtualHost *:8080>
ServerName zendskeleton.localhost
DocumentRoot C:/zendskeleton/public
SetEnv APPLICATION_ENV "development"
<Directory C:/zendskeleton/public>
DirectoryIndex index.php
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
In Windows hosts file:
127.0.0.1 zendskeleton.localhost localhost
I (running on a macbook pro Yosemite 10.10.5) have a hosts file which consists of the following:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot “/Users/samir/Sites/theblog/”
ServerName theblog.dev
ServerAlias www.theblog.dev
ErrorLog "/usr/local/var/log/apache2/dummy-host2.example.com-error_log"
CustomLog "/usr/local/var/log/apache2/dummy-host2.example.com-access_log" common
</VirtualHost>
and for the folder at /Users/samir/Sites/theblog/, I want to be able to access it from going to http://theblog.dev, but right now the only way to access /theblog is if I copied and pasted it at /Library/WebServer/Documents, how do I change the location to Users/samir/Sites? And how do I make the url's work?
I am using laravel 5 by the way.
Thank you in advance!
I am considering you are working with Laravel application.
Try with below:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot “/Users/samir/Sites/theblog/public”
<Directory /Users/samir/Sites/theblog/public/>
Allow from all
</Directory>
ServerName theblog.dev
ServerAlias www.theblog.dev
ErrorLog "/usr/local/var/log/apache2/dummy-host2.example.com-error_log"
CustomLog "/usr/local/var/log/apache2/dummy-host2.example.com-access_log" common
</VirtualHost>
I'm trying to enable multiple domains in my environment Development, but am not succeeding the way I tried below, at which point I'm wrong?
I installed httpd and changed DocumentRoot in httpd.conf to:
C:/Webserver/www
*I changed the Windows hosts file to(in Italics would like to access):
If I switch to 127.0.0.1 api.rotadorock the address resolves to www/ but the right is www/rotadorock/api.
127.0.0.1 localhost
127.0.0.1 webserver
127.0.0.1/rotadorock/ecommerce rotadorock
127.0.0.1/rotadorock/api api.rotadorock
127.0.0.1/rotadorock/ecommerce ecommerce.rotadorock
127.0.0.1/rotadorock/mobile mobile.rotadorock
127.0.0.1/rotadorock/sistema sistema.rotadorock
127.0.0.1/rotadorock/social social.rotadorock
*Update(windows hosts file)
I removed the hosts file changes I mentioned above, because as #Volker Birk said are not necessary. But even so, still can not access as desire (api.rotadorock/ or localhost/api.rotadorock/ and should point to C:/Webserver/www/rotadorock/api). What could be wrong?
And finally changed httpd-vhost.conf for:
NameVirtualHost webserver:80
<Directory "C:/Webserver/www">
Options All
AllowOverride All
Order allow,deny
Allow from all
</Directory>
<VirtualHost *:80>
ServerName localhost
DocumentRoot "c:/Webserver/www"
ServerAlias localhost
ErrorLog "logs/httpd-error.log"
CustomLog "logs/httpd-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerName webserver
DocumentRoot "c:/Webserver/www"
ServerAlias webserver
ErrorLog "logs/httpd-error.log"
CustomLog "logs/httpd-access.log" common
</VirtualHost>
<VirtualHost rotadorock:80>
ServerName rotadorock
DocumentRoot "c:/Webserver/www/rotadorock/ecommerce"
ServerAlias rotadorock
ErrorLog "logs/httpd-error.log"
CustomLog "logs/httpd-access.log" common
</VirtualHost>
<VirtualHost api.rotadorock:80>
ServerName api.rotadorock
DocumentRoot "c:/Webserver/www/rotadorock/api"
ServerAlias api.rotadorock
ErrorLog "logs/httpd-error.log"
CustomLog "logs/httpd-access.log" common
</VirtualHost>
<VirtualHost ecommerce.rotadorock:80>
ServerName ecommerce.rotadorock
DocumentRoot "c:/Webserver/www/rotadorock/ecommerce"
ServerAlias ecommerce.rotadorock
ErrorLog "logs/httpd-error.log"
CustomLog "logs/httpd-access.log" common
</VirtualHost>
<VirtualHost mobile.rotadorock:80>
ServerName mobile.rotadorock
DocumentRoot "c:/Webserver/www/rotadorock/mobile"
ServerAlias mobile.rotadorock
ErrorLog "logs/httpd-error.log"
CustomLog "logs/httpd-access.log" common
</VirtualHost>
<VirtualHost sistema.rotadorock:80>
ServerName sistema.rotadorock
DocumentRoot "c:/Webserver/www/rotadorock/sistema"
ServerAlias sistema.rotadorock
ErrorLog "logs/httpd-error.log"
CustomLog "logs/httpd-access.log" common
</VirtualHost>
<VirtualHost social.rotadorock:80>
ServerName social.rotadorock
DocumentRoot "c:/Webserver/www/rotadorock/social"
ServerAlias social.rotadorock
ErrorLog "logs/httpd-error.log"
CustomLog "logs/httpd-access.log" common
</VirtualHost>
You don't need the hosts file. Have a look into the documentation:
http://httpd.apache.org/docs/2.2/en/vhosts/name-based.html
Finally solved the problem. And I could just using the Windows hosts file and httpd-vhosts.conf httpd together.
Let me give an example of what was done to enable multiple subdomains accessing locally.
On Windows hosts file to add, for each domain and subdomain you want something like this:
127.0.0.1 api.rotadorock #my subdomain
127.0.0.1 rotadorock #my domain
And then the httpd-vhosts apache httpd:
# Accessing the API
<VirtualHost 127.0.0.1>
DocumentRoot "C:/Webserver/www/rotadorock/api"
ServerName api.rotadorock
ServerAlias api.rotadorock
<Directory "C:/Webserver/www/rotadorock/api">
All Options Includes Indexes
</ Directory>
</VirtualHost>
# Accessing the domain
<VirtualHost 127.0.0.1>
DocumentRoot "C:/Webserver/www/rotadorock/"
ServerName rotadorock
ServerAlias *.rotadorock
<Directory "C:/Webserver/www/rotadorock/">
All Options Includes Indexes
</Directory>
</VirtualHost>
And then that way I could access api.rotadorock/ and rotadorock/ locally. I tried all ways without the hosts file. But just gotta use it. If someone can explain to me how it should have done so it would not need to use the hosts I would be grateful.
I've got a site set up on localhost that I'm actively developing, and I'd like to set up a subdomain on localhost to make my life 10* easier.
I added this to C:\xampp\apache\conf\extra\httpd-vhosts.conf:
<VirtualHost i1.localhost:80>
ServerAdmin dummy#localhost
DocumentRoot "C:/xampp/htdocs/i1/"
ServerName i1.localhost
ServerAlias www.i1.localhost
ErrorLog "logs/dummy-host2.localhost-error.log"
CustomLog "logs/dummy-host2.localhost-access.log" combined
</VirtualHost>
Apache stats up fine, but when I navigate to http://localhost/ I'm seeing content from the i1 subdomain. http://i1.localhost/ works fine, however.
Then I tried doing this:
<VirtualHost localhost:80>
ServerAdmin dummy#localhost
DocumentRoot "C:/xampp/htdocs/"
ServerName localhost
ServerAlias www.localhost
ErrorLog "logs/dummy-host2.localhost-error.log"
CustomLog "logs/dummy-host2.localhost-access.log" combined
</VirtualHost>
<VirtualHost i1.localhost:80>
ServerAdmin dummy#localhost
DocumentRoot "C:/xampp/htdocs/i1/"
ServerName i1.localhost
ServerAlias www.i1.localhost
ErrorLog "logs/dummy-host2.localhost-error.log"
CustomLog "logs/dummy-host2.localhost-access.log" combined
</VirtualHost>
But that worked the opposite. On both localhost and i1.localhost I'm seeing content from C:/xampp/htdocs/.
Anyone got an idea what's going wrong?
Cheers.
Apache usually does not like a vhosts document root inside another vhost, try:
DocumentRoot "C:/xampp/htdocs/"
and
DocumentRoot "C:/xampp/i1/"
I need to have two VirtualHosts with the same listen port for different projects and with different logs. Here's what I've got:
<VirtualHost *:80>
DocumentRoot /home/projects/smk
ErrorLog /var/log/apache2/smk-error.log
RedirectMatch ^/$ /cms
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /home/projects/smk/cms
ErrorLog /var/log/apache2/smk-cms-error.log
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /home/projects/smk/deploy
ErrorLog /var/log/apache2/smk-deploy-error.log
</VirtualHost>
Add different ServerName directive in all virtual hosts:
<VirtualHost *:80>
ServerName dev.localhost
DocumentRoot /home/projects/smk/cms
ErrorLog /var/log/apache2/smk-cms-error.log
</VirtualHost>
<VirtualHost *:80>
ServerName my-project.localhost
DocumentRoot /home/projects/smk/deploy
ErrorLog /var/log/apache2/smk-deploy-error.log
</VirtualHost>
Don't forget to add host-entries for dev.localhost and my-project.localhost in /etc/hosts to 127.0.0.1 or whatever ip you want it to point to.
ServerName my-project.localhost
DocumentRoot /home/projects/smk/deploy
ErrorLog /var/log/apache2/smk-deploy-error.log
//Try adding Error document
ErrorDocument 404 404.html
There is a need to create a feedback in your application.