Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 months ago.
Improve this question
I need your help here in creating a virtual host in wampserver. In office I can create a virtual hosts but when I try to create in my laptop it doesn't work. I still can't figure out what's wrong. Here's what I did.
I copy the wordpress file in this folder. This will be the path of my project
E:\Subversion\chelle.wpblog.local
I edit the host file
C:\Windows\System32\drivers\etc\hosts
I added it to the end of file
127.0.0.1 chelle.wpblog.local
Next is I enable the virtual host in Apache
C:\wamp\bin\apache\Apache2.4.4\conf\httpd.conf
I uncomment this
Include conf/extra/httpd-vhosts.conf
Next is I setup the virtual host in WAMP
C:\wamp\bin\apache\Apache2.4.4\conf\extra\httpd-vhosts.conf
I add this at the bottom
<VirtualHost *:80>
ServerName chelle.wpblog.local
ServerAlias chelle.wpblog.local
DocumentRoot "E:/Subversion/chelle.wpblog.local/"
<Directory "E:/Subversion/chelle.wpblog.local/">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
Last is restart wampserver and open the chelle.wpblog.local in the browser. And it doesn't display. It display only google search results.
I was installing the zend framework on my local wamp using apache server.
First go and decide what will be your domain name for the local url.
Ex->www.test_zend_tutorial.com
then go and open the file located at "C:\WINDOWS\system32\drivers\etc"
hosts
write
127.0.0.1 (use one tab space) www.test_zend_tutorial.com
then go to the folder located at
D:\wamp\bin\apache\Apache2.2.17 (whatever is your version) \conf\
and open the file
httpd.conf
and search for text
Include conf/extra/httpd-vhosts.conf
and uncomment it by removing the # tag from the start of the line.Save the file and close it.
Now go to another folder located at
D:\wamp\bin\apache\Apache2.2.17\conf\extra
and open the file
httpd-vhosts.conf
and paste the code below at the last in this file
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot "D:\wamp\www"
ServerName localhost
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerName www.test_zend_tutorial.com
DocumentRoot "D:\wamp\www\(your project folder name)\public"
SetEnv APPLICATION_ENV "development"
<directory "D:\wamp\www\(your project folder name)\public">
DirectoryIndex index.php
AllowOverride all
Order Allow,Deny
Allow from all
</directory>
</VirtualHost>
and restart the wamp, now write the www.test_zend_tutorial.com in the browser and you will see the things working.
If when you use the new domain in the browser it goes to a google search or something like that then the change to your hosts file has not been recognised.
You have to either reboot after changing the hosts file or more simply run these 2 commands from a command windows ( as administrator )
net stop dnscache
net start dnscache
This will refresh windows DNS cache and pick up your hosts file changes.
It is also a good idea to ping your new domain to check it is being seen, use
ping chelle.wpblog.local
If it reports 127.0.0.1 as the ip address and 4 send and 4 receieved packet then the domain is now known to Windows, if it reports some other ip address the hosts file change has not succeeded.
Also it is a good idea when creating VHOSTS to also create one for localhost or the wamp home page will not work.
You also have old Apache 2.2 syntax (Order allow,deny allow from all) you could try using the Apache 2.4 syntax, see below
So try this
## must be first so the the wamp menu page loads
<VirtualHost *:80>
ServerAdmin webmaster#mail.net
DocumentRoot "D:/wamp/www"
ServerName localhost
<Directory "D:/wamp/www">
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#mail.net
ServerName chelle.wpblog.local
ServerAlias www.chelle.wpblog.local
DocumentRoot "E:/Subversion/chelle.wpblog.local"
<Directory "E:/Subversion/chelle.wpblog.local">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
In WampServer 3.0.4 you do not need to run through all those setting up.
Go to local host and under Tools area for "Add a Vertual Host" in the first time it will say turn on "Vertual Host sub menu" in wamp server settings.
To get there right click on wamp icon > go to wamp server settings > and click on Vertual Host sub menu. Then re-fresh the page and follow the setup process, you just need to provide the server name and path. It will do all the works for you.
Simple as that
Method 1:
in hosts file
127.0.0.1 mysite
::1 mysite
in C:\wamp64\bin\apache\apache2.4.23\conf\extra\httpd-vosts.conf file add your virtual host as follows
<VirtualHost *:80>
ServerName mysite
DocumentRoot "<path_to_your_local_site>"
<Directory "<path_to_your_local_site>">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
Make sure vhost configuration is enable in httpd.conf file is enabled as follows
C:\wamp64\bin\apache\apache2.4.23\conf\httpd.conf
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
After you have changed configuration as above, restart all service in wamp and load website as follows
http://mysite
your local site should open.
Method 2:
In latest versions of wamp, you can do this configuration via webpage.
Open localhost in your browser. You would see wamp welcome page.
Down below under Tools, there is option to add virtual host. click on the link which would take you to add virtual host page.
In Name of the host, enter your site name eg: mysite
Under Complete absolute path of the VirtualHost folder, enter the path of your site.
Save the config and restart all services. you should be able to open mysite with the link http://mysite
As pointed in another answer, in newer versions of wam
The answers above are overcomplicating the problem somewhat, and in fact the question is including extra information that's misleading the responders.
The clues lie in step 2 and the symptoms described in 5. The hosts file is set up but when the request is made to "blah.local", google responds. Apache is not involved.
The first step to diagnosis would be pinging blah.local and seeing that it maps correctly to 127.0.0.1. I have never (in many years as a developer) found it necessary to restart local DNS on either Windows or Linux/Mac so I would expect this to work out of the box. But if it doesn't, of course restart DNS and see that it does.
However, late versions of Chrome at least do not recognize the TLD '.local' and so when you put the URL back in the browser, it's passed on to Google as a search term. There may be a setting in your browser to tell it to handle the unsanctioned TLD, but your simplest solution would be to use a TLD that's sanctioned by W3C like '.com'.
In short, if your hosts file reads something like
127.0.0.1 local.chelle.wpblog.com
rather than
127.0.0.1 chelle.wpblog.local
everything should work.
Create the folder for your local website
Go to localhost (browser)
Click Add a Virtual Host button
Add the name of the virtual host
Add the complete absolute path
Restart DNS
Related
I want to be able to use root-relative-paths (ex: /incl/file.php) while developing the website in XAMPP's localhost so that it will work in the same way when I upload it to a webserver. In order to do that, I've set up a Virtual Host within XAMPP. The Virtual Host works fine when I access it with absolute paths (ex: C:/xampp/htdocs/incl/file.php) or pahts without the slash (incl/file.php), but root-relative-paths (/incl/file.php) don't work at all.
I've tried many different configurations of Virtual Host set ups that I found here and on many websites and uninstalling and installing XAMPP. I've also tried to use "\" instead of "/", but the result is the same. I have Windows 10 Pro with the latest XAMPP version installed on it.
This is the Virtual Host set up I am currently employing.
In the hosts file:
# localhost name resolution is handled within DNS itself.
127.0.0.1 localhost
# ::1 localhost
127.0.0.1 atriero.localhost
In the httpf-vhosts.conf file:
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
<Directory "C:/xampp/htdocs">
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/xampp/subdomains/site"
ServerName atriero.localhost
<Directory "C:/xampp/subdomains/site">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
As an example of root-relative-paths that are not working, in my index page I have
require "/header.php";
which is located on the "site" folder, the same where index.php is located. If I type "header.php" without the slash, it works fine.
There's also in the header.php page the following line
include_once '/includes/dbh.inc.php';
where the same issue happens, dbh.inc.php is located in the includes folder within the site folder. If I take the slash out the link works fine, but in the way it is writen, with root-relative-path, it doesn't work.
I expect that it is possible to run root-relative-paths with Virtual Host in XAMPP, I assume it would really help in the development of my website and as far as I know it would be the best way to do so.
If for some reason it isn't possible to use root-relative-paths with Virtual Host and if I have to upload my website to the server without the "\" before every path, will it be harmfull in any way to the working of my website?
Thanks in advance.
I am trying to setup virtual host for Magento, but its not working, I created magento.localhost.com.conf in the Apache2/sites-avaliable directory, this is my file :
<VirtualHost *:80>
ServerAdmin magento#localhost.com
ServerName magento.localhost.com
DocumentRoot /srv/www/magento_dev/public_html
<Directory /srv/www/magento_dev/public_html/>
Options Indexes FollowSymlinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /srv/www/magento_dev/logs/error.log
LogLevel warn
</VirtualHost>
I am following instructions from book actually ,also changed /etc/hosts file , I added 192.168.36.1 magento.localhost.com. at the end , but when I try to open the site, it says :
This webpage is not available
I enabled apache rewrite, give permission to all this folders ,basically did everything as instructions, but still not working. My os is Ubuntu 14.04, any tips ?
Follow recommendations in comments for a2ensite and for testing with a simple index.php file.
Also make sure to restart Apache.
When that works, then try with the Magento index.php file.
What you do next depends on if this is a brand new copy of Magento or a copy of a previously installed one. If it's new, you should see the setup page. Follow the instructions. If it's a copy, you will need to change the database core_config_data values relating to your website urls.
Edit:
You say
changed /etc/hosts file ,I added 192.168.36.1
On what machine did you change this? Also is your Magento running in a virtual machine on your Windows machine? And the VM machine has that IP?
Edit 2:
Also change your web server name to "Magento.mysite.com" or something like that. localhost has a special meaning! And it doesn't make sense if you are accessing a remote we server!
Check web server ip with ipconfig or ifconfig on the command prompt. Put that ip in the hosts file of the web browser machine.
Yesterday i have created a new site on my Codero Dedicated Server. and i have not assigned any domain name yet to the ip address.
Currently i am able to access my site with http://MySiteIpAddress/~username but i want to access it with only http://MySiteIpAddress/. Is there any way to do it. I don't know if that's possible by htaccess rules, so any hints are appreciated.
You want to setup a virtual host and point it to the folder you want.
See this other post for more details.
You need to do several steps in order to make this work.
1.) Update the hosts file. On Windows XP, you can find it under c:\WINDOWS\system32\drivers\etc\. You should already see the first
line from below, it takes care of your mentioned other project. - add
the additional ones to make any requests to the mentioned virtual
hosts routed back to your own machine.
127.0.0.1 localhost
127.0.0.1 foo-bar.com
127.0.0.1 abcdef.com
127.0.0.1 qwerty.com
2.) Update the vhosts file in Apache configuration. Under your XAMPP folder, add the following to
apache\conf\extra\httpd-vhosts.conf and if needed change the ports
(i.e. if you use 8080 instead of port 80).
<VirtualHost *:80>
DocumentRoot C:/xampplite/htdocs/foo-bar/
ServerName www.foo-bar.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot C:/xampplite/htdocs/abcdef/
ServerName www.abcdef.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot C:/xampplite/htdocs/qwerty/web/
ServerName www.qwerty.com
</VirtualHost>
3.) Do a quick configuration check. Open {XAMPP-folder}\apache\conf\httpd.conf your file and make sure that
the following part is not commented out by a preceeding # character:
Include conf/extra/httpd-vhosts.conf
4.) Restart XAMPP.
... and you should be all setup now. Your other project should
be accessible at the URI you mentioned if you just put it under
C:/xampplite/htdocs/my-project/.
I am using wamp to build my web application. So I had one vhost at mydomain.com but now I have changed my domain to dev.mydomain.com . For this changes to reflect I have edited etc\hosts file's entry from 127.0.0.1 mydomain.comto 127.0.0.1 dev.mydomain.com and in apache configuration file httpd-vhosts.conf -
<VirtualHost *:80>
DocumentRoot "D:/Software/Installed/wamp/www/myapp/public"
ServerName dev.mydomain.com
<Directory "D:/Software/Installed/wamp/www/myapp">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require local
</Directory>
When I open url dev.mydomain.com, I see the default wamp config page.
I have gone through many tutorials to find out what mistakes have been done but could find none. It would be helpful if someone throws some light on that. Thanks.
Why is your Directory different than DocumentRoot ??
I think you need to match those and restart your wamp and you are good to go.
Also, you must have index file in directory to see domain running properly.
I installed Bitnami WAMP Stack in Windows 7 and I am trying to get my eclipse php code to run. I found a link online that said to add an alias, but that didn't work, how do I get the code to run in
http://localhost/greenmugcafe/
if my eclipse workspace is located here
C:\Users\Robert\Documents\GitHub\greenmugcafe ?
Edit: I could not find anything on doing this for Bitnami WAMP but I found a few for the Bitnami Django stack.
Any Help at all?
Your code would run from http://localhost/greenmugcafe/ if you changed the virtual host directory of localhost to C:/Users/Robert/Documents/GitHub/
Personally, I think it would be better to create a local domain called greenmugcafe.dev rather than having a folder greenmugcafe in the localhost domain.
How to setup virtual hosts in WAMP
Make sure virtual hosts have been enabled:
Edit /installdir/apache2/conf/httpd.conf
Search for line that includes httpd-vhosts.conf and uncomment it by removing the # at the start
Adding a new virtual host:
Edit the hosts file on your windows system (usually located at C:\WINDOWS\system32\drivers\etc\)
Add the following to the end of the hosts file 127.0.0.1 greenmugcafe.dev. This tells your computer that any url with a value of greenmugcafe.dev should be routed to 127.0.0.1 (aka localhost).
Save the hosts file and now edit this file /installdir/apache2/conf/extra/httpd-vhosts.conf
Add the greenmugcafe.dev virtual host entry at the bototm of the /installdir/apache2/conf/extra/httpd-vhosts.conf file, save, and restart the server.
Here's the code:
#greenmugcafe
<VirtualHost *:80>
ServerAdmin webmaster#greenmugcafe.dev
DocumentRoot "C:/Users/Robert/Documents/GitHub/greenmugcafe/"
ServerName greenmugcafe.dev
ErrorLog "logs/greenmugcafe.dev-error.log"
CustomLog "logs/greenmugcafe.dev-access.log" common
<Directory "C:/Users/Robert/Documents/GitHub/greenmugcafe/">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Require all granted
</Directory>
</VirtualHost>
Now http://greenmugcafe.dev will point to C:/Users/Robert/Documents/GitHub/greenmugcafe/
This method will also work for other WAMP stacks like Wamp Server and XAMPP.
For a launched website on a linux server, instead of the windows host file, we would change the a record of the domain name to point to the server IP address. Then we still need to setup the virtual host so the server knows to recognise the domain name and point it to the correct folder on the server.
Hope that helps :-)