So I've been creating some websites using plain php on my computer and access them trough apache's virtualhost on port 80. However, now I'm working for a new company which develops microservices using lumen, so I had to install Valet to acces this local lumen projects. Valet works on port 80, so I've configured MAMP to run on the default ports [8888 and 8889 for MySQL]. ATM I can reach lumen microservices and localhost on localhost:8888 but I can't seem to reach all my old virtualhosts.
this is the config I have right now:
httpd.conf
Listen 8888
httpd-vhosts.conf
NameVirtualHost *:8888
<VirtualHost *:8888>
DocumentRoot /Volumes/User/Docs/PHP/htdocs
ServerName localhost
</VirtualHost>
<VirtualHost *:8888>
ServerName lab
# ServerAlias *.lab *.test
VirtualDocumentRoot "/Volumes/User/Docs/Workspace/sites/%1"
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
</VirtualHost>
Related
Context: fresh wampserver 3.x install (windows10)
port 80 was used by microsoft iis so i change the port using wampserver tool (right click on the icon). Wampserver manage itself to change the port with 8080.
at this moment, httpd-vhosts.conf content is
# Virtual Hosts
#
<VirtualHost *:8080>
ServerName localhost
ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
and hosts content is:
#
127.0.0.1 localhost:8080
::1 localhost:8080
Purpose: create virtualhost for my project like http://myproject.localdev instead of http://localhost:8080/myproject/public/
what's going bad ?
by using wampserver link to create virtualhost, i got the error message below
first VirtualHost must be localhost in c:/wamp64/bin/apache/apache2.4.33/conf/extra/httpd-vhosts.conf
I used 8080 port too and had the same problem. What I've done - in httpd-vhosts.conf I added localhost with port 80 anyway, so I had both port 80 and port 8080:
<VirtualHost *:80>
ServerName localhost
....
<VirtualHost *:8080>
ServerName localhost
After that I opened localhost:8080 - there was a warning "Port used for the VirtualHost is not an Apache Listen port". Newertheless I clicked "Add a Virtual Host". The new host was added, then I restarted DNS (WAMP - Tools - Restart DNS).
After all you can delete from httpd-vhosts.conf localhost:80
I try to use a Virtual Hosts on xampp (apache 2.4), on Windows 10.
I've been through a lot of topics and posts and tried every combination of port etc, and I couldn't make it work.
When I try to access my project it redirects me to localhost (default).
Here's my system32/drivers/etc/hosts :
127.0.0.1 localhost
127.0.0.1 yanns-properties.test
Here's my httpd-vhosts.conf :
NameVirtualHost *:8080
<VirtualHost _default_:80>
DocumentRoot "C:/xampp/htdocs/"
ServerName localhost
</VirtualHost>
# Site: yanns-properties
<VirtualHost *:8080>
DocumentRoot "C:/xampp/htdocs/yanns-properties"
ServerName yanns-properties.test
CustomLog "C:/xampp/htdocs/yanns-properties/custom.log" combined
<Directory "C:/xampp/htdocs/yanns-properties">
Options All
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
I also put in my httpd.conf file :
Listen 80
Listen 8080
When I try to access yanns-properties.test, it redirects me to localhost (with list of file since I renamed index).
I tested with various port, with my project in a different folder ... I don't know what to do anymore.
Thanks for your help !
I
I'm having trouble getting Virtual Hosts to work on MAMP.
Here's my hosts file:
127.0.0.1 localhost
127.0.0.1 mysite
Here's my httpd-vhosts.conf file:
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
#
# Custom Virtual Hosts
#
<VirtualHost *:80>
DocumentRoot "/Users/(username)/Documents/"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Users/(username)/Documents/foo/bar/"
ServerName mysite
<Directory "/Users/(username)/Documents/foo/bar/">
AllowOverride all
</Directory>
</VirtualHost>
My httpd.conf looks like this:
# Virtual hosts
Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
http://mysite doesn't work. I restarted the apache servers multiple times. I've taken a look into multiple threads on this subject on here, but I can't figure out what's wrong.
EDIT: btw, I'm using /Users/(username)/Documents as my document root for MAMP, maybe I should replace those with the usual /Applications/MAMP/htdocs anyway ?
Check that the ports you set for apache is what you set in your httpd-vhosts.conf file. If its port 80. it should be same in your Mamp apache port.
Last night I have updated my windows 7 to windows 10.
The result is struggle trying to run my local apache server in windows 10 that is running on windows 7.I have tried uninstalling and installing another versions of xampp then I came up that I have to change the apache's default port just to make it run.
I changed httpd.conf
from Listen 80 to Listen 1234
AND
ServerName localhost:80 to ServerName localhost:1234
and in xampp control panel Config->Service and Port Settings. I also change the Main Port
Now I can access phpmyadmin using localhost:1234/phpmyadmin.
And now my problem is creating Virtual host
so I added in my host(C:\Windows\System32\drivers\etc\hosts) file
127.0.0.1 sample.local
127.0.0.1 anothersample.local
And my vhost (D:\xampp\apache\conf\extra\httpd-vhosts.conf) file
<VirtualHost *:1234>
DocumentRoot "D:/xampp/htdocs/sample"
ServerName sample.local
</VirtualHost>
<VirtualHost *:1234>
DocumentRoot "D:/xampp/htdocs/anothersample"
ServerName anothersample.local
</VirtualHost>
I did make sure the vhost file above was include
I already restarted my apache but seems like my vhost is not working .Can anyone point out what i missed?
Thank you #ShamSUP AND #maytham-ɯɐɥıλɐɯ I was able to solve my problem by uninstalling the xampp.
Then following the instructions here
I will just list the steps I have done here.
Windows+R and type appwiz.cpl and use Turn Windows features on or off and install the IIS Manager Console by expanding
Internet Information Services->Web Management Tools->then checking IIS Management Console
Windows+R and type InetMgr.exe and enter, then expand Site Right Click it then click Edit Bindings
Change the http port from 80 to 8080
After that I then install the XAMPP and configure the Virtual host
host(C:\Windows\System32\drivers\etc\hosts) file
127.0.0.1 sample.local
127.0.0.1 anothersample.local
vhost (D:\xampp\apache\conf\extra\httpd-vhosts.conf) file
<VirtualHost *:80>
DocumentRoot "D:\xampp\htdocs\sample"
ServerName sample.local
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "D:/xampp/htdocs/anothersample"
ServerName anothersample.local
</VirtualHost>
And by default in windows virtual host is uncommented
After restarting apache and mysql.The Virtual host is running now.I hope this may help someone in the future.
E:\xampp\apache\conf\extra\httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "E:/xampp/htdocs/dev2017/schools"
ServerName dev.schools
<Directory "E:/xampp/htdocs/dev2017/schools">
</Directory>
</VirtualHost>
C:\Windows\System32\drivers\etc\hosts
127.0.0.1 dev.schools
NOTE: Restart Xampp Server.
Type URL: http://dev.schools
Maybe my issue is different.
Above answer not worked for me Windows 10, XAMPP portable 5.6.30
My XAMPP works on port 80 but when I set virtual host then its localhost also go to virtual host folder. So http://localhost also shows the content of http://mydrupal
I simply added this to /apache/conf/extra/httpd-vhosts.conf file as well.
<VirtualHost *:80>
DocumentRoot "D:/xampp/htdocs"
ServerName localhost
<Directory D:/xampp/htdocs>
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Above code was not required on Windows 7.
For virtual host - mydrupal
<VirtualHost *:80>
DocumentRoot "D:/vhosts/drupal"
ServerName mydrupal
<Directory D:/vhosts>
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Hope this helps.
So I have this problem...
I use WAMP and have set up perfectly working Virtual Hosts in the past, but now I have come to something I never foresaw.
I am trying to do this:
Access C:\wamp\www through http://localhost
Access D:\somethingelse through http://localhost:8080 OR http://something.dev
I much prefer using the proper http://something.dev, as the working site is http://something.co, and so I can keep them separate.
I have followed guides and read forum posts, but all I have manages to do so far is this:
Access C:\wamp\www through http://localhost OR http://something.dev
Access D:\somethingelse through http://localhost:8080 OR http://something.dev:8080
Anybody got any idea how you would do this? Here's my VirtualHost Code:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot "C:\wamp\www"
ServerName localhost
ServerAlias www.localhost.com
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" common
</VirtualHost>
<VirtualHost *:8080>
ServerAdmin webmaster#something
DocumentRoot "D:/something/www"
ServerName something.dev
ServerAlias www.something.dev
ErrorLog "logs/something-error.log"
CustomLog "logs/something-access.log" common
<directory "D:/something/www">
Options Indexes FollowSymLinks
AllowOverride all
Order Allow,Deny
Allow from all
</directory>
</VirtualHost>
And in httpd.conf I have this
Listen *:80
Listen *:8080
And my hosts file is working and points both of these to 127.0.0.1
(The reason I want to do this is that when I code on my machine I use the http://something.dev, but I run Livereload Windows, and test my website simultaneously on an iPhone and iPad on the same local network, but without any access to iOS's equivalent of the hosts file. It also allows me to open up only a specific part of my server to the internet, through port forwarding on my router.)
I suppose you have solved the issue. Anyway is good to share some nice information on how to set up multiple Virtual Hosts in Wamp. This is working for me:
http://www.kristengrote.com/blog/articles/how-to-set-up-virtual-hosts-using-wamp
In my case I am working with ports 8080 and 8181. 8080 is redirecting to a subfolder under c:\wamp\www\myfolder, while 8181 is redirecting to root c:\wamp\www.
To make 8181 work I had to edit httpd-vhosts.conf, hosts (in \drivers\etc folder) and httpd.conf.
In httpd.conf my Apache is listening:
Listen 8080
Listen 8181
also I uncommented:
Include conf/extra/httpd-vhosts.conf
my root is pointing to
DocumentRoot "c:/wamp/www/myfolder"
root directory is configured as:
<Directory "c:/wamp/www">
Options Indexes FollowSymLinks
AllowOverride All
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
Allow from ::1
Allow from localhost
</Directory>
and added:
<VirtualHost *:8181>
DocumentRoot "C:\wamp\www"
ServerName name-of-my-fake-server
</VirtualHost>
in httpd-vhosts.conf I have set:
NameVirtualHost *:8181
in hosts (c:\windows\system32\drivers\etc) I have added:
127.0.0.1 localhost
127.0.0.1 name-of-my-fake-server #My Test Site
Doing that I have now two ports working 8080 and 8181: so 8080 points to directory "c:\wamp\www\myfolder" and the other port 8181 points to my root folder "c:\wamp\www\"
Using * as the hostname requires the use of NameVirtualHost:
NameVirtualHost *:80
NameVirtualHost *:8080
For those with MAMP, edit the httpd.conf
nano /Applications/MAMP/conf/apache/httpd.conf
Add Listen for each port
Listen 80
Listen 8080
And the ServerName too
ServerName localhost:80
ServerName localhost:8080
Once done that, edit httpd-vhosts.conf
nano /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
Define NameVirtualHost
NameVirtualHost *:80
NameVirtualHost *:8080
And the VirtualHost's
<VirtualHost *:80>
DocumentRoot "/Users/yourUser/path/project1"
ServerName project1.local
</VirtualHost>
<VirtualHost *:8080>
DocumentRoot "/Users/yourUser/path/project2"
ServerName project2.local
</VirtualHost>
Of course you need to have project1.local and project2.local in your hosts file
sudo nano /etc/hosts
And add
127.0.0.1 project1.local project2.local
Restart MAMP and you could access your vhost by
project1.local
project2.local:8080
project2 could be access also in your network or with a external IP (e.g to test from a different device like a mobile phone). Assuming your IP is 192.168.1.10
192.168.1.10:8080
The question is a little about it. But I assumed that it's near there and may be helpful for somebody.
Recently I met the problem when I need to get access to a few resources (debian repository, my website and phpmyadmin) by one external IP address and port.
After learning the problem I found technology named as reverse proxy. It like proxy but server is accepting all connection from many users and redirect to one target (your server).
I made simple Docker image and docker-compose file and push that to github.com/urpylka/docker-nginx-reverse-proxy and hub.docker.com.
Config file is very simple:
server {
listen 80;
server_name smirart.ru robotic.lol;
location / {
proxy_pass http://robotic.lol:1080/;
}
}
server {
listen 80;
server_name repo.smirart.ru;
location / {
proxy_pass http://8.8.8.8:2080/;
}
}
You can use that for few web-servers running by different IP.