I’m having a hard time getting multiple sites working with MAMP using Virtual hosts. Below is what I have set up on my MBA. If I open up my web browser and go to "http:local.login.dev" or "http://dev.login.localhost" (after reconfigure) I get the index page that’s saved in /Users/aaron/localhost. First item listed in my Virtual hosts section Not the index page saved in the Virtual Host I want to get to. Other sites I have setup give me the same result.. "http:next.site.localhost" = displays the index page in /Users/aaron/localhost.
Does anybody have any thoughts? My final goal is to configure MAMP Virtual hosts to work and test with SSL.
Bottom line is it seems like ONLY the first Virtual host entry is read and that's whats used for every host listed. Am I missing some setting somewhere??
Environment:
- MBA with OS X, Yosemite
MAMP 3.0.7.3 using ports 80, and 3306 for http and mysql respectively
httpd.conf File:
Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
127.0.0.1 localhost
127.0.0.1 local.login.dev
<VirtualHost *>
DocumentRoot "/Users/aaron/localhost"
ServerName localhost
</VirtualHost>
<VirtualHost *:80> — I tried both with and without :80
DocumentRoot "/Users/aaron/localhost/training/login/public"
ServerName local.login.dev
</VirtualHost>
Also tried configuring my hosts and httpd-vhosts.conf this way - From another post:
127.0.0.1 localhost
127.0.0.1 dev.login.localhost
<VirtualHost *>
DocumentRoot "/Users/aaron/localhost"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Users/aaron/localhost/training/login/public"
ServerName dev.login.localhost
ServerAlias dev.login.localhost
<Directory "/Users/aaron/localhost/training/login/public">
Allow from All
AllowOverride all
Options -Indexes +FollowSymlinks
</Directory>
</VirtualHost>
Just playing around more I commented out the first "Localhost" in my httpd-vhosts.conf file and looks like I can now navigate to my local sites correctly. Below is what I currently have configed..
httpd-vhosts.conf:
# <VirtualHost *>
# DocumentRoot "/Users/aaron/localhost/"
# ServerName localhost
# </VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Users/aaron/localhost/training/login/public"
ServerName dev.login.localhost
ServerAlias dev.login.localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Users/aaron/localhost/site1"
ServerName dev.site1.localhost
ServerAlias dev.site1.localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Users/aaron/localhost/site2"
ServerName dev.site2.localhost
ServerAlias dev.site2.localhost
</VirtualHost>
Hosts File:
127.0.0.1 localhost
######Locahost Dev Sites
127.0.0.1 dev.login.localhost dev.site1.localhost dev.site2.localhost
Now to see if I can get SSL working.
If any of this is incorrect, please let me know... but this config is the only way I can get the Virtual hosts working, as of now, using port 80... If I have issues mixing with 443 I'll update
Related
Im on windows 10, trying to customize an url to use Laravel. I dont want to acess the url using public folder on it. Im using wamp and apache is running on port 8080. So I edit the file wamp\bin\apache\apache2.4.23\conf\extra\httpd-vhosts.conf like this:
<VirtualHost *:80>
DocumentRoot c:/wamp/www/
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot c:/wamp/www/laravel_test/blog/public
ServerName laravel_test.dev
</VirtualHost>
After that, I edit the file system32/drivers/etc/hosts with:
127.0.0.1 localhost
127.0.0.1 laravel_test.dev
And when I access the url laravel_test.dev it doesnt work. I tried to use this too on httpd-vhosts.conf:
<VirtualHost *:8080>
And it doesnt work either. I always restart the service on wamp, and nothing changes.
I couldnt install and configure the homestead properly, so im trying to use wamp now. Can somebody help me?
In your httpd.conf file you need to uncomment the virtual Hosts section
Then,
Your vhost needs to listen on port 8080
<VirtualHost *:8080>
ServerName laraveltest.dev
ServerAlias www.laraveltest.dev
DocumentRoot c:/wamp/www/laravel_test/blog/public
<Directory "c:/wamp/www/laravel_test/blog/public">
AllowOverride All
Options Indexes MultiViews FollowSymLinks
Require all granted
</Directory>
</VirtualHost>
For your hosts file
127.0.0.1 laraveltest.dev www.laraveltest.dev
Currently, I have XAMPP setup to where typing 127.0.0.1 in the browser redirects me to the home page found within htdocs.
I would like to be able to type "devtest" and have that be an alias for 127.0.0.1.
What I have tried so far is modifying: C:\xampp\apache\conf\extra\httpd.vhosts.conf where I added an entry that looks like:
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host2.example.com
DocumentRoot C:\xampp\htdocs\Workspace\MyProject
ServerName devtest
ErrorLog C:\xampp\htdocs\Workspace\MyProject\MyProject-error_log
CustomLog C:\xampp\htdocs\Workspace\MyProject\MyProject-access_log common
</VirtualHost>
Is there another step I'm missing?
Open the hosts file in Notepad:
C:\Windows\System32\drivers\etc\hosts
Add the line:
127.0.0.1 devtest
Navigate to: http://devtest
Use this, and make sure you enable using vhosts config file in apache.
<VirtualHost *:80>
DocumentRoot "C:\xampp\htdocs\Workspace\MyProject"
ServerName devtest.local
<Directory "C:\xampp\htdocs\Workspace\MyProject">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
I just started learning php and I am trying to host locally my own php website by using XAMPP.
I wanted to create virtual host with:
URL: myphpwebsite.local
Port: 8088
But when I attempted to access this website through the browser I got a:
Not Found
HTTP Error 404. The requested resource is not found.
Does anyone know what the problem is?
My httpd-vhosts.conf
NameVirtualHost 127.0.0.1:8088
<VirtualHost 127.0.0.1:8088>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost myphpwebsite.local>
DocumentRoot "C:/Microsoft/Workspace/myphpwebsite"
ServerName myphpwebsite.local
ErrorLog "C:/Microsoft/Workspace/myphpwebsite/logs/myphpwebsite.local.error.log"
CustomLog "C:/Microsoft/Workspace/myphpwebsite/logs/myphpwebsite.local.custom.log" combined
<Directory "C:/Microsoft/Workspace/myphpwebsite">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
And my C:\Windows\System32\drivers\etc\hosts file:
127.0.0.1 localhost
127.0.0.1 myphpwebsite.local
Any help would be appreciated!
make sure there's file/htaccess/index or whatever in directory you want to open, 404 may comes from that ;)
try using one below, eventually replace your port:
<VirtualHost *:80>
DocumentRoot "C:/Microsoft/Workspace/myphpwebsite"
ServerName myphpwebsite.local
</VirtualHost>
the question is your Apache running/serving on port 8088?
For example my xamp is running on 80 and 443...
xamp control panel is very handy, it has nice logs button that will open your log files to show you php and apache errors etc. check it out.
Try going with default port, if it works it means that you need to play with ports if you really want to.
just a quick tip, .com is shorter than .local and if you're using chrome and it works like mine then most of the time something.local will redirect you to google search (and I like my search there, you can switch it off ;))
I don't know if I am much help, but using WAMP, here are my settings. I am listening on port 80, I use 8080 for my tomcat server.
hosts file
127.0.0.1 local.mysite.com
httpd-vhosts.conf
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
....
<Directory "c:/wamp/www">
Options Indexes MultiViews FollowSymLinks
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Directory>
<VirtualHost *:80>
ServerName localhost
DocumentRoot "c:/wamp/www"
</VirtualHost>
<Directory "c:/wamp/www/path/to/site/root">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<VirtualHost *:80>
ServerName local.mysite.com
DocumentRoot "c:/wamp/www/path/to/site/root"
ServerAdmin me#email.com
ProxyPreserveHost Off
RewriteEngine On
AllowEncodedSlashes NoDecode
#AllowEncodedSlashes On
ErrorLog "c:/wamp/www/path/to/logs/error.log"
CustomLog "c:/wamp/www/path/to/logs/access.log" common
</VirtualHost>
....
Then I can access my local site like this: http://local.mysite.com
Hope this helps...
The NameVirtualHost directive needs to match the value of VirtualHost exactly, and you need to specify the port in each instance. If you want to use port 8088 for myphpwebsite.local, you'd need to do:
NameVirtualHost 127.0.0.1:8088
<VirtualHost 127.0.0.1:8088>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost 127.0.0.1:8088>
DocumentRoot "C:/Microsoft/Workspace/myphpwebsite"
ServerName myphpwebsite.local
ErrorLog "C:/Microsoft/Workspace/myphpwebsite/logs/myphpwebsite.local.error.log"
CustomLog "C:/Microsoft/Workspace/myphpwebsite/logs/myphpwebsite.local.custom.log" combined
<Directory "C:/Microsoft/Workspace/myphpwebsite">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Notice the VirtualHost opening tags are identical; it's the ServerName value that actually tells Apache which domain this particular directive applies to. Restart your server after making the changes. Check out this page for more information: http://httpd.apache.org/docs/2.2/vhosts/name-based.html
Hope this helps!
Make sure that the port you are using is not being used by another service.
I know this question has been asked several times, and ive even done it alot of times in my company, but, now I wanted to set up a virtual host at home and Its not working.
What have I done:
Added xxx.localhost.de into the hosts
127.0.0.1 xxx.localhost.de
Uncommented include vhosts... in my httpd.conf
Include conf/extra/httpd-vhosts.conf
Set up a virtual host for my project
<VirtualHost *:80>
ServerAdmin asdr#web.de
DocumentRoot "D:\wamp\www\xxx"
ServerName xxx.localhost.de
ServerAlias xxx.localhost.de
ErrorLog "logs/xxx-error.log"
CustomLog "logs/xxx-access.log" common
</VirtualHost>
I dont get an error - wamp is still starting fine and I can access it by using the normal path
localhost/...
but when i try to reach it over xxx.localhost.de , I get on the website "www.localhost.de". It acts like he does NOT care about my hosts file...
What have I actually missed out? In my company it always worked like this. Ive checked tutorials aswell, and it always says this are all the steps which are needed.
Thanks!
I have had the same problem too, There are couple of things that can cause that, first try to add DirectoryIndex index.php to
<VirtualHost *:80>
ServerAdmin asdr#web.de
DocumentRoot "D:\wamp\www\xxx"
DirectoryIndex index.php
ServerName xxx.localhost.de
ServerAlias xxx.localhost.de
ErrorLog "logs/xxx-error.log"
CustomLog "logs/xxx-access.log" common
</VirtualHost>
then you can try to write in your browser "http://you_address.local
if this doesn't help,I will think of anything else that can cause that
Try this :-
Change the HOSTS file to :-
127.0.0.1 localhost
::1 localhost
127.0.0.1 project1.dev
::1 project1.dev
And the Vhost definition to
<VirtualHost *:80>
ServerAdmin asdr#web.de
DocumentRoot "D:\wamp\www"
ServerName localhost
ServerAlias localhost
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" common
<Directory "D:/wamp/www">
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin asdr#web.de
DocumentRoot "D:\wamp\www\xxx"
ServerName project1.dev
ServerAlias www.project1.dev
ErrorLog "logs/project1-error.log"
CustomLog "logs/project1-access.log" common
<Directory "D:/wamp/www/xxx">
AllowOverride All
Require local
</Directory>
</VirtualHost>
It seems I had to make the changes to the hosts.ics file, and not the standard hosts file. It worked just fine then
I have a local virtual host for my main site, local.mysite.com. I also have other virtual hosts for other projects I am working on. For instance, local.mygame.com. For some reason, after adding in the virtual host information and adding the string to my hosts file, whenever I access local.mygame.com, or local.phpmyadmin.com, it redirects to local.mysite.com everytime.
<VirtualHost *:80>
ServerName local.mysite.com
ServerAlias local.mysite.com
DocumentRoot /mysite/content
</VirtualHost>
<VirtualHost *:80>
ServerName local.mygame.com
DocumentRoot /www/mygame
LogLevel debug
</VirtualHost>
Hosts file contains:
127.0.0.1 local.mysite.com
127.0.0.1 local.mygame.com
It does a 302 redirect from local.mygame.com to local.mysite.com
Try adding "AllowOverride none" in case a .htaccess file is overriding your settings here