I use Windows 10 and XAMPP for local development. I want to create project on laravel 5.5 and access it in browser by project.dev
I add next lines to httpd-vhosts.conf file
<VirtualHost project.dev:80>
DocumentRoot "C:\xampp7\htdocs\server\laravel\project_name\public"
ServerAdmin project.dev
<Directory "C:\xampp7\htdocs\server\laravel\project_name">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
and
127.0.0.1 project.dev
to hosts file. But it does not work (only for laravel),I get 400 error.
This works with all the rest my local projects except those ones on laravel.
I have no problem with access to this project by
http://localhost/server/laravel/project_name/public
What other settings do I have to make to access laravel 5.5 project like project.dev?
1- change VirtualHost project.dev:80 to VirtualHost *:80
2- change ServerAdmin project.dev to ServerName project.dev
and after these changes restart your apache service
Related
I know I'm probably missing something simple, but I've exhausted all resources trying to get this working.
I'm running my Apache on Port:5000 and trying to direct to lsapp.dev instead of http://localhost:5000/lsapp/public/ with:
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/lsapp/public"
ServerName lsapp.dev
</VirtualHost>
I have tried VirtualHost *:5000 but still can't get it work?
you can use this on command line in your project root
php artisan serve --port=your_port_number
or do this:
edit httpd-vhosts.conf that is located in C:\xampp\apache\conf\extra\httpd-vhosts.conf and add following lines at the end of the file:
# VirtualHost for LSAPP.DEV
<VirtualHost lsapp.dev:80>
DocumentRoot "C:\xampp\htdocs\lsapp\public"
ServerAdmin lsapp.dev
<Directory "C:\xampp\htdocs\lsapp">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
our apache is listening to lsapp.dev connections, but we have to configure our hosts file that allows to redirect lsapp.dev to the localhost that is located in C:\Windows\System32\drivers\etc
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 lsapp.dev
Set your Virtual host file like this.
<VirtualHost *:80>
DocumentRoot "D:\laravel Task\laravel\blog" //here set your project storage path
ServerName localhost.test.com // set your url for your project
<Directory "D:\laravel Task\laravel\blog"> // again set your project storage path
AllowOverride All
Order allow,deny
Allow from all
Require all granted
set your hosts file like this
127.0.0.1 localhost.test.com
Now you can Run your project
localhost.test.com
//OR//
If you dont want to use virtual host, then you can run your project like this
goto your project folder=>
command line in your project root=>php artisan serve
your project will run in
http://127.0.0.1:8000/
I have recently purchased a new computer and I am trying to get my website to find laravel. I have installed both wamp and composer. I am able to create a new laravel project using composer create-project... I have made a VirtualHost and a hostname as such..
<VirtualHost *:80>
DocumentRoot /wamp/www/jaycousins/public
ServerName jaycousins
<Directory "/wamp/www/jaycousins/public">
Options +Indexes
AllowOverride All
Require all granted
ErrorLog "logs/dummy-host2.example.com-error.log"
CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 localhost
127.0.0.1 jaycousins
But I cant find laravel simply by searching http://jaycousins/
I find it by http://localhost/jaycousins/public... How do i fix this?
You give full path of directory
<Directory "<< Directory Full path >>">
E.g.
<Directory "c:/wamp/www/jaycousins/public">
Wamp config Reference
https://www.kristengrote.com/blog/articles/how-to-set-up-virtual-hosts-using-wamp
I'm working locally on my Macbook Pro using XAMPP and I'm trying to setup virtualhosts so that I can work on multiple projects more easily.
Everything appears to be working fine except I can't connect to MySQL through PHPMyAdmin and on the XAMPP control panel it says MySQL isn't running. However, I can access MySQL through an application I have in my htdocs folder. When I access phpmyadmin through localhost/phpmyadmin the CSS is loaded and PHPMyAdmin appears to be located, but MySQL can't connect so I'm not quite sure where the issue lies (considering I can connect through my application)
Upon going to localhost/phpmyadmin I get the following error
#2002 - No such file or directory
The server is not responding (or the local server's socket is not correctly configured).
The thing is, I can access the database just fine through the application. I can log in, save and do any other sort of interactions with the database.
Here's what I have in my httpd-vhosts.conf file
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs/test1"
ServerName localhost
<Directory /Applications/XAMPP/xamppfiles/htdocs/test1>
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName pma
DocumentRoot "/Applications/XAMPP/xamppfiles/phpmyadmin"
<Directory /Applications/XAMPP/xamppfiles/phpmyadmin>
Options FollowSymLinks
DirectoryIndex index.php
<IfModule mod_php5.c>
AddType application/x-httpd-php .php
php_flag magic_quotes_gpc Off
php_flag track_vars On
php_flag register_globals Off
php_value include_path .
</IfModule>
</Directory>
</VirtualHost>
Now for a summary
I set up virtualhosts for apache on my Macbook
The virtualhost setup appears to be working fine for the application I have in my htodcs folder, and it can connect to the database. I can log in, save data and all that stuff.
When I browse to localhost/phpmyadmin I get a MySQL connection error. If I browse to pma/phpmyadmin (the virtualhost I tried to create) Chrome and Firefox just search google for it instead of recognizing the alias (is that the correct term?)
I ran into the same thing with a WAMP server. I solved it by putting back the original "out of the box" server settings:
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host.example.com
DocumentRoot "c:/Apache2/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>
And then for each project used code such as:
<VirtualHost *:80>
ServerAdmin admin#localhost
DocumentRoot "C:/wamp/projectname"
ServerName localhost
ServerAlias projectname.here
<Directory "C:/wamp/projectname">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride None
Order allow,deny
Allow from all # <-- used for Apache 2.2
#Require all granted #<-- used for Apache 2.4+
</Directory>
</VirtualHost>
For different projects, just duplicate the last set of code for each project, renaming the DocumentRoot, ServerAlias and Directory path. You will notice the "ServerAlias" line; this is what made Apache serve up the project when entering the alias in the web browser. I found the explanation here which ironically was in the httpd-vhosts.conf file.
Also, please note that my research recommends for higher versions of Apache to use Require all granted in place of Allow from all as commented in the code above.
All of this code is in the httpd-vhosts.conf file, which on my Windows 7 installation is at c:\wamp\bin\apache\Apache2.2.21\conf\extra directory. Since you are using a Macbook and have already identified the location, I just put this in for other's reference.
Do I need to update my host file and apache httpd.conf files manually whenever I create a new zf project using command.
For ex: if my new project is zendi.
in host file:
127.0.0.1 localhost zendi
in httpd.conf:
NameVirtualHost 127.0.0.1
<VirtualHost 127.0.0.1>
DocumentRoot "C:\wamp\www"
ServerName localhost
</VirtualHost>
<VirtualHost 127.0.0.1>
DocumentRoot "C:\wamp\www\zendi\public"
ServerName zendi
ErrorLog "C:\wamp\logs\apache_error.log"
<Directory "C:\wamp\www\zendi\public" >
Options Indexes FollowSymLinks
AllowOverride all
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
If you are using PHP 5.4, then you can use the built-in web server, and you don't even need Apache.
http://php.net/manual/en/features.commandline.webserver.php
If you need to use virtual host for your newly created zf application then the answer is YES you need to configure it manually command line project creation doesn't configure it for you. But if you don't need to have virtual server for every application you create then you can skip the process and go with direct url:
localhost/zendi/public
(But it is often considered good practice to have virtual hosts configured for the projects that you'll be working for a while)
I am trying to install PHP-Laravel in Windows 8 and I am using Xamp server(localhost). I am following Installing Laravel guide.
According to this guide I am making virtual host using following code :
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/TssApp/public"
ServerName TssApp
<Directory "C:/xampp/htdocs/TssApp/public">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
</Directory>
</VirtualHost>
//Where "C:/xampp/htdocs/TssApp/public" is path of Laravel public folder
and I have also added following line in in etc/hosts
127.0.0.2 TssApp
After doing necessary steps mentioned in this tutorial when I type "http://TssApp" , it always redirect to "http://tssapp/xampp/" instead of Laravel Home page. I don't know if I am missing any thing.
Note: I can access laravel home page at "http://localhost/tssapp/public/" but want
to use "http://TssApp" link to access my application.
Please help me regarding this issue.
Thanks .
Do you have NameVirtualHost * in your virtual-hosts configuration?
You'll need to restart Apache after any changes to either /etc/hosts or your virtual-hosts configuration files
Try adding the code to C:\xampp\apache\conf\extra\httpd-vhosts.conf instead of adding it to your own conf file. As far as I know xampp will ignore it unless its in the vhosts file.
You could try this.
<VirtualHost *>
DocumentRoot "C:\xampp\htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *>
DocumentRoot "C:\xampp\htdocs\TssApp\public"
ServerName tssapp
<Directory "C:\xampp\htdocs\TssApp\public">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Although you should put your files in the xampp directory and not the htdocs directory, so your files should be C:\xampp\TssApp\public, This would stop people from visiting htdocs which is a public folder and getting access to your application.
According to the documentation (that you point to), you should write
<VirtualHost 127.0.0.2>
and not
<VirtualHost *:80>
Could you try that and restart your computer/server?
Add in:
Allow from all
after
AllowOverride all
The end result should be:
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/TssApp/public"
ServerName TssApp
<Directory "C:/xampp/htdocs/TssApp/public">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Allow from all
</Directory>
</VirtualHost>
Also make sure you are editing the file "httpd-vhosts.conf" found in:
C:\xampp\apache\conf\extra