Laravel 5.2 site on localhost/Wamp - laravel-5

I am trying to learn Laravel.
I created a project on c:/sites where I develop all my sites. I called it larabasic.dev
I cannot open the site in my browser, it keeps switching to www.larabasic.dev and tells me server not found.
I set up a virtual host like I did to all my other sites that works well.
I tried:
1. Changing server.php to index.php and copied the public/htaccess file to the root folder
2. Going to http://larabasic.dev/public
3. Going to http://larabasic.dev/public/index.php
4. Changing vhosts file to:
<VirtualHost *:80>
ServerName larabasic.dev
ServerAlias larabasic.dev
DocumentRoot "c:/sites/larabasic.dev/public"
<directory "c:/sites/larabasic.dev/public">
Options Indexes FollowSymLinks
AllowOverride all
Require all granted
</directory>
</VirtualHost>
Instead of:
<VirtualHost *:80>
ServerName larabasic.dev
ServerAlias larabasic.dev
DocumentRoot "c:/sites/larabasic.dev"
<directory "c:/sites/larabasic.dev">
Options Indexes FollowSymLinks
AllowOverride all
Require all granted
</directory>
</VirtualHost>
My hosts file has these 2 entries:
127.0.0.1 larabasic.dev And
::1 larabasic.dev
Nothing helps. Again, any other sites I have developed with plain php work fine.
What am I missing?
Thank you

I've encountered the same problem and I've fixed this by giving 127.0.0.2 to my laravel application.
First, in the hosts file, you need to redirect larabasic.dev to 127.0.0.2:
127.0.0.2 larabasic.dev
Second, you need to bind the virtual host to that IP:
<VirtualHost 127.0.0.2:80>
DocumentRoot "C:/sites/larabasic.dev/public"
ServerAdmin admin#localhost
ServerName larabasic.dev
ServerAlias www.larabasic.dev
<Directory "C:/sites/larabasic.dev/public">
AllowOverride All
Options Indexes FollowSymLinks
Require local
# if you want access from other pc's on your local network
#Require ip 192.168.1
# Only if you want the world to see your site
#Require all granted
</Directory>
</VirtualHost>
This is my working configuration on my local machine.

Related

xampp and virtual hosts not working properly

my virtual host setup looks like this:
<VirtualHost *:8080>
ServerName localhost
DocumentRoot "D:\xampp\htdocs"
<Directory "D:\xampp\htdocs">
DirectoryIndex index.php
</Directory>
</VirtualHost>
<VirtualHost *:8080>
ServerName mysite.site
DocumentRoot "D:\xampp\htdocs\mysite"
SetEnv APPLICATION_ENV "development"
<Directory "D:\xampp\htdocs\mysite\public">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
and the hosts file:
127.0.0.1 localhost
127.0.0.1 mysite.site
but it actually doens't work. I have to go through localhost/mysite/public to make it work. Why? Instead of getting my site it loads my localhost default site which is xampp's htdocs folder.
EDIT:
Just wanted to add that I have Include conf/extra/httpd-vhosts.conf in httpd.conf already.
Ok, i finally got this. Looks like my port was incorrect. I checked what port is used in httpd.conf under ServerName localhost:80. Then I fixed my virtual host setup:
<VirtualHost *:80>
ServerName mysite.site
DocumentRoot "D:/xampp/htdocs/mysite/public"
SetEnv APPLICATION_ENV "development"
<Directory "D:/xampp\htdocs/mysite/public/">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Now it works. :)

XAMPP VirtualHosts Access From Mobile Device

