Having trouble mapping Laravel public folder with a vhost on MAMP - laravel

I've got a Laravel project called "test" running on MAMP on my mac. I've uncommented the vhosts include line in httpd.conf and included this below in the vhosts file:
<VirtualHost *:80>
DocumentRoot "/Applications/MAMP/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Applications/MAMP/htdocs/test/public"
ServerName testapp.dev
</VirtualHost>
When I go to "testapp.dev" in my browser it just says the old
testapp.dev’s server IP address could not be found.
DNS_PROBE_FINISHED_NXDOMAIN
I'm not sure if I've missed something or what. Thanks in advance for your help! :)
(This is a repost but more clear)

So I ditched MAMP and used valet. I had some problems with that just going to localhost which was some random background apache server which I stopped and then everything worked! :)

if you are using windows edit C:\windows\system32\drivers\etc\hosts and if you are using unix edit /etc/hosts file and add this row at the end of file:
127.0.0.1 testapp.dev

Related

MAMP virtual hosts keep sending me to 'Index of /'

I'm using Mac so I'm working with MAMP.
In /MAMP/conf/apache/httpd.config I did uncomment the second line:
#Virtual hosts
Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
Then in /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf I made this:
<VirtualHost *:80>
DocumentRoot "/Applications/MAMP/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/User/xxxxx/Sites/mysite"
ServerName mysite
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Applications/MAMP/htdocs/laravel-blog/public"
ServerName laravel-blog.dev
</VirtualHost>
And my etc/hosts looks like this:
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
127.0.0.1 mysite
127.0.0.1 laravel-blog.dev
so when I go to mysite:8888/ this redirects me to a page called
'Index of /' with all the folders that I have in htdocs
but when I go to laravel-blog.dev:8888/ it says the page failed to open
so I changed it: instead of laravel-blog.dev , I just used laravel-blog, changed it also in my /etc/hosts and in httpd-vhosts.conf file
and now when I go to laravel-blog:8888/ it redirects me back to this "Index of /" page, even tho the DocumentRoot is set to /Applications/MAMP/htdocs/laravel-blog/public
I have searched for hours and tried a lot of things but still nothing seems to redirect me to the '/public' page of an application, only redirects me back to the 'Index' which is the htdocs.
Anyone an explanation for this? how i can get to '/public'?
And why laravel-blog.dev is not accepted but laravel-blog is?
what has that .dev to do with anything?
All of this is a bit above me, but I find when I am redirecting using MAMP (not sure about MAMP PRO) I have to call the file index.(extension) or it will show the index of the whole folder. When you call the file index.(extension), it will open that file.
Hope this helps,
Nat

How to Vagrant scotchbox subdomain virtualhost

I have installed vagrant and scotchbox from scotch.io to develop locally and is running like a charm.
Now I need use the subdomains as variable, and i have googled about, but still no working.
I have changed the hosts file and added
192.168.33.10 scotch.box
Is needed add a line for wildcard subdomain hosts?
Also I have added the next line to my conf file
<VirtualHost *:80>
DocumentRoot /var/www/public
ServerName tenant.scotch.box
ServerAlias *.scotch.box
</VirtualHost>
Sorry for my broken english.
Just add
192.168.33.10 tenant.scotch.box
to hosts.
I had the same problem a couple of months ago. On the hosting OS you have to edit the hosts file.
On Windows
C:\Windows\System32\drivers\etc\hosts
On linux
sudo nano /etc/hosts
you have then to add the ip-address of your scotch box with the desired host name
192.168.33.10 tenant.scotch.box
You can even add multiple lines to your hosts file if you have multiple subdomains or you are developing multiple web applications on the same scotch box. For example :
192.168.33.10 sub1.scotch.box
192.168.33.10 sub2.scotch.box
192.168.33.10 sub3.scotch.box
BUT don't forget to edit the virtual host file inside Scotch Box which is located /etc/apache2/sites-available/YOUR_CONFIG.conf
You will need a <VirtualHost *:80> </VirtualHost> for each sub domain. Example:
<VirtualHost *:80>
DocumentRoot /var/www/public
ServerName sub1.scotch.box
ServerAlias *.scotch.box
</VirtualHost>

Serving several host/domain names on local machine

