MAMP vhosts not working - apache

I am trying to add a vhost for a specific project located within my MAMP htdocs folder.
Steps I did:
Open /Applications/MAMP/htdocs/conf/apache/httpd.conf and uncomment the Include /Applications/MAMP/htdocs/conf/apache/extra/httpd-vhosts.conf line.
Open /Applications/MAMP/htdocs/conf/apache/extra/httpd-vhosts.conf and removed both demo vhosts, and added the following:
<VirtualHost *:80>
DocumentRoot /Applications/MAMP/htdocs
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Users/arko/Sites/mysite"
ServerName mysite
</VirtualHost>
Edit hosts file: sudo vim /etc/hosts and added this line:
127.0.0.1 mysite
My hosts file now looks like this:
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
# MAMP Virtual Hosts
127.0.0.1 mysite
Then I opened up my MAMP and restarted the servers (stop servers, then started servers).
Whenever I go to http://mysite/ I just get the contents of /Applications/MAMP/htdocs (a ugly list of all my folders in there, since I have no index file in my htdocs folder.
So it seems like it is ignoring my vhost, and just using my hosts file to route http://mysite/ to 127.0.0.1 (localhost)
Update
When I go to http://mysite/ I get this error in my apache error log:
[Wed Mar 16 11:04:39 2016] [error] [client 127.0.0.1] client denied by server configuration: /Applications/MAMP/htdocs/.DS_Store

Take a look at this. I think apatch is hosting the .DS_STORE file.
link

Related

Virtual host will NOT work in MAMP but works on localhost:8888

Created a new Laravel project in htdocs in MAMP. Followed all the steps, added virtual hosts, changed conf file, etc/hosts, restarted mamp and my pc several times but I just can't get my virtual host to run.
however, when I am in the MAMP Dashboard I can navigate to my website -> website -> public and the default Laravel boilerplate page appears.
Has anyone had this issues with MAMP before? I gave up with XAMPP and Valet so it's my last chance here..
Specs
High Sierra 10.13.5 on 2015 MBP,
Composer version 1.6.5,
php 7.2.7
httpd.conf
# Virtual hosts
Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
httpd-vhosts
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /Applications/MAMP/htdocs
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "Applications/MAMP/htdocs/website/public"
ServerName website.dev
</VirtualHost>
etc/hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
#255.255.255.255 broadcasthost
#::1 localhost
127.0.0.1 website.dev
website.dev is technically a public url, so the browser is looking for it on the internet I guess. I was trapped once in this dreadful situation. changing the name to something like website.local should solve your issue. It did for me.

Can't get wampserver 2.5 accessible from a remote machine