Could you please help me to access XAMPP localhost sites from a mobile device (either from home network or from internet)
I am using multiple virtual hosts to access all sites using a short link for each. Please see the configuration of virtual hosts below:
<VirtualHost *:80>
ServerName mysite
ServerAlias mysite
DocumentRoot "F:/Drive/Dev/mysite"
<Directory "F:/Drive/Dev/mysite">
AllowOverride All
Options Indexes FollowSymLinks Includes ExecCGI
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName mysite2
ServerAlias mysite2
DocumentRoot "F:/Drive/Dev/mysite2"
<Directory "F:/Drive/Dev/mysite2">
AllowOverride All
Options Indexes FollowSymLinks Includes ExecCGI
Require all granted
</Directory>
</VirtualHost>
and the host file:
127.0.0.1 mysite
127.0.0.1 mysite2
I have tried several suggestion found here, but non of them helped...
Thanks in advance.
ngrok creates a secure public URL (https://yourapp.ngrok.io) to a local webserver on your machine
test mobile apps against a development backend running on your machine.
https://ngrok.com/

MAC OSX: Cannot run multiple local domains

i am trying to add another local domain to my mac osx:
No matter what i do when visiting say 'domainnumber2.dev' it always displays the first host in my list.
If i swop them around in my httpd-vhosts file then i get the domainnumber2.dev site.
How can i run multiple localhost site on my mac.
I have a simple set up as below:
<VirtualHost *:80>
ServerName mydomain.dev
ServerAlias mydomain.dev
DocumentRoot "/Users/UserName/Sites/mydomain/"
</VirtualHost>
<VirtualHost *:80>
ServerName mydomainTwo.dev
ServerAlias mydomainTwo.dev
DocumentRoot "/Users/UserName/Sites/mydomainTwo/"
</VirtualHost>
I have also had the more details set up adding the below for both
<Directory "/Users/UserName/Sites/mydomain/">
DirectoryIndex index.php
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>
In my hosts file i have:
##
# 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
127.0.0.1 mydomain.dev
127.0.0.1 mydomainTwo.dev
which ever VirtualHost is first is the site that is served up
I stumbled across this same problem...
In your httpd-vhosts.conf file (/private/etc/apache2/extra/httpd-vhosts.conf after showing hidden files) add the following for each domain...
<VirtualHost *:80>
ServerName mysubdomain.dev
CustomLog "/root/to/site/logs/mysubdomain.dev-access_log" combined
ErrorLog "/root/to/site/logs/mysubdomain.dev-error_log"
DocumentRoot "/root/to/site/mysubdomain.co.uk"
<Directory "/root/to/site/mysubdomain.co.uk">
DirectoryIndex index.php
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>
</VirtualHost>
Then restart apache. Everything else you have seems to be the same as my setup.
Make sure you have the correct permissions to be able to write the log files etc too.

Wampserver can't get Named Virtual hosts to work

Using wampserver I can't get named virtual hosts to work. I've edited the httpd.conf to use the
Include conf/extra/httpd-vhosts.conf
I've added the domain to my system32/driver/etc/hosts file. I've edited the httpd-vhosts.conf file and everything seems to work except now localhost is unavailable. The domain I setup (test123.com) works fine, hitting 127.0.0.1 works fine, but hitting localhost hangs. There is nothing relevant in the error logs and no mention of it in the access logs. Here is how I have edited httpd-vhosts.conf:
#
# Virtual Hosts
#
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
# Tells Apache to serve the default WAMP Server page to "localhost"
<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:/wamp/www"
<Directory "C:/wamp/www">
Options FollowSymLinks
AllowOverride all
Order allow,deny
Allow from all
</Directory>
DirectoryIndex index.php
</VirtualHost>
<VirtualHost *:80>
ServerName test123.com
ServerAlias *.test123
# Folder where the files live
DocumentRoot "D:/Projects/html/test123"
# A few helpful settings...
<Directory "D:/Projects/html/test123">
Options FollowSymLinks
AllowOverride all
Order allow,deny
Allow from all
</Directory>
DirectoryIndex index.php
</VirtualHost>
What am I doing wrong?
Finally figured it out. In httpd.conf I had to change
Listen 80
to
Listen *:80

Apache gives me 403 Access Forbidden when DocumentRoot points to two different drives

I am getting an 403 access forbidden when attempting to open a page under a vhost where the document root is sitting on a different drive than where apache is sitting. I installed using the apachefriends release. This is my httpd-vhosts.conf file:
NameVirtualHost 127.0.0.1
<VirtualHost 127.0.0.1>
ServerName foo.localhost
DocumentRoot "C:/xampp/htdocs/foo/public"
</VirtualHost>
<VirtualHost 127.0.0.1>
ServerName bar.localhost
DocumentRoot "F:/bar/public"
</VirtualHost>
When opening bar.localhost in my browser, Apache is giving me 403 Access Forbidden. I tried setting lots of different access rights, even full rights to everyone, but nothing I tried helped.
Edit: Thanks! For future reference, add 'Options indexes' within to show directory indexes.
You did not need
Options Indexes FollowSymLinks MultiViews Includes ExecCGI
AllowOverride All
Order Allow,Deny
Allow from all
Require all granted
the only thing what you need is...
Require all granted
...inside the directory section.
See Apache 2.4 upgrading side:
http://httpd.apache.org/docs/2.4/upgrading.html
Somewhere, you need to tell Apache that people are allowed to see contents of this directory.
<Directory "F:/bar/public">
Order Allow,Deny
Allow from All
# Any other directory-specific stuff
</Directory>
More info
For Apache 2.4.2: I was getting 403: Forbidden continuously when I was trying to access WAMP on my Windows 7 desktop from my iPhone on WiFi. On one blog, I found the solution - add Require all granted after Allow all in the <Directory> section. So this is how my <Directory> section looks like inside <VirtualHost>
<Directory "C:/wamp/www">
Options Indexes FollowSymLinks MultiViews Includes ExecCGI
AllowOverride All
Order Allow,Deny
Allow from all
Require all granted
</Directory>
I have fixed it with removing below code from
C:\wamp\bin\apache\apache2.4.9\conf\extra\httpd-vhosts.conf file
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host.example.com
DocumentRoot "c:/Apache24/docs/dummy-host.example.com"
ServerName dummy-host.example.com
ServerAlias www.dummy-host.example.com
ErrorLog "logs/dummy-host.example.com-error.log"
CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host2.example.com
DocumentRoot "c:/Apache24/docs/dummy-host2.example.com"
ServerName dummy-host2.example.com
ErrorLog "logs/dummy-host2.example.com-error.log"
CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>
And added
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot "c:/wamp/www"
ServerName localhost
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" common
</VirtualHost>
And it has worked like charm
Solved 403: Forbidden when visiting localhost. Using ports 80,443,3308 (the later to handle conflict with MySQL Server installation)
Windows 10, XAMPP 7.4.1, Apache 2.4.x My web files are in a separate folder.
httpd.conf - look for these lines and set it up where you have your files, mine is web folder.
DocumentRoot "C:/web"
<Directory "C:/web">
Changed these 2 lines.
<VirtualHost *:80>
ServerAdmin webmaster#localhost.com
DocumentRoot "C:/web/project1"
ServerName project1.localhost
<Directory "C:/web/project1">
Order allow,deny
allow from all
</Directory>
</VirtualHost>
to this
<VirtualHost *:80>
ServerAdmin webmaster#localhost.com
DocumentRoot "C:/web/project1"
ServerName project1.localhost
<Directory "C:/web/project1">
Require all granted
</Directory>
</VirtualHost>
Add your details in your hosts file
C:\Windows\System32\drivers\etc\hosts file
127.0.0.1 localhost
127.0.0.1 project1.localhost
Stop start XAMPP, and click Apache admin (or localhost) and the wonderful XAMPP dashboard now displays! And visit your project at project1.localhost

Resources