Assuming that we know the procedure of running Laravel with PHP artisan serve. But to run Laravel on localhost without PHP artisan serve is actually very simple.
Steps to run laravel on localhost without PHP artisan serve are given below:-
- If you are using WAMP, then go to the WAMP folder.
- Next, go to bin folder.
- Next, go to apache folder.
- Next, go to apache version folder if any. For eg:- apache2.4.41.
- Next, go to conf folder.
- Next, go to extra folder inside the conf folder.
- Next, open the httpd-vhosts conf file.
- Next, make a copy of virtual hosts as shown in the image below.
- Next, remove all the lines inside that tag. Only the lines start from servername and documentroot will be kept
- Remove the text at the right side of the servername and add the desired domain name or the project name like myproject.com or myproject.dev at the right side of the servername.
- Similarly, remove the quoted text at the right side of the documentroot and add this path with double-quote:- “D:/wamp/www/project folder name/public”. In my case, I have installed the localhost in D drive.
- Now, open the C drive and go to the windows folder.
- Now, search for the system32 folder and go to drivers folder.
- Now, go to etc folder and search for the hosts file.
- Now, make a copy of the hosts file to modify the file.
- Now open the hosts file and add this line 127.0.0.1 name of your project like XYZ.com and save the hosts file or replace the hosts file after the modification.
- Now left click on the WAMP icon and hit stop all services and then hit restart all services.
Now, you can open the browser and type your project name, it will upload your laravel project. If it does not work then restart your PC and start the server. Finally, you can run laravel on localhost without PHP artisan serve.
Read also, Insert multiple rows using same/single id in PHP
I hope this article will help you to run your laravel project on localhost easily. If you have any doubt then please leave your comment below.