如何使用 wamp 在本地主机上运行 Laravel 项目?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/48057738/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 17:11:30  来源:igfitidea点击:

How to run laravel project on localhost using wamp?

phplaravelwamp

提问by omkara

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 ?

我是laravel的新手。我已经成功安装了 laravel,但现在我无法在本地主机上提供服务。我的文件路径是 C:\wamp\www\testproject 里面的 testproject 我有 Laravel 目录结构。那么,谁能告诉我如何在本地主机上提供服务。请帮我 ?

Thank You

谢谢你

采纳答案by Nims Patel

  1. First of open CMD

  2. CMD -> cd testproject (go to your project directory )enter image description here

  3. CMD -> CD php artisan serveenter image description here

  4. Than run that url http://127.0.0.1:8000enter image description here

  1. 首先打开CMD

  2. CMD -> cd testproject(进入你的项目目录)在此处输入图片说明

  3. CMD -> CD php artisan serve在此处输入图片说明

  4. 比运行那个网址http://127.0.0.1:8000在此处输入图片说明

Complate installation and run : https://www.youtube.com/watch?v=zq639PQosDU&index=4&list=PLnBvgoOXZNCP2LEKmvu2W-eUkO-DYn0TL

完成安装并运行:https: //www.youtube.com/watch?v=zq639PQosDU&index =4&list =PLnBvgoOXZNCP2LEKmvu2W-eUkO-DYn0TL

回答by Parth Pandya

You can serve on your local host by the following command:- php artisan serveThis 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.

您可以通过以下命令在本地主机上提供服务:- php artisan serve这是默认情况下的 artisan 命令,它将在本地主机端口 8000 上为您的应用程序提供服务。导航到 Laravel 根目录后,需要在 cmd 中传递此命令。

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.

请尝试以上任何一种方法,并让我知道它是否有效。

回答by Hyman

In c://windows/system32/driver/etc/hosts

c://windows/system32/driver/etc/hosts

127.0.0.1 www.your-project-name.local

In httpd-vhosts.conf

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 servewill work fine

php artisan serve可以正常工作

回答by NanThiyagan

open project folder in terminal

在终端中打开项目文件夹

run

   php artisan serve

or

或者

   php -s localhost:portnumber -t public 

回答by Bhargav Kaklotara

You can create virtual host that refers to the public path of your laravel project

您可以创建引用 Laravel 项目公共路径的虚拟主机

Or you can use laragonas local server just like wamp , it will create auto virtual host for you.

或者你可以像 wamp 一样使用laragon作为本地服务器,它会为你创建自动虚拟主机。

As example, you have projet in the folder

例如,您在文件夹中有项目

C://laragon/www/projrct1

C://laragon/www/projrct1

Then the laragon will create one virtual host for project1

然后 laragon 会为 project1 创建一个虚拟主机

And you can easily run this projects by typing

您可以通过键入轻松运行此项目

"project1.dev" in the address bar of your browser

浏览器地址栏中的“project1.dev”

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

但是如果你不想使用 laragon 作为本地服务器,你也可以创建可以引用你的 laravel 应用程序公共文件夹的虚拟主机

You can follow these instructions:

您可以按照以下说明操作:

https://john-dugan.com/wamp-vhost-setup/

https://john-dugan.com/wamp-vhost-setup/