Vladimir
Vladimir

Reputation: 1789

How to run Laravel project on Apache localhost

When I use artisan serve project works fine on localhost:8000 but I need to run project from localhost/, when I visit localhost/project/public code don't work correctly, any solution?

Upvotes: 4

Views: 13803

Answers (2)

Eenvincible
Eenvincible

Reputation: 5626

Are you using Linux? If you are, then I have instructions for you that should help both for the current project and the future projects:

The best approach is to create a virtual host for your project. For future projects, you will simply repeat the same process.

To save you time, I have put together a clear tutorial on how to do so by creating a conf file. This will enable you to access your project by actually visiting a local domain like demo.local instead of localhost:8000 etc.

Here is the tutorial : How to setup a virtual host in Ubuntu (Laravel Example)

I hope this helps and if you have further questions, please let me know.

Upvotes: 5

baao
baao

Reputation: 73241

Create a virtual host configuration file at

/etc/apache2/sites-available

(Simply copy the default.conf file) and point the directory root to the folder containing your laravel project. Best is to copy your files to

/var/www/html/ ...project folder...

and make the public laravel dir document root in your confit file.

You can find more information on creating vhost files in many answers here on stackoverflow.

Upvotes: 4

Related Questions