I desesperate to get wamp working!
I've installed wampserver 2.5 on my win7 64bits machine.
In the httdp.conf file, I just commented out the line regarding vhosts:
Include conf/extra/httpd-vhosts.conf
The httpd-vhosts.conf contains:
<VirtualHost *:80>
DocumentRoot "C:/Users/Alain/Dropbox/Website/exemples/Grafikart/Petsy_alain.dev"
ServerName petsy.dev
ServerAlias www.petsy.dev
<Directory "C:/Users/Alain/Dropbox/Website/exemples/Grafikart/Petsy_alain.dev">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
<RequireAny>
Require local
Require ip 192.168.1
</RequireAny>
</Directory>
</VirtualHost>
(I also tried Require all granted)
I first installed wampserver 2.5 64 bits.
I was able, from my local machine to access http://petsy.dev
But when I tried to access to http://192.168.1.16/petsy.dev from an other machine of my LAN, I was always getting a 403 error (Forbidden):
[Thu Dec 04 14:43:08.519329 2014] [authz_core:error] [pid 11088:tid 776] [client 192.168.1.15:39975] AH01630: client denied by server configuration: C:/Users/Alain/Dropbox/Website/exemples/Grafikart/Petsy_alain.dev
[Thu Dec 04 14:43:08.635335 2014] [authz_core:error] [pid 11088:tid 776] [client 192.168.1.15:39975] AH01630: client denied by server configuration: C:/wamp/www/favicon.ico
I got access remotely to petsy.dev when I added in the remote PC hosts file the line:
192.168.1.16 petsy.dev
In that case, I was able, on my remote machine, to access to the server using 'http://petsy.dev'.
First I don't understand what does it change on the server side and secondly I cannot be satisfied by this solution as I cannot use it on a smartphone.
As I wasn't able to find an answer anywhere, I finally tried to install wampserver 2.5 32 bits!
Same problem! But with a different error:
I can ALWAYS access to my petsy.dev website locally but now, when I try to access it remotely, I get a 404 error (not Found) !!!
Here are the access logs of apache
From my local machine:
xxxx::7d1a:xxxx:9672:xxxx - - [05/Dec/2014:19:22:25 +0100] "GET / HTTP/1.1" 200 40438
From my remote machine:
192.168.1.15 - - [05/Dec/2014:19:22:30 +0100] "GET /petsy.dev/ HTTP/1.1" 404 295
httpd -T answers syntax OK
httpd -S says:
VirtualHost configuration:
*:80 is a NameVirtualHost
default server localhost (C:/wamp/bin/apache/apache2.4.9/conf/extra/httpd-vhosts.conf:23)
port 80 namevhost localhost (C:/wamp/bin/apache/apache2.4.9/conf/extra/httpd-vhosts.conf:23)
alias localhost
port 80 namevhost petsy.dev (C:/wamp/bin/apache/apache2.4.9/conf/extra/httpd-vhosts.conf:34)
alias www.petsy.dev
ServerRoot: "C:/wamp/bin/apache/apache2.4.9"
Main DocumentRoot: "C:/wamp/www/"
Main ErrorLog: "C:/wamp/logs/apache_error.log"
Mutex rewrite-map: using_defaults
Mutex authdigest-client: using_defaults
Mutex default: dir="C:/wamp/bin/apache/apache2.4.9/logs/" mechanism=default
Mutex authdigest-opaque: using_defaults
PidFile: "C:/wamp/bin/apache/apache2.4.9/logs/httpd.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
Define: APACHE24=Apache2.4
Please, please which stupid error did I make ????
You dont need the <RequireAny> so just try this
<VirtualHost *:80>
DocumentRoot "C:/Users/Alain/Dropbox/Website/exemples/Grafikart/Petsy_alain.dev"
ServerName petsy.dev
ServerAlias www.petsy.dev
<Directory "C:/Users/Alain/Dropbox/Website/exemples/Grafikart/Petsy_alain.dev">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require local
Require ip 192.168.1
</Directory>
</VirtualHost>
Additional Info
I dont think you understand what is happening when you create Virtual Hosts.
Basically when Apache see's it has one or more Virtual Hosts configured, you are teling Apache that it is the server for more than one domain name. The important part in that sentence is more than one domain name.
This causes Apache to examine the domain name on each incoming connection. It will then match the domain name to one of its Virtual Hosts definitions and change the DocumentRoot and potentially other parameters to those set in that Virtual Host.
So the important thing is that you use a matching domain name in the browser of the other PC you are using to get to Apache with a domain name it knows about.
This would normally be done by a DNS Server on the real internet, but while you are inside your own local network i.e. safely behind your router you have to use another method. You could setup your own local DNS Server, but thats quite complicated.
So the simple solution is to use the HOSTS file on the other PC's in your network.
So on the other PC (not the PC running WAMPServer), edit the \windows\system32\drivers\etc\hosts file and add this
192.168.1.16 petsy.dev
Then either reboot or do this to reload the windows dnscache
Start a command windows using "Run as Administrator" and execute these 2 commands to reload the cache
net stop dnscache
net start dnscache
Now you can use the correct domain name from the browser on the non-wampserver pc like so
http://petsy.dev
And the browser will find that petsy.dev lives on ip address 192.168.1.16. When the connection is made with 192.168.1.16 it will be using the corretc domain name i.e. petsy.dev and apache will find the virtual host and set everything as per the VH config and server pages from the correct folder.
here is a great tutorial
Project Links do not work on Wamp Server
Answer #1 worked for me
I'm running windows 7 64 bit
I have wampserver2.5 (64 bit) installed on a hd assigned to letter A
All my dev sites are located on A:\websites
In A:\wamp\bin\apache\apache2.4.9\conf\extra\httpd-vhosts.conf I have this
<VirtualHost *:80>
DocumentRoot "A:/websites"
ServerName localhost
ServerAlias localhost
<Directory "A:/websites">
AllowOverride All
Require local
</Directory>
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost.log" common
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "A:/websites/example.dev/www
ServerName example.dev
ServerAlias www.example.dev
<Directory "A:/websites/example.dev/www>
AllowOverride All
Require local
Require ip 192.168.10
</Directory>
</VirtualHost>
On the computer running wamp I adjusted the host file as follows
127.0.0.1 example.dev
::1 example.dev
On the local remote computer I've added an entry to the host file as
192.168.10.100 example.dev (this is the ip address of the computer running wamp)
next step is to clear your dns cache
open a terminal on the windows box that's not the web server
type "net stop dnscache"
type "net start dnscache"
Open a browser and point it to example.dev and it works
hope this helps

VirtualHosts loading blank pages in Mavericks

I'm having issues loading VirtualHosts I've setup on my iMac, all that they appear to be returning are blank pages. I've tried multiple browsers, flushed my DNS cache, cleared browser cache etc but nothing appears to be fixing this.
Here is what my /etc/apache2/httpd-vhosts/conf file looks like:
NameVirtualHost *:80
<Directory "/Users/chris/Sites/test/">
Allow From All
AllowOverride All
</Directory>
<VirtualHost *:80>
ServerName "test.dev"
ServerAlias "test.dev.*.*.*.*.xip.io"
DocumentRoot "/Users/chris/Sites/test"
</VirtualHost>
Here is what my /etc/hosts file looks like:
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
# VHX START
127.0.0.1 test.dev
fe80::1%lo0 test.dev
# VHX STOP
In my /private/etc/apache2/httpd.conf file I've made sure to uncomment the following line:
Include /private/etc/apache2/extra/httpd-vhosts.conf
I'm using VirtualHostX to manage all of this but I've even resorted to deleting everything in these files and starting again following guides online – that didn't work either.
I've tried to tail the apache access log and whenever I try to access http://test.dev nothing shows up in that file or the apache error log – it's as though my machine has absolutely no idea that URL exists even though I believe everything is setup correctly.
Any ideas on how I can fix this?
Thanks,
Chris

