0

I've a strange problem. My laravel project in v5.1 runs successfully after running php artisan serve command in terminal at localhost:8000. But the project doesn't run when I access the project with localhost/myproject/public from my browser and shows a blank page. I also tried creating virutal host and access the project from virutual host but without any success.

Can anyone help me how to solve this issue?

razn
  • 69
  • 3
  • 9
  • php artisan serv not working ? – AddWeb Solution Pvt Ltd Aug 03 '17 at 06:22
  • 4
    you need to go to localhost:8000 and not localhost/myproject/public – Exprator Aug 03 '17 at 06:25
  • Do you have a local instance of Apache or nginix running? Checkout Laravel Homestead if you're looking for a more complete virtual machine to develop on. It's a preconfigured Vagrant box running ubuntu and Nginix. You can't just open the public folder in your browser, that won't work. – Ryan Kozak Aug 03 '17 at 06:29
  • When artisan server start they show you url though you can access your project default its come localhost:8000. Check it and lets know if you feel any issue. – Prabhu Nandan Kumar Aug 03 '17 at 06:32
  • @AddWebSolutionPvtLtd my project works fine running php artisan serve – razn Aug 03 '17 at 07:03
  • @Ryankozak yep my local instance of Apache is running. And two of my other projects have no problem running from url "localhost/otherProject/public" but some of my projects just don't run like this or from virtual host. – razn Aug 03 '17 at 07:04
  • where is your project located.? – Zedex7 Aug 03 '17 at 07:06
  • @PrabhuNandanKumar the url shown after running php artisan serve is http://localhost:8000/ and my project runs as it should but I just can't run my project via localhost/myproject/public or virtual host – razn Aug 03 '17 at 07:08
  • @razn did you tired by Virtual host ? – Prabhu Nandan Kumar Aug 03 '17 at 07:10
  • @ZaheerAttar my project is actually located in "var/www/html/pn/myproject" dir and I can't access it via "localhost/pn/myproject/public" while some of my other project do run like this. – razn Aug 03 '17 at 07:10
  • you need to go `localhost:8000/pn/myproject/public` – Zedex7 Aug 03 '17 at 07:12

2 Answers2

0

-Move your project to 'htdocs' or 'www' root folder. -Open public folder and open index.php file and edit these lines :

require __DIR__.'/../bootstrap/autoload.php';
$app = require_once __DIR__.'/../bootstrap/app.php';

to these:

require __DIR__.'/bootstrap/autoload.php';
$app = require_once __DIR__.'/bootstrap/app.php';

so index be able to find 'autoload.php'

and save these edits. -Now move all files from public folder to 'htdocs' folder. -run your project in browser whit 'http://localhost' or 'http://127.0.0.1'

0

I had same problem on Ubuntu 16.04. solved it by doing :

  1. Set AllowOverride to All as follows in your default conf file or virtual host conf file AllowOverride All Order allow,deny allow from all

  2. sudo service apache2 restart

You may need to also do sudo a2enmod rewrite to enable module rewrite.

Hope this will help you.