问题
I am new in laravel. I have install laravel successfully but now I am unable to serve on localhost. My file path is C:\wamp\www\testproject inside testproject I have laravel directory structure. So, can anyone tell me that how can I serve on localhost. Please help me ?
Thank You
回答1:
First of open CMD
CMD -> cd testproject (go to your project directory )
CMD -> CD php artisan serve
Than run that url http://127.0.0.1:8000
Complate installation and run : https://www.youtube.com/watch?v=zq639PQosDU&index=4&list=PLnBvgoOXZNCP2LEKmvu2W-eUkO-DYn0TL
回答2:
You can serve on your local host by the following command:-
php artisan serve
This is the by default artisan command which will serve your application on local host port 8000. This command needs to be passed in cmd after navigating to your laravel root directory.
Another way you can add virtual host on your system configuration and serve your application with virtual domain name also.
Do try any of the above and let me know if it worked.
回答3:
In c://windows/system32/driver/etc/hosts
127.0.0.1 www.your-project-name.local
In httpd-vhosts.conf
<VirtualHost *:80>
ServerAdmin www.your-project-name.local
DocumentRoot "your project folder path"
ServerName www.your-project-name.local
ErrorLog "logs/dummy-host.example.com-error.log"
CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>
OR
php artisan serve will work fine
回答4:
open project folder in terminal
run
php artisan serve
or
php -s localhost:portnumber -t public
回答5:
You can create virtual host that refers to the public path of your laravel project
Or you can use laragon as local server just like wamp , it will create auto virtual host for you.
As example, you have projet in the folder
C://laragon/www/projrct1
Then the laragon will create one virtual host for project1
And you can easily run this projects by typing
"project1.dev" in the address bar of your browser
But if you don't want to use laragon as local server you can also create virtual host that can refer to the public folder of your laravel app
You can follow these instructions:
https://john-dugan.com/wamp-vhost-setup/
来源:https://stackoverflow.com/questions/48057738/how-to-run-laravel-project-on-localhost-using-wamp