This post was initially written in February 2013. It contained some errors, i.e, the name mysite.dev was written as mysite.local at some places. (refer comment threads below)
I have corrected this post in July 2013.
I have also written a simpler approach to do this on another post, http://setup-steps.blogspot.com/2013/07/laravel-3-development-environment.html
Happy Coding!
-----
1) Download Laravel package from
2) Extract the Laravel package content to XAMPP htdocs folder. Rename the package folder as myfirst.dev.
3) Run XAMPP Control Panel. Start Apache and MySQL.
4) Test the url:
4a) http://localhost (the index.php file at this path will redirect to http://localhost/xampp)
4b) Type http://localhost/myfirst.dev/public (the Laravel public folder shall appear)
5) Add new domain name to Windows host file.
5a) Run Notepad as Administrator.
5b) Open c:\windows\system32\drivers\etc\hosts
5c) Edit/Add Entry to look like below (be careful to add a space in between the texts)
127.0.0.1 localhost myfirst.dev
5d) Save
6) Move myfirst.dev folder to a new location.
a) Cut the folder [XAMPP_HOME]/htdocs/myfirst.dev
b) Paste it to [XAMPP_HOME]/sites/myfirst.dev
7) We will add a Virtual Host setting so that we can point the URL http://myfirst.dev to the new location in Step 6.
7a) open [XAMPP_Home]\apache\conf\extra\httpd-vhosts
7b) look for the followings:
#
# Use name-based virtual hosting.
#
# NameVirtualHost *:80
7c) Change to the followings (the last line is not commented):
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
7d) At the end of the file, add the followings:
NameVirtualHost *
<VirtualHost *>
DocumentRoot "C:/Z/Dev/xampp/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *>
DocumentRoot "C:/Z/Dev/xampp/sites/myfirst.dev/public"
ServerName
</VirtualHost>
8) Restart Apache. You may get XAMPP new security concept. The httpd-xampp.conf has been configured to be very restrictive in terms of path/folder access.
9) You can turn-off the restriction.
9a) Open [XAMP_Home]/apache/conf/httpd-xampp.conf
9b) Look for the followings:
#
# Each directory to which Apache has access can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its subdirectories).
#
# First, we configure the "default" to be a very restrictive set of
# features.
#
<Directory />
AllowOverride none
Require all denied
</Directory>
9c) Change the highlighted codes above into:
#
# Each directory to which Apache has access can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its subdirectories).
#
# First, we configure the "default" to be a very restrictive set of
# features.
#
<Directory />
# "default" restriction is turned off
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
10) Restart Apache. Go to http://myfirst.dev/
Notice the URL path and Physical path.
Just wondering where this came from?
ReplyDelete6a) http://mylaravel.local/mylaravel/public (it should display the same page as step 4b above)
What is mylaravel.local ??
What I've done was ...
DeleteSteps 1 - 4 are OK.
Step 5 - Write this at the end of the host file: 127.0.0.1 localhost mylaravel.local
Step 6 - Test the url http://mylaravel.local/mylaravel/public (it should display the same page as step 4b above)
Step 7 - Open the file httpd-vhosts.conf and write this code at the end.
NameVirtualHost *:80
NameVirtualHost *
<VirtualHost *>
DocumentRoot "C:\Users\Amer\xampp\"
ServerName localhost
</VirtualHost>
<VirtualHost *>
DocumentRoot "C:\Amer\xampp\htdocs\laravel\public"
ServerName mylaravel.local
</VirtualHost>
8) Restart Apache. Go to http://myfirst.dev/
Regards.
Sorry. There is a mistake. I will update this page soon.
ReplyDeleteA few mistakes here (I guess you had mylaravel.local first and then decided to name it myfirst.dev instead?) :
ReplyDeleteIn 5c you wrote: Edit/Add Entry to look like below (be careful to add a space in between the texts)
127.0.0.1 localhost myfirst.dev
As shown in the picture. But then in 6:
6) Test the url:
6a) http://mylaravel.local/mylaravel/public (it should display the same page as step 4b above)
The url should be http://myfirst.dev/myfirst.dev/public (the first myfirst.dev is the new name for the link that has been added in the hosts file, the second myfirst.dev is the name of the laravel folder)
Then again in 7d:
NameVirtualHost *
DocumentRoot "C:/Z/Dev/xampp/htdocs"
ServerName localhost
DocumentRoot "C:/Z/Dev/xampp/sites/myfirst.dev/public"
ServerName mylaravel.local
there is a mistake in the second ServerName. This should be myfirst.dev too, as you can see in the picture below your code.
I didn't test this but hope it works. Thanks for the how to anyway!
http://hostinglaravel.com/planes.php
ReplyDeleteHosting for developers and programmers. Pay only for what you need, you can migrate to a more advanced plan at any time, CMS (Wordpress, Joomla, Drupal ...) and Framework (Laravel, Django, Ruby on rails). Hosting high performance SSD for your applications and Web pages that load 300% faster !!!
my laravel virtual host not working error 404 page not found anyone faced this issue please help me?
ReplyDeleteEnhance your web development capabilities with the help of dedicated Laravel developers at Connect Infosoft Technologies. Unlock the full potential of your projects and achieve optimal results. Hire Laravel Developers in India
ReplyDelete