I've set up wamp and laravel with composer, and virtualhosts too. Whenever I go to my project folder 'localhost/project/', or my vhost 'project.dev', I only see the file directory of the laravel project. Yet if I go to 'project.dev/public' or 'project.dev/server.php' it works. What am I doing wrong?
You need to set your DocumentRoot (in your vhosts file) to C:\location\of\laravel\public instead of C:\location\of\laravel\
Here is an example, dont forget to also tell Apache from where it is allowed to accespt connections as well.
<VirtualHost *:80>
DocumentRoot "D:/wamp/www/laravel/public"
ServerName laravel.dev
Options Indexes FollowSymLinks
<Directory "D:/wamp/www/laravel/public">
AllowOverride all
Require local
Require ip 192.168.1
</Directory>
</VirtualHost>
Related
I was having problems with a blank page in my first Laravel project. I'm currently watching the Laravel Framework course on YouTube. This is Lesson 1 called "How to install the Laravel Framework". I checked it out laravel.com for the requirements section and made sure I have all of them. After that, I installed Composer 2.0.13. Using it, I installed Laravel Framework 5.7.29. I got reports that some packages are deprecated. They were about changing the color on the console.
The next step was to change "/etc/hosts". I added the line 127.0.0.1 poligon.local The next step was to change "/opt/lampp/etc/extra/httpd-vhosts.conf". I added the lines:
<VirtualHost *:80>
ServerAdmin admin#example.com
DocumentRoot "/home/stas/projects/poligon.local/public"
ServerName poligon.local
ServerAlias www.poligon.local
<Directory /home/stas/projects/poligon.local/public>
Options Indexes FollowSymLinks
AllowOverride All
Order Allow,Deny
Allow from all
Require all granted
</Directory>
ErrorLog "logs/poligon-error.log"
CustomLog "logs/poligon-access.log" common
</VirtualHost>
Then I wrote $ sudo /opt/lampp/lampp start to start the local XAMPP server. And I have a blank page on the "poligon.local/". When I started php artisan serve, I had access to "poligon.local:8000", and there is the Laravel home page. But the author of the video got access to the "poligon.local" without php artisan serve. What do you think is my mistake?
Update: If I create /public/index.html I will get this html page.
Update2: I was experimenting now with php artisan serve --host 127.0.0.1 --port 80 and found that with the XAMPP server enabled, this socket is already in use. But when the server is turned off, I manage to run artisan command with these connection settings. As I understand it, XAMPP occupies this socket, but for some reason can't handle it on its own.
Update3: I checked it out /public/index.php the whole file and found out that it is being executed. Up to the line $response = $kernel->handle( $request = Illuminate\Http\Request::capture() ); There is no continuation after it.
Define the site you added in hosts file in the Virtual Host route.
Change this
<VirtualHost *:80>
ServerAdmin admin#example.com
DocumentRoot "/home/stas/projects/poligon.local/public"
ServerName poligon.local
ServerAlias www.poligon.local
<Directory /home/stas/projects/poligon.local/public>
Options Indexes FollowSymLinks
AllowOverride All
Order Allow,Deny
Allow from all
Require all granted
</Directory>
ErrorLog "logs/poligon-error.log"
CustomLog "logs/poligon-access.log" common
</VirtualHost>
to this
<VirtualHost poligon.local:80>
ServerAdmin admin#example.com
DocumentRoot "/home/stas/projects/poligon.local/public"
ServerName poligon.local
ServerAlias www.poligon.local
<Directory /home/stas/projects/poligon.local/public>
Options Indexes FollowSymLinks
AllowOverride All
Order Allow,Deny
Allow from all
Require all granted
</Directory>
ErrorLog "logs/poligon-error.log"
CustomLog "logs/poligon-access.log" common
</VirtualHost>
Notice that i have defined the host URL you defined in the virtual host route
From <VirtualHost *:80> to the url you defined <VirtualHost poligon.local:80>
What this * does is it gets all the requests and direct it to XAMPP homepage which is default.
I want to use Laravel projects at the same time. How you can do it? For example one project at
http://example.xom/laravel_proj1
and another on
http://example.xom/laravel_proj2
Configuration: Laravel 7 / 8 and Apache
Update: This is 2 different Projects. But are there some problems if I use this 2 equals Projects. Upsides of MySQL Datables of course.
File: /opt/bitnami/apache2/conf/vhosts/APPNAME-vhost.conf
<VirtualHost 127.0.0.1:80 _default_:80>
ServerAlias *
DocumentRoot /opt/bitnami/projects/APPNAME/public
<Directory "/opt/bitnami/projects/APPNAME/public">
Options -Indexes +FollowSymLinks -MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Usually you work with subdomains to have multiple laravel projects running at the same time. This means that one instance runs at first.example.com and the other at second.example.com. In my opinion what you are trying is more a workaround if you only have one vhost running.
So I would have two vhost files like you have now. One like:
<VirtualHost 127.0.0.1:80 _default_:80>
ServerAlias first.example.com
DocumentRoot /opt/bitnami/projects/first/public
<Directory "/opt/bitnami/projects/first/public">
...
</Directory>
</VirtualHost>
and
<VirtualHost 127.0.0.1:80 _default_:80>
ServerAlias second.example.com
DocumentRoot /opt/bitnami/projects/second/public
<Directory "/opt/bitnami/projects/second/public">
...
</Directory>
</VirtualHost>
Then you would add both subdomains to your hosts file. I don't know where that one is located but in there you would have to add:
127.0.0.1 first.example.com
127.0.0.1 second.example.com
This is not exactly how I do it now, but I think it could be a good starting point. You also need to activate your vhosts and restart apache.
I am trying to create a virtual host for a Zend Framework project, but it is not working.
I added the string "127.0.0.1 mysite.local" to the hosts file (/private/etc/hosts), and this is what I put in httpd.conf:
<VirtualHost *:80>
ServerName mysite.local
DocumentRoot "/Applications/MAMP/htdocs/mysite/public"
SetEnv APPLICATION_ENV "development"
<Directory "/Applications/MAMP/htdocs/mysite/public">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
I restarted server, and then I try to access it in browser like: http://mysite.local:8888/, but it takes me to "htdocs" root, not to the Zend Project.
Am I missing something? Did I type something wrong? I'm using MacOSX, I tried putting port 8888 instead of 80 in the VirtualHost definition but it didn't work too.
Thanks
Hi I'm setting up Lavarel using a book called Laravel Starter by Shawn McCool (Packt Publishing), I've cloned the respiratory via github and have got as far as configuring my hosts file and setting up my virtual hosts. As below:
127.0.0.1 laravel.dev
<VirtualHost *:80>
ServerName laravel.dev
DocumentRoot C:/xampp/htdocs/laravel/public
</VirtualHost>
However if I visit the link http://laravel.dev I am redirected to the XAMPP page and I should be expecting the laravel splash page.
Any ideas of what I have done wrong? The document root is pointing to the correct direction as it is installed onto my localhost.
Greatly appreciate any help.
In the new xampp you should use something like this:
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/laravel/public"
ServerName laravel.dev
ServerAlias laravel.dev
ErrorLog "logs/laravel.log"
CustomLog "logs/custom.laravel.log" combined
<Directory "C:/xampp/htdocs/laravel/public">
AllowOverride All
Order Allow,Deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
edited with the right serverName. This is my own virtual host file. I also use it for Laravel.
Go to C:\wamp\bin\apache\apache2.4.9\conf\httpd.conf and enable virtualhost by removing the #sign in front of Include conf/extra/httpd-vhosts.conf
Albeit an old question, I found a solution to this the hard way. Do something like this:
<VirtualHost *:80>
DocumentRoot "C:\xampp\htdocs"
ServerName localhost
<Directory "C:\xampp\htdocs">
Require all granted
</Directory>
</VirtualHost>
This would enable the XAMPP Stack to point to the localhost correctly (I guess?)
And of course don't forget your drivers\etc\hosts
127.0.0.1 localhost
127.0.0.1 laraveltest.dev
Your configuration seems fine. Just don't forget to add these two.
<VirtualHost *:80>
ServerName laraveltest.dev
ServerAdmin laraveltestp#localhost.com
DocumentRoot "D:/Workspace/Projects/Playground/laravel-test/public"
#SetEnv APPLICATION_ENV "development"
<Directory "D:/Workspace/Projects/Playground/laravel-test/public">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Allow from all
Require all granted
</Directory>
</VirtualHost>
In new Laravel you need to change your Apache Vhost file to stop this redirection from server. For complete guide about how to change vhost file and run your first laravel web app go to following link : <https://answerdone.blogspot.com/2018/01/how-to-solve-laravel-xampp-dashboard.html>
probably, it is because xampp and laravel run on the same port. If so, try changing port before you start running laravel project by this command
php artisan serve --port=8080
*8080 can be changed to any other number port you want
Do you have NameVirtualHost enabled?
try uncomment #NameVirtualHost *:80 and see if it helps.
I used localhost/appName/public/. This is the only way it worked for me.
I want to change XAMPP's htdocs directory. I followed the instructions to create a virtual host from this question:
Make XAMPP/Apache serve file outside of htdocs
this works fine on Windows 7, however when I try it on OSX, going to mysite.local just loads the xampp splash screen (mysite.local/xampp/index.html). I have restarted the web server. My virtual host declared in httpd-vhosts.conf is:
<VirtualHost *:80>
DocumentRoot Users/username/Documents/sitename.com
ServerName sitename.localhost
<Directory Users/username/Documents/sitename.com>
Order allow,deny
Allow from all
</Directory>
Open the following file in a text editor.
/Applications/XAMPP/xamppfiles/etc/httpd.conf
Search for "DocumentRoot", if the line below has a # in front of it than it's commented remove it and change the path between the quote
DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs"
Now search for the line below and change the path between the quotes to your needs.
<Directory "/Applications/XAMPP/xamppfiles/htdocs">
NOTICE: Paths similar to ~/ won't work use the absolute path.
I would like to expand this answer for 2022.
You will have to change 3 files if you want to keep web root in another directory. Let's say that you have installed XAMPP regularly, but your httpd directory is on another volume. Let's say in work/xampp/
Open /Applications/XAMPP/xamppfiles/apache2/conf/httpd.conf and change it to the following
Alias /bitnami/ "/Applications/XAMPP/xamppfiles/apache2/htdocs/"
Alias /bitnami "/Applications/XAMPP/xamppfiles/apache2/htdocs"
DocumentRoot "/Applications/XAMPP/xamppfiles/apache2/htdocs"
<Directory "/Applications/XAMPP/xamppfiles/apache2/htdocs">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
DocumentRoot "/Volumes/work/xampp"
<Directory "/Volumes/work/xampp">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
We have added
DocumentRoot "/Applications/XAMPP/xamppfiles/apache2/htdocs"
and the block
DocumentRoot "/Volumes/work/xampp"
<Directory "/Volumes/work/xampp">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Open file /Applications/XAMPP/xamppfiles/etc/extra/httpd-vhosts.conf and change it to the following
<VirtualHost *:80>
DocumentRoot "/Volumes/work/xampp"
</VirtualHost>
<VirtualHost yoursite.mac:80>
ServerName yoursite.mac
ServerAlias www.yoursite.mac
ServerAdmin webmaster#yoursite.mac
DocumentRoot "/Volumes/work/xampp/yoursite.mac/webroot"
ErrorLog "/Volumes/work/xampp/yoursite.mac/logs/oll.mac-error_log"
CustomLog "/Volumes/work/xampp/yoursite.mac/logs/oll.mac-access_log" common
<Directory "/Volumes/work/xampp">
Require all granted
</Directory>
</VirtualHost>
Open /etc/hosts as a sudo and add your new site to it
127.0.0.1 yoursite.mac
If you forward to a directory in your user root, then:
DocumentRoot "/Users/<your username here>/Sites"
<Directory "/Users/<your username here>/Sites">
Other than the answers mentioned above, I also had to change the line in XAMPP/xampfiles/etc/httpd.conf where it mentions username. the default was set to daemon and I changed it to my username; so there was no permission problem.
solved by editing httpd.conf
I have got this working. As per http://www.acwolf.com/blog/2009/February/xampp-virtual-hosts-mac, in OSX it is necessary to make two changes to httpd.conf, first, uncomment
#Include /Applications/xampp/etc/extra/httpd-vhosts.conf
and second, change the user from nobody to the username you use to log into OSX. You may also need to delete your browser's cache.