在本地主机中运行laravel项目 [英] Run laravel project in localhost

查看:580
本文介绍了在本地主机中运行laravel项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经通过作曲家create-project laravel/laravel –-prefer-dist安装了laravel

I have installed laravel by composer create-project laravel/laravel –-prefer-dist

在运行php artisan serve命令之后,进入laravel项目目录并获得此结果.

after this run php artisan serve command to laravel project directory and get this result.

Laravel开发服务器已启动: http://127.0.0.1:8000

Laravel development server started: http://127.0.0.1:8000

但是当我在浏览器laravel项目中转到 http://127.0.0.1:8000 时,它没有运行并给出错误

But when i go to http://127.0.0.1:8000 in browser laravel project not running and give error

无法访问此网站 127.0.0.1拒绝连接.

This site can’t be reached 127.0.0.1 refused to connect.

http://localhost/laravel/public/正常.谁能告诉我运行该laravel项目的正确方法是什么.

but http://localhost/laravel/public/ it is working. Can anyone tell me that what is proper way to run this laravel project.

推荐答案

尝试在其他端口上运行

php artisan serve --port=9000

,然后尝试 http://127.0.0.1:9000 可以正常工作.

and then try http://127.0.0.1:9000 will work.

由于端口8000可能已经在系统上运行,因此无法正常工作.

As might be on port 8000 something already running on your system will not make it work.

您还可以在没有工匠服务命令的情况下运行laravel项目

And you can also run your laravel project without artisan serve command

如果有人想公开该应用程序,则更简单,最快的方法是:

If anyone wants to make the application public, the more easy and fastest way is:

  1. 在根目录中的"index.php"中重命名"server.php"文件
  2. 将.htaccess文件从公用文件夹移动到根目录
  3. 使目录可被Apache2访问(设置所有文件权限) 至777).
  1. Rename the "server.php" file in root directory, in "index.php"
  2. Move your .htaccess from public folder to root directory
  3. Make your directory accessible to Apache2 (set all file permissions to 777).

这篇关于在本地主机中运行laravel项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