Shakun Chaudhary
Shakun Chaudhary

Reputation: 339

php artisan serve command works but url not working

In Laravel 5.4,

After running php artisan serve command fresh laravel setup works on this url localhost:8000 but when i try to access with public url localhost/lara54/public. it is not working and gives white blank page. I tried this using virtual host in linux giving folder path upto public but still not working.

php artisan serve command also creates a virtual host what i am missing here to make this setup work with URL.

Upvotes: 5

Views: 14158

Answers (7)

user4535674
user4535674

Reputation:

The default Laravel command "php artisan server" returns the URL "localhost:8000" in your browser address bar, so you should type "http://localhost:8000". Because it uses the default PHP built-in web server (read at PHP.net) to serve the Laravel application direcory for development.

For production, it is recommended to use nginx or Apache, you may read on DigitalOcean for Nginx or for Apache

Upvotes: 0

Ahad Ahmad
Ahad Ahmad

Reputation: 1

It's a matter of fact that serve command and run with public folder give url not found error. There are three ways

  1. you should change your url like this:
<a href="{{ url('/dashboard') }}">
  1. you should change your .htaccess file and add code
<Directory /var/www/html/public/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>
  1. on production server you should run VC

Upvotes: 0

K4XN
K4XN

Reputation: 100

I just got inspired by user4535674's and Bercove's answers.

Instead of php artisan serve --port=8000 type php artisan serve --host=0.0.0.0 --port=8000

It worked in my case like a charm!

Upvotes: 1

Yan Niang
Yan Niang

Reputation: 1

Try install vc runtime Work for me

Upvotes: 0

Bercove
Bercove

Reputation: 1175

Run this command it will work

php -S 0.0.0.0:8000

Upvotes: 3

Deepak Dholiyan
Deepak Dholiyan

Reputation: 1912

Try using the following --port param:

php artisan serve --port=8000

Hope it helps you because this solves my problem.

Upvotes: 1

Jigneshsinh Rathod
Jigneshsinh Rathod

Reputation: 1028

give permission to following two directories:

storage

bootstrap/cache

i hope its help you

Upvotes: 1

Related Questions