【问题标题】:How to reach Laravel without /public/index.php如何在没有 /public/index.php 的情况下访问 Laravel
【发布时间】:2015-07-25 17:38:40
【问题描述】:

我正在学习 Laravel 官方课程(目前是第一章“Meet Composer”),但我似乎无法正确理解。在课程中,我被指示在命令行中输入:

php -S localhost:8888 -t public

我应该能够访问 URL:“http://localhost:8888/learning-laravel-5”,但这会给我一个 404 错误。

但是如果我输入这个 URL,我会看到首页,它应该是:http://localhost:8080/learning-laravel-5/public/index.php

我的问题是,我怎样才能看到视频中的首页,按照提供的 URL:http://localhost:8888/learning-laravel-5

我查看了 stackoverflow 上的重复问题,但找不到解决此问题的方法。

编辑:我试图通过 pwd 获取我的绝对路径,它说“/media/sf_sandbox/laracast-4.2”,我现在已经这样做了:“php -S localhost:8888 -t /media/sf_sandbox/ laracast-4.2/公共”。我现在去 localhost:8888 但还是不行。

它说我的文档根目录是 /media/sf_sandbox/learning-laravel-5/public

【问题讨论】:

    标签: php laravel-5


    【解决方案1】:

    如果您从项目根目录 learning-laravel-5 运行以下命令,则比 localhost:8888 它自己指向learning-laravel-5/public 文件夹

    php -S localhost:8888 -t /var/www/html/learning-laravel-5/public
    

    在这种情况下,只有localhost:8888 应该可以工作,您不需要在此之后附加learning-laravel-5

    【讨论】:

    • 对不起@pinkal,这对我不起作用,我输入了“php -S localhost:8888 -t public”,我得到了回复“正在收听localhost:8888”但是当我去localhost:8888我只是看到页面不可用。
    • @Joop 尝试绝对路径。我已经更新了我的答案。
    • 嗨@pinkal,我试图通过密码获取我的绝对路径,它说“/media/sf_sandbox/laracast-4.2”,我现在已经这样做了:“php -S localhost:8888 -t /media/sf_sandbox/laracast-4.2/public”。我现在转到localhost:8888,但仍然没有任何反应,尽管它说它正在侦听 url localhost:8888。我真的很想知道我做错了什么。
    【解决方案2】:

    您似乎正在使用 XAMP..因为 对于 XAMP,localhost 端口是 8000 并且 对于 XAMP,localhost 端口是 8000。

    在你运行 composer 的 laravel 目录中,输入 php artisan serve。这将运行一个内部网络服务器,默认情况下打开 8000 端口。完成后,打开浏览器并访问http://localhost:8000

    如果可行,则说明您的 MAMP 配置存在问题。

    如果是MAMP,检查以下

    1) 确保将文档根目录设置为 laravel 安装中的 /public 目录。

    2 确保您在 mamp 中启用了重写模块。

    结帐How to get htaccess to work on MAMP

    【讨论】:

    • 我没有使用任何这些软件包,我有一个 Ubuntu virtualbox LAMP 正在运行。补充:我使用的是8080端口,我想使用8888,而不是你指定的8000。
    猜你喜欢
    • 1970-01-01
    • 2019-07-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-27
    相关资源
    最近更新 更多