I have installed wamp on C:/wamp64/ folder
I have created a virtual host called sampleapp.dev. But when I access it It says "This site can’t be reached".
my httpd-vhosts file
# Virtual Hosts
#
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName sampleapp.dev
DocumentRoot "C:/wamp64/www/sampleapp/public"
</VirtualHost>
my hosts file
127.0.0.1 localhost
::1 localhost
127.0.0.1 sampleapp.dev
::1 sampleapp.dev
What I am doing wrong?
<VirtualHost *:80>
ServerName sampleapp.dev
ServerAlias sampleapp.dev
DocumentRoot "C:/wamp64/www/sampleapp/public"
</VirtualHost>
<Directory "C:/wamp64/www/sampleapp/public">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
my setting
it's working
As you can see from the Definition of the localhost Virtual Host, you need more than just the name of the VH defined, you also have to tell Apache who is allowed to access your new Virtual Host.
The <Directory...> block tell Apache this, specifically the Require local piece, but the other parameters also tell Apache useful information about whats allowed to be done in this new VH.
Try the below amendment.
I have changed sampleapp.dev to sampleapp.test. This is because if you ever use the Chrome browser, the .dev tLD does some odd things now. Google bought the .dev tLD and Chrome now will try and enforce the use of SSL (https) on all .dev tLD's. Simple solution it to just use something else like .local or .test
# Virtual Hosts
#
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName sampleapp.test
ServerAlias www.sampleapp.test
DocumentRoot "${INSTALL_DIR}/www/sampleapp/public"
<Directory "${INSTALL_DIR}/www/sampleapp/public/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
As I use .test instead of .dev yo will also have to change your HOSTS file accordingly, and then reboot or refresh your dnscache like this from a command window started using "Run as Administrator".
Also avoid using Require all granted unless you actually want to allow the universe into your server. If your router blocks port 80, which they do by default nothing can actually get into your WAMPServer. But the second you decide you want to show a friend your nice new site and Port Forward port 80 to your WAMPServer PC, all sites that use Require all granted will become visible. Best to make that change only on the site you really want to be visible from the internet.
>net stop dnscache
>net start dnscahce
I am trying to set up the virtual host for my app written in Codeignitor. Here is what I am doing
In my config.php file in codeignitor I do this
$config['base_url'] = 'http://app.com';
Then in my hosts file I do this
127.0.0.1 www.myapp.com
127.0.0.1 api.myapp.com
127.0.0.1 files.myapp.com
Then in my vhosts file I add this code
NameVirtualHost 127.0.0.1
<VirtualHost 127.0.0.1>
DocumentRoot "C:\xampp\htdocs\
ServerName localhost
</VirtualHost>
<VirtualHost www.myapp>
DocumentRoot "C:\xampp\htdocs\myApp"
ServerName myapp.com
ServerAlias myapp.com
<Directory "C:\xampp\htdocs\myApp">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
When I type http://www.myapp.com/ in my browser it gives me Access forbidden! error. Can I get some headers?
Now it works. I a had to add .com in the VH files.
This question already has answers here:
How To Set Up Apache Virtual Hosts on XAMPP (Windows) [closed]
(4 answers)
Closed 1 year ago.
I am sure this question is being asked many times but I am not encounter with a problem. I am using XAMPP where I configure Zend framework.
XAMPP is running on port 8081 as 80 is being occupied by some Windows process I need to use virtual host for that I configure with following code in C:/xampp/apache/config/extra/httpd-vhosts.config (or C:/xampp/apache/conf/extra/httpd-vhosts.conf in newer releases).
<VirtualHost *:80>
ServerName comm-app.local
DocumentRoot "C:/xampp/htdocs/CommunicationApp/public"
SetEnv APPLICATION_ENV "development"
<Directory "C:/xampp/htdocs/CommunicationApp/public"
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
and also update the hosts file with 127.0.0.1 comm-app.local and try to re-start apache but it is showing error.
15:03:01 [Apache] Error: Apache shutdown unexpectedly.
15:03:01 [Apache] This may be due to a blocked port, missing dependencies,
15:03:01 [Apache] improper privileges, a crash, or a shutdown by another method.
15:03:01 [Apache] Press the Logs button to view error logs and check
15:03:01 [Apache] the Windows Event Viewer for more clues
15:03:01 [Apache] If you need more help, copy and post this
15:03:01 [Apache] entire log window on the forums
Step 1) C:\WINDOWS\system32\drivers\etc\
Open the "hosts" file :
127.0.0.1 localhost
127.0.0.1 test.com
127.0.0.1 example.com
Step 2) xampp\apache\conf\extra\httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot C:/xampp/htdocs/test/
ServerName www.test.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot C:/xampp/htdocs/example/
ServerName www.example.com
</VirtualHost>
Step 3) C:\xampp\apache\conf\httpd.conf. Scroll down to the Supplemental configuration section at the end, and locate the following section (around line 500), Remove the # from the beginning of the second line so the section now looks like this:
#Virtual hosts
Include conf/extra/httpd-vhosts.conf
Step 4) Restart XAMPP
and now run in your browser :
www.example.com or www.test.com
I see two errors:
<VirtualHost *:80> -> Fix to :8081, your POrt the server runs on
ServerName comm-app.local
DocumentRoot "C:/xampp/htdocs/CommunicationApp/public"
SetEnv APPLICATION_ENV "development"
<Directory "C:/xampp/htdocs/CommunicationApp/public" -> This is probably why it crashes, missing >
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
-> MIssing close container: </VirtualHost>
Fixed version:
<VirtualHost *:8081>
ServerName comm-app.local
DocumentRoot "C:/xampp/htdocs/CommunicationApp/public"
SetEnv APPLICATION_ENV "development"
<Directory "C:/xampp/htdocs/CommunicationApp/public">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
One thing to mention:
You can always try and run command:
service apache2 configtest
This will tell you when you got a malformed configuration and maybe even can tell you where the problem is.
Furthermore it helps avoid unavailability in a LIVE system:
service apache2 restart
will shutdown and then fail to start, this configtest you know beforehand "oops I did something wrong, I should fix this first" but the apache itself is still running with old configuration. :)
Add this Code in C:\xampp\apache\conf\extra\httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs"
ServerName qa-staging.com
ServerAlias www.qa-staging.com
<Directory "c:/xampp/htdocs">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Now Add your virtual host name in bellow file.
C:\Windows\System32\drivers\etc\hosts
127.0.0.1 qa-staging.com
If you are not able to save this code in host file then right click on notpad select Run as administrator and then you can able to save your custom code now restart your XAMP
Write these codes end of the C:\xampp\apache\conf\extra\httpd-vhosts.conf file,
DocumentRoot "D:/xampp/htdocs/foldername"
ServerName www.siteurl.com
ServerAlias www.siteurl.com
ErrorLog "logs/dummy-host.example.com-error.log"
CustomLog "logs/dummy-host.example.com-access.log" common
between the virtual host tag.
and edit the file System32/Drivers/etc/hosts use notepad as administrator
add bottom of the file
127.0.0.1 www.siteurl.com
<VirtualHost *:80>
DocumentRoot "D:/projects/yourdirectry name"
ServerName local.yourdomain.com
<Directory "D:/projects/yourdirectry name">
Require all granted
</Directory>
</VirtualHost>
Save the Apache configuration file.
for detailed info refer to this
Just change the port to 8081 and following virtual host will work:
<VirtualHost *:8081>
ServerName comm-app.local
DocumentRoot "C:/xampp/htdocs/CommunicationApp/public"
SetEnv APPLICATION_ENV "development"
<Directory "C:/xampp/htdocs/CommunicationApp/public">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
In Your disk drive:\xampp\apache\conf\extra\httpd-vhosts.conf exists an example and you could edit it with your configuration:
##<VirtualHost *:80>
##ServerAdmin webmaster#dummy-host.example.com
##DocumentRoot "C:/xampp/htdocs/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>
It would be like this, as example and don't forget to add VirtualHost for localhost itself to have posibility run phpmyadmin and other project at the same time on the port 80, as example I will show with store.local project:
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#store.local
DocumentRoot "c:/xampp/htdocs/store.local/public"
ServerName www.store.local
ServerAlias store.local
<Directory C:/xampp/htdocs/store.local>
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
then as mentioned above you must add in:
C:\windows\system32\drivers\hosts to the bottom of the file
127.0.0.1 store.local
127.0.0.1 www.store.local
restart Apache and try in the browser:
store.local or www.store.local
maybe at the first time you must to add like this:
http://store.local or http://www.store.local
to use other ports, you must add follows, before your VirtualHost:
Listen 8081 or another which you prefer
then just use the port for your VirtualHost like this:
<VirtualHost *:8081>
ServerAdmin webmaster#store.local
DocumentRoot "c:/xampp/htdocs/store.local/public"
ServerName store.local
ServerAlias www.store.local
<Directory C:/xampp/htdocs/store.local>
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
then restart Apache and try in the browser
store.local:8081 or www.store.local:8081
and only project for which you add the port will running on this port, for example other projects and phpmyadmin will be still running on port 80
Apache Virtual Host documentation Setting up a virtual host (vhost) provides several benefits:
Virtual Hosts make URLs cleaner – localhost/mysite vs mysite.local.
Virtual Hosts make permissions easier – restrict access for a single vhost on a local network vs permitting access to all sites on your local network.
Some applications require a “.” in the URL (ahem Magento). While you can setup localhost.com/mysite by editing the Windows hosts file, creating a vhost is a better solution.
VirtualHost Directive Contains directives that apply only to a specific hostname or IP address
Location Directive Applies the enclosed directives only to matching URLs
Example changes over configuration file - D:\xampp\apache\conf\extra\httpd-vhosts.conf
<VirtualHost *:80>
ServerAdmin localhost
DocumentRoot "D:/xampp/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost localhost:80>
ServerAdmin webmaster#host.example.com
DocumentRoot "/www/docs/host.example.com"
#DocumentRoot "D:\xampp\htdocs\phpPages"
ServerName host.example.com
ErrorLog "logs/host.example.com-error_log"
TransferLog "logs/host.example.com-access_log"
</VirtualHost>
# To get view of PHP application in the Browser.
<VirtualHost *:80>
ServerAdmin postmaster#dummy-host.localhost
DocumentRoot "D:\xampp\htdocs\app1"
ServerName app1.yash.com
ServerAlias app1.yash.com
ErrorLog "logs/app1.yash.com-error.log"
CustomLog "logs/app1.yash.com-access.log" combined
# App1 communication proxy call to Java War applications from XAMP
<Location /ServletApp1>
ProxyPass http://app1.yashJava.com:8080/ServletApp1
ProxyPassReverse http://app1.yashJava.com:8080/ServletApp1
Order Allow,Deny
Allow from all
</Location>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin postmaster#infotreesolutions.com
DocumentRoot "D:\xampp\htdocs\app2"
ServerName app2.yash.com
ErrorLog "logs/app2.yash.com-error.log"
CustomLog "logs/app2.yash.com-access.log" combined
# App1 communication proxy call to Java War applications from XAMP
<Location /ServletApp2>
ProxyPass http://app1.yashJava.com:8080/ServletApp2
ProxyPassReverse http://app1.yashJava.com:8080/ServletApp2
Order Allow,Deny
Allow from all
</Location>
</VirtualHost>
Update Your Windows Hosts File « Open your Windows hosts file located in C:\Windows\System32\drivers\etc\hosts.
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 test.com
127.0.0.1 example.com
127.0.0.1 myssl.yash.com
D:\xampp\apache\conf\httpd.conf, [httpd-ssl.conf](http://httpd.apache.org/docs/2.2/mod/mod_ssl.html)
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost> directive.
# Listen 0.0.0.0:80 | [::]:80
Listen 80
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule speling_module modules/mod_speling.so
# ServerAdmin: Your address, where problems with the server should be e-mailed.
# This address appears on some server-generated pages, such as error documents.
# e.g. admin#your-domain.com
ServerAdmin postmaster#localhost
ServerName localhost:80
DocumentRoot "D:/xampp/htdocs"
<Directory "D:/xampp/htdocs">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
</Directory>
# Virtual hosts
Include "conf/extra/httpd-vhosts.conf"
# ===== httpd-ssl.conf - SSL Virtual Host Context =====
# Note: Configurations that use IPv6 but not IPv4-mapped addresses need two
# Listen directives: "Listen [::]:443" and "Listen 0.0.0.0:443"
Listen 443
## SSL Virtual Host Context
<VirtualHost _default_:443>
DocumentRoot "D:\xampp\htdocs\projectFolderSSL"
ServerName myssl.yash.com:443
ServerAlias myssl.yash.com:443
ServerAdmin webmaster#localhost
ErrorLog "logs/error.log"
<IfModule log_config_module>
CustomLog "logs/access.log" combined
</IfModule>
## Redirecting URL from Web server to Application server over different machine.
# myssl.yash.com:443/ServletWebApp
<Location /path>
ProxyPass http://java.yash2.com:8444/ServletWebApp
ProxyPassReverse http://java.yash2.com:8444/ServletWebApp
Order Allow,Deny
Allow from all
</Location>
#SSLCertificateFile "conf/ssl.crt/server.crt"
SSLCertificateFile "D:\SSL_Vendor\yash.crt"
#SSLCertificateKeyFile "conf/ssl.key/server.key"
SSLCertificateKeyFile "D:\SSL_Vendor\private-key.key"
#SSLCertificateChainFile "conf/ssl.crt/server-ca.crt"
SSLCertificateChainFile "D:\SSL_Vendor\intermediate.crt"
</VirtualHost>
# ===== httpd-ssl.conf - SSL Virtual Host Context =====
#see
XAMPP security concept - Error 403,404
Apache VirtualHost and localhost
I fixed it using following configuration.
Listen 85
<VirtualHost *:85>
DocumentRoot "C:/xampp/htdocs/LaraBlog/public"
<Directory "C:/xampp/htdocs/CommunicationApp/public">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
I'm a little late to the party, but I wrote this little bash script for Mac that creates a VirtualHost through the terminal:
#!/bin/bash
echo "Welcome to the VirtualHostCreator! Press <RETURN> to continue."
read
echo "Enter the name the VirtualHost you would like to create. No spaces or dashes, please."
read hostname
echo "Enter the document root of the VirtualHost."
read doc_root
echo "Creating VirtualHost \"$hostname\". You may be prompted for your password."
hosts_file="/etc/hosts"
vhosts_file="/Applications/XAMPP/xamppfiles/etc/extra/httpd-vhosts.conf"
restart_command="sudo /Applications/XAMPP/xamppfiles/xampp restart"
cat >> $vhosts_file << EndOfMessage
<VirtualHost ${hostname}>
ServerName ${hostname}
DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs/${doc_root}"
</VirtualHost>
EndOfMessage
sudo sh -c "echo \"127.0.0.1 $hostname\" >> $hosts_file"
$restart_command
I'm sure there are a few improvements that can be made, and it only has the two required options for the vhost (server name and document root), but it does the job much more quickly and efficiently than opening and editing all the files manually, and also automatically restarts XAMPP afterwards.
This assumes that you have the default installation location for XAMPP, which can all be changed.
Step 1) Open Host File Under "C:\Windows\System32\drivers\etc"
Add
127.0.0.1 vipsnum.mk
Step 2) Open httpd-vhosts.conf File Under "C:\xampp\apache\conf\extra"
Add
<VirtualHost vipsnum.mk:80>
ServerName vipsnum.mk
DocumentRoot "C:/xampp/htdocs/vipnum/"
SetEnv APPLICATION_ENV "development"
<Directory "C:/xampp/htdocs/vipnum/">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
1. C:\xampp\apache\conf\https.conf
Virtual hosts
Include conf/extra/httpd-vhosts.conf
2. C:\Windows\System32\drivers\etc\hosts
127.0.0.1 localhost
127.0.0.1 helpdesk.local
3. C:\xampp\apache\conf\extra\httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/helpdesk/public"
ServerName helpdesk.local
</VirtualHost>
Now, Restart Apache and go through the link.
URL : http://helpdesk.local
Problem with xampp in my case is when specifying a different folder other than htdocs are used, especially with multiple domains and dedicated folders. This is because httpd-ssl.conf is also referencing <VirtualHost>.
To do this rem out the entire <VirtualHost> entry under httpd-ssl.conf
From there, any setting you do in your httpd-vhosts.conf will update as expected both http and https references.
I have been looking for the solution for quite a bit. And finally I have the answer. If your virtual host is not working on your Windows 10, or 7 etc, it's because of this new https hype, where all the sites are routed to https.
XAMPP follows the same trend, so fixing virtual hosts, hosts file etc is not enough, due to strict https redirection. Here is the full solution.
My desired site is located at D:\xampp\htdocs\ikeen.
1) Add this to your httpd-vhosts.conf:
<VirtualHost *:80>
ServerName localhost
DocumentRoot "D:\xampp\htdocs"
<Directory "D:\xampp\htdocs">
DirectoryIndex index.php
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName ikeen.localhost
DocumentRoot "D:\xampp\htdocs\ikeen"
SetEnv APPLICATION_ENV "development"
<Directory "D:\xampp\htdocs\ikeen">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
2) Add this to the end of httpd.conf:
<Directory />
AllowOverride none
Require all granted
</Directory>
3) Add this line to your hosts file in Windows directory
127.0.0.1 ikeen.localhost
4) The final step is to change the VirtualHost section of your httpd-ssl.conf file to the following
<VirtualHost _default_:443>
# General setup for the virtual host
DocumentRoot "D:/xampp/htdocs"
#ServerName www.example.com:443
ServerName localhost
ServerAdmin admin#example.com
ErrorLog "D:/xampp/apache/logs/error.log"
TransferLog "D:/xampp/apache/logs/access.log"
# General setup for the ikeen host
DocumentRoot "D:/xampp/htdocs/ikeen"
#ServerName www.example.com:443
ServerName ikeen.localhost
ServerAdmin admin#example.com
ErrorLog "D:/xampp/apache/logs/error.log"
TransferLog "D:/xampp/apache/logs/access.log"
Restart and be happy:)
I have added below configuration to the httpd.conf and restarted the lampp service and it started working. Thanks to all the above posts, which helped me to resolve issues one by one.
Listen 8080
<VirtualHost *:8080>
ServerAdmin webmaster#dummy-host2.example.com
DocumentRoot "/opt/lampp/docs/dummy-host2.example.com"
ServerName localhost:8080
ErrorLog "logs/dummy-host2.example.com-error_log"
CustomLog "logs/dummy-host2.example.com-access_log" common
<Directory "/opt/lampp/docs/dummy-host2.example.com">
Require all granted
</Directory>
</VirtualHost>
Simple,
You can see the below template and use it accordingly. Its very common to create a virtual host and very simple. Surely below template will work.
<VirtualHost *:8081>
DocumentRoot "C:/xampp/htdocs/testsite"
ServerName testsite.loc
ServerAlias www.testsite.loc
<Directory "c:/xampp/htdocs/testsite">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Also for more reference about virtual host please visit this site.
http://www.thegeekstuff.com/2011/07/apache-virtual-host
Thanks,
I'm learning Symfony right now. I created 2 Symfony projects with 2 different domains. Nevertheless, my second domain points to the first, and don't know why.
I'm following this tutorial, the famous jobeet: http://www.symfony-project.org/jobeet/1 ... rine/en/01
Notice my configurations:
My /etc/apache2/httpd.conf
ServerName localhost
#From the symfony tutorial "jobeet"
# Be sure to only have this line once in your configuration
NameVirtualHost 127.0.0.1:8080
# This is the configuration for your project
<VirtualHost 127.0.0.1:80>
ServerName www.jobeet.com.localhost
DocumentRoot "/home/lola/sfprojects/jobeet/web"
DirectoryIndex index.php
<Directory "/home/lola/sfprojects/jobeet/web">
AllowOverride All
Allow from All
</Directory>
Alias /sf /home/lola/sfprojects/jobeet/lib/vendor/symfony/data/web/sf
<Directory "/home/lola/sfprojects/jobeet/lib/vendor/symfony/data/web/sf">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
#Another symfony tutorial
NameVirtualHost 127.0.0.1:8081
<VirtualHost 127.0.0.1:80>
ServerName www.tutorial.com.localhost
DocumentRoot "/home/sfprojects/tutorial/web"
DirectoryIndex index.php
<Directory "/home/sfprojects/tutorial/web">
AllowOverride All
Allow from All
</Directory>
Alias /sf /home/lola/sfprojects/tutorial/lib/vendor/symfony/data/web/sf
<Directory "/home/lola/sfprojects/tutorial/lib/vendor/symfony/data/web/sf">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
Notice that I'm listening to 8081 port in the tutorial domain. I tried the permutation of VirtualHost 127.0.0.1:80 and VirtualHost 127.0.0.1:81. Neither worked. (really don't know which use)
My /etc/hosts:
#From the symfony tutorial
127.0.0.1 www.jobeet.com.localhost
#From ANOTHER symfony tutorial
127.0.0.1 www.tutorial.com.localhost
After that I restarted Apache.
Now, when I do:
http://www.jobeet.com.localhost/frontend_dev.php/ I go to my Jobeet tutorial things, BUT when I do http://www.tutorial.com.localhost/frontend_dev.php/ I ALSO go to the Jobeet page. I should go to the one containing the tutorial part.
Why is not working??!
Well:
In /etc/apache2/httpd.conf is enough with:
NameVirtualHost 127.0.0.1:80
I repeated this command when creating the other ServeName (tutorial). Maybe that was the conflict. I left all in port 80. Now it resolve right.
So, this is the final /etc/apache2/httpd.conf:
ServerName localhost
NameVirtualHost 127.0.0.1:80
# This is the configuration for your project
<VirtualHost 127.0.0.1:80>
ServerName www.jobeet.com.localhost
DocumentRoot "/home/lola/sfprojects/jobeet/web"
DirectoryIndex index.php
<Directory "/home/lola/sfprojects/jobeet/web">
AllowOverride All
Allow from All
</Directory>
Alias /sf /home/lola/sfprojects/jobeet/lib/vendor/symfony/data/web/sf
<Directory "/home/lola/sfprojects/jobeet/lib/vendor/symfony/data/web/sf">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
#Another symfony tutorial
# DO NOT REPEAT NameVirtualHost 127.0.0.1:80 --------> ****HERE: do not repeat this****
<VirtualHost 127.0.0.1:80>
ServerName www.tutorial.com.localhost
DocumentRoot "/home/sfprojects/tutorial/web"
DirectoryIndex index.php
<Directory "/home/sfprojects/tutorial/web">
AllowOverride All
Allow from All
</Directory>
Alias /sf /home/lola/sfprojects/tutorial/lib/vendor/symfony/data/web/sf
<Directory "/home/lola/sfprojects/tutorial/lib/vendor/symfony/data/web/sf">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
The /etc/hosts (or in /etc/apache2/sites-avaiable for debian) is the same.
I can access to www.jobeet.com.localhost and www.tutorial.com.localhost
Sorry, it was my misconfiguration.
A common mistake is to have disabled the virtual host module for apache, for enable it try: sudo a2enmod virtualhost
put your vhost conf in /etc/apache2/sites-available/name-file-with-vhost-conf
all virtual host must be enabled, with sudo a2ensite name-file-with-vhost-conf
apache2 must be reloaded sudo service apache2 reload
you can try this github/rokemaster/virtual_hosts is all steps in one script
I have two virtual hosts on windows(for example: test1.dev and test2.dev). But it always load content of test1.dev for both virtual hosts.
Following are my files:
hosts:
127.0.0.1 localhost
127.0.0.1 test1.dev
127.0.0.1 test2.dev
httpd.conf:
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>
Include "c:/wamp/alias/*"
<VirtualHost 127.0.0.1>
ServerName test1.dev
DocumentRoot "C:\wamp\www\test1\public"
</VirtualHost>
<VirtualHost 127.0.0.1>
ServerName test2.dev
DocumentRoot "C:\wamp\www\test2\public"
</VirtualHost>
Can someone recognize the problem ?
I'm guessing you're missing the NameVirtualHost 127.0.0.1:80 line somewhere :)
I did some thing like this
1- for the local host its :
NameVirtualHost localhost:80
<VirtualHost localhost:80>
ServerName localhost
ServerAlias localhost
DocumentRoot D:/wamp/www
ErrorLog "D:/wamp/www/error.log"
CustomLog D:/wamp/www/access.log common
<Directory "D:/wamp/www">
Options -Indexes FollowSymLinks MultiViews
AllowOverride All
<IfModule mod_access.c>
Order allow,deny
Allow from all
</IfModule>
</Directory>
</VirtualHost>
2 - and for any other local domain
NameVirtualHost zf.local:80
<VirtualHost zf.local:80>
ServerName zf.local
ServerAlias zf.local
DocumentRoot D:/Workspace/Zend/documentation
ErrorLog "D:/Workspace/Zend/documentation/error.log"
CustomLog D:/Workspace/Zend/documentation/access.log common
<Directory "D:/Workspace/Zend/documentation">
Options -Indexes FollowSymLinks MultiViews
AllowOverride All
<IfModule mod_access.c>
Order allow,deny
Allow from all
</IfModule>
</Directory>
</VirtualHost>
You don't have to write virtual host info into httpd.conf. Just uncomment line on which you load conf/extra/httpd-vhosts.conf, then go to this file and put your info there. Should work.
Example of my httpd-vhosts.conf:
NameVirtualHost *:80
<VirtualHost 127.0.0.1>
DocumentRoot "C:/wamp/www"
ServerName dev
</VirtualHost>
You need to include something similar to following line
NameVirtualHost *
Also, it seems you are using https connection to the server which doesn't play well with virtual hosts because of the SSL protocol limitation. The Host header in the http request is encrypted and by the time apache decrypts it, it has already passed on the request to one of the virtual host.
I changed
NameVirtualHost *:80
to
NameVirtualHost 127.0.0.1:80
and it works for me
Don't forget to check for lines like "Listen [::0]:80" in httpd.conf and add your ports there too, if NameVirtualHost doesn't work.
Hey guys I've written a very straight forward tutorial which includes the whole process. Let me know if you run into any problems in a comment.
http://www.kintek.com.au/web-design-blog/configuring-multiple-domains-within-wamp-for-local-development/