Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run Laravel project on Apache localhost

Tags:

laravel-5

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?

like image 282
Vladimir Avatar asked Jan 09 '23 22:01

Vladimir


2 Answers

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.

like image 92
Eenvincible Avatar answered Jan 31 '23 09:01

Eenvincible


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.

like image 38
baao Avatar answered Jan 31 '23 09:01

baao