I have a local PHP server on a Windows machine and the trouble I am having is that within the main root 127.0.0.1/localhost I would like to have several folders/sites that I can call on.
At present I can do localhost/siteA or localhost/siteB with no problem, but what I would like to do is to assign these locations test domain names:
EG: localhost/siteA would be sitea.dev, localhost/siteB would be siteb.dev
Not a problem as I have set up one on the host file and vhost config files.
mysites.dev which is linked to the root/localhost. So I can use it as above
mysites.dev/siteA and mysites.dev/siteB
But I would like to give each of these sites its own vhost name as mentioned above. So I have added the following:
Hosts File
127.0.0.1 mysites.dev
127.0.0.1 sitea.dev
vhost file
<VirtualHost *:80>
DocumentRoot "C:\Websites\"
ServerName mysites.dev
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:\Websites\sitea\"
ServerName sitea.dev
</VirtualHost>
The trouble is that whichever one I call they all seem to simply load the first one, or at least it seems like that, but without the vhost details they all still go to the root so it looks like the host file is directing them to 127.0.0.1 and that it the vhost file seems to be ignored.
SO what am I missing in order to hook up mty individual local sites?
SOLVED: See my answer will mark it as the correct one when i can in a few days.
Your vhosts are both trying to catch anything that comes in on port 80: <VirtualHost *:80>.
You need to specify the vhost name to point to a particular folder:
<VirtualHost sitea.dev:80>
DocumentRoot "C:\Websites\sitea\"
ServerName sitea.dev
</VirtualHost>
<VirtualHost siteb.dev:80>
DocumentRoot "C:\Websites\siteb\"
ServerName sitea.dev
</VirtualHost>
You can find more info on this in the Apache docs: http://httpd.apache.org/docs/2.2/vhosts/examples.html
Well i do feel stupid. After a long look i then noticed that in the config file it was not calling in the vhost file as i placed them in the main httpd.conf and it worked.
So i had to uncomment the following within the httpd.conf file:
# Virtual hosts
Include conf/extra/httpd-vhosts.conf

Pulling my hair out with mod_rewrite and MAMP

I'm using MAMP and I can't get mod_rewrites to work.
After lots of playing with numerous http.conf files and then finally looked at my php_info, there is no mod_rewrite exstension installed.
I opened up the php.ini files in Applications > MAMP > conf > php5.2 & php5.3 and looked at the exstensions and there was no mod_rewrite.so. All I can see is:
extension=imap.so
extension=yaz.so
extension=mcrypt.so
extension=gettext.so
extension=pgsql.so
extension=pdo_pgsql.so
extension=pdo_mysql.so
I added it expecting a stroke of luck - but no joy!
I had the same problem and hopefully this will solve it for you.
I added my site in my host file so instead of going through the locahost/..... It had its own url that I redirected to 127.0.0.1. i.e. my host file looked like this
127.0.0.1 mysite.local
I then set up a virtual host in MAMP. You will find the vhosts.conf file in /Applications/MAMP/conf/apache
My host file looks like this
NameVirtualHost *
<VirtualHost *>
DocumentRoot "/Applications/MAMP/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *>
DocumentRoot "/Applications/MAMP/htdocs/mysite-folder"
ServerName mysite.local
</VirtualHost>
Hope that helps :D

Apache 2.2 localhost VirtualHosts problems

I am trying to setup my dev machine with virtual hosts so I can access my development projects with a simple url, like http:// project.dev/ rather that a whole http:// 127.0.0.1/dev/path/to/root/of/project/ type of url.
Now, I'm aware there are many tutorials and questions already answered about this, but after trying many of them, I feel like I'm running in circles here.
The problem is simple: after setting up my hosts file and my virtual hosts, any attempt to access a virtual hosts irremediably displays the content of my server DocumentRoot.
my hosts file:
127.0.0.1 localhost
127.0.0.1 mydomain.dev
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
my httpd-vhosts.conf
NameVirtualHost *:80
<VirtualHost *:80>
ServerName localhost
DocumentRoot /Users/pilot/Sites/
</Virtualhost>
<VirtualHost *:80>
ServerName mydomain.dev
DocumentRoot /Users/pilot/Sites/devel/vytamin/dev/
</VirtualHost>
I precise that the httpd-vhosts.conf file IS loaded in my httpd.conf and I do get a warning if I point the virtual host document root to a wrong folder.
I made a try setting the localhost virtual host to the following, without any success.
<VirtualHost *:80>
ServerName localhost
DocumentRoot /Users/pilot/Sites/devel
</Virtualhost>
The following URLS all display the DocumentRoot of my server defined in my httpd.conf file, and seem to ignore the DocumentRoot defined in my VirtualHosts.
http:// 127.0.0.1/
http:// localhost/
http:// mydomain.dev/
I'm running Apache2.2 on Mac OSX 10.5 Leopard, but not the one shipped with mac os. I compiled my own under /usr/local/apache2 and web sharing IS disabled
I can't see anything wrong with my set up so I hope the community will!
Thanks for your help!
Ok, I found the problem!
The configuration above is perfectly fine, it was just that my apache was not restarting properly.
Neither apache_ctl graceful or apache_ctl restart was terminating all httpd processes I have running, therefore failing to reload properly the changes in my configuration files.
Once I killed the remaining processes and really restarted apache, it worked...
Solved, but I feel dumb to have found that!
Now I have a daemon situation to solve!

Resources