Ruby on Rails - etc/hosts config file

This is what I have in my "etc/hosts" file:
127.0.0.1 localhost
127.0.1.1 gotqn-System-Product-Name
127.0.0.1 depot.yourhost.com
and this is what I have added in the apache2.conf file:
<VirtualHost *:80>
ServerName depot.yourhost.com
DocumentRoot "/home/gotqn/Aptana Projects/depot/public/"
<Directory "/home/gotqn/Aptana Projects/depot/public">
AllowOverride all
Options -MultiViews
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
When I type http://localhost/ my browser lists all my files in the "var\www" folder and when I type http://depot.yourhost.com/ it displays the following error:
We're sorry, but something went wrong.
I have checked the production.log file of my rails applications and it says:
Connecting to database specified by database.yml
Started GET "/" for 127.0.0.1 at 2013-01-13 20:32:41 +0200 Processing
by StoreController#index as HTML Completed 500 Internal Server Error
in 3ms
ActiveRecord::StatementInvalid (Could not find table 'carts'):
app/controllers/application_controller.rb:46:in rescue in
current_cart' app/controllers/application_controller.rb:44:in
current_cart' app/controllers/store_controller.rb:11:in `index'
I suppose that there is something wrong with my database configuration as the table exists but it is not found.
Anyway, my questions is how the hosts file knew that "depot.yourhost.com" means to open the rails applications and "localhost" do list my "var\www" folder - I have thought that RoR is using port 3000.
Why there is no conflict for port 80?
Rails applications run under port 3000 when running with the lightweight Webrick server. Since you are running Apache with mod_passenger, the application will be available at port 80 according to your Apache configuration.
The hosts file contains an entry 127.0.0.1 depot.yourhost.com which directs that domain name to your local adapter 127.0.0.1. The hosts file should always be checked before a nameserver needs to be consulted to retrieve a name's address.
Next, your Apache configuration includes a VirtualHost which is listening on all network adapters due to the * in
<VirtualHost *:80>
Your Apache configuration must be setup to use name-based virtual hosting, after which the ServerName variable is matched against the HTTP_HOST request header which was supplied by your request to depot.yourhost.com.
Therefore, you can have as many VirtualHosts as needed all using port 80 on the same IP address, and Apache will decide which to route the request to based on the HTTP_HOST header.
Finally, mod_passenger will detect if an application is a Ruby on Rails application by inspecting the directory contents around the DocumentRoot which you have specified in the VirtualHost configuration. If it finds the public directory as its DocumentRoot and a RoR application at a level higher, Passenger will attempt to start the Rails app.
Now, as to why you are getting a directory listing from localhost... Elsewhere in your Apache configuration you must have a VirtualHost which matches the ServerName localhost and sets its DocumentRoot to /vart/www.
<VirtualHost *:80>
ServerName localhost
# or...
ServerAlias localhost
</VirtualHost>
If you are seeing the contents of the directory listed out rather than a 403 Forbidden (absent an index file like index.html), it is because the Apache server config or VirtualHost config does not include the directive:
Options -Indexes
Add that in the global httpd.conf to prevent listing directories server-wide.

Virtual host on Apache 2 isn't working as excpected

I'm trying to set a development server on my OSX 10.8.2. The deployed site name is mattat.org.il so I'd like to set it to mattat.dev.
These are the steps I followed:
Uncommented the include for virtual hosts, in httpd.conf:
Include /private/etc/apache2/extra/httpd-vhosts.conf
added a virtual host to httpd-hosts.conf:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "/Users/matanya/Sites/matat"
ServerName mattat.dev
</VirtualHost>`
Added the server name to etc/hosts:
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost.
fe80::1%lo0 localhost
127.0.0.1 mattat.dev
Restarted Apache.
Now, when i go to localhost it takes me to the directory I've set for the virtual host, instead of taking me the the root directory (i.e Sites).
When I go to mattat.dev it is unidentified as a valid url, and simply interpreted as a Google search.
What am I missing?
.dev is not a valid TLD, your browser is not treating it as a URL. http://mattat.dev should work.
For not recognising localhost, check that you have a default directory in your httpd.conf for Apache to fall back on if it cannot find a virtual host, or alternatively add a second Virtual host for localhost.
<Directory "/Users/matanya/Sites/">
Options Indexes
Order allow,deny
Allow from all
</Directory>