Laravel Framework 5.7.29 blank main page - laravel

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.

Related

set virtualhost in apache is not direct to my goal directory of laravel project

OS: Microsoft Windows 10
backend framework: Laravel
my goal: when I access to "http://example.domain", it can direct to laravel index.php.
httpd-vhosts.conf:
<VirtualHost *:80>
DocumentRoot "C:\Apache24\htdocs\NKUST_foodpanda\public"
DirectoryIndex index.php
ServerName example.domain
ErrorLog "C:\Apache24\logs\error.log"
CustomLog "C:\Apache24\logs\access.log" combined
<Directory "C:\Apache24\htdocs\NKUST_foodpanda\public">
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
I save httpd-vhosts.conf and restart my apache, and now, when I access to "http://example.domain", it will direct to "C:\Apache24\htdocs", not "C:\Apache24\htdocs\NKUST_foodpanda\public".
I have tried with same possible scenario as yours with following entry httpd-vhost.conf. Checked it with both '' and '/' and it is working for me. Make sure to provide proper permission to your directories. If this could not work you need to provide more info.
<VirtualHost example.domain:80>
DocumentRoot "C:\Apache24\htdocs\NKUST_foodpanda\public"
DirectoryIndex index.html
ServerName example.domain
ErrorLog "C:\Apache24\logs\error.log"
CustomLog "C:\Apache24\logs\access.log" combined
<Directory "C:\Apache24\htdocs\NKUST_foodpanda\public">
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
If you want to set a newer setup in "httpd-vhosts.conf", you have to delete comment out "Include conf/extra/httpd-vhosts.conf" in "httpd.conf".
I have not notice this problem, I comment out "Include conf/extra/httpd-vhosts.conf" and set something in "httpd-vhosts.conf" at the same time, so "httpd-vhosts.conf" doesn't work.

Access forbidden either read protected or not readable

Currently I have multiple laravel project in my htdocs and configured like this
<VirtualHost *:0903>
DocumentRoot "C:/xampp/htdocs/svs_web_application/public"
ServerName localhost
</VirtualHost>
<VirtualHost *:0904>
DocumentRoot "C:/xampp/htdocs/api_tk/public"
ServerName localhost
</VirtualHost>
<VirtualHost *:0905>
DocumentRoot "C:/xampp/htdocs/svs_api/public"
ServerName localhost
</VirtualHost>
listen 0903
listen 0904
listen 0905
I can access these projects and do some stuffs.
Not until when I configured another laravel project with this kind of setup
<VirtualHost *:0902>
DocumentRoot "C:/xampp/htdocs/pinoytravelreseller/public"
ServerName localhost
</VirtualHost>
listen 0902
And I got this kind of error
Access forbidden!
You don't have permission to access the requested object. It is either read-protected or not readable by the server
Tried to include this setup
<VirtualHost *:0902>
DocumentRoot "C:/xampp/htdocs/pinoytravelreseller/public"
ServerName localhost
<Directory "C:/xampp/htdocs/pinoytravelreseller/public">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Allow from all
Require all granted
</Directory>
</VirtualHost>
listen 0902
But still doesn't work is there any configuration do I need to do?
is there any files on that folder,
can you access by the way like localhost:902/demo.php,
demo.php just a php which say a 'hi',
if it cannot run and say 'hi' well,
I think you need to check is there any htaccess file on the root of project folder

Laravel 5.2 site on localhost/Wamp

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.

setting up laravel redirects to xampp

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.

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