简体   繁体   English

如何在没有/public/index.php的情况下到达Laravel

[英]How to reach Laravel without /public/index.php

I'm following the official Laravel course (currently the first chapter " Meet Composer ,"), but I can't seem to get it right. 我正在学习Laravel官方课程(当前第一章“ Meet Composer ”),但我似乎做得不好。 In the course I was instructed to enter in the command line: 在课程中,我被指示输入命令行:

php -S localhost:8888 -t public

and I should be able to reach the URL: " http://localhost:8888/learning-laravel-5 ", but this gives me a 404 error. 并且我应该能够访问URL:“ http:// localhost:8888 / learning-laravel-5 ”,但这给了我404错误。

But if I put in this URL I get to see the frontpage, as it should: http://localhost:8080/learning-laravel-5/public/index.php 但是,如果我输入此URL,我会看到首页,因为它应该是: http:// localhost:8080 / learning-laravel-5 / public / index.php

My question is, how can I see the frontpage as instructed in the video, following the provided URL: http://localhost:8888/learning-laravel-5 ? 我的问题是,如何按照提供的URL,按照视频中的说明查看首页: http:// localhost:8888 / learning-laravel-5

I have looked through the duplicate questions on stackoverflow but I can't find a solution to this problem. 我已经查看了关于stackoverflow的重复问题,但是找不到解决该问题的方法。

Edit: I have tried to get my absolute path by doing pwd, its says "/media/sf_sandbox/laracast-4.2", I now have done this: "php -S localhost:8888 -t /media/sf_sandbox/laracast-4.2/public". 编辑:我试图通过执行pwd来获得我的绝对路径,它说“ /media/sf_sandbox/laracast-4.2”,我现在已经这样做:“ php -S localhost:8888 -t /media/sf_sandbox/laracast-4.2 /上市”。 I now go to localhost:8888 but it still doesn't work. 我现在转到localhost:8888,但仍然无法正常工作。

It says my documentroot is /media/sf_sandbox/learning-laravel-5/public 它说我的文档根目录是/ media / sf_sandbox / learning-laravel-5 / public

If you are running below command from the project root learning-laravel-5 , than localhost:8888 it self points to the learning-laravel-5/public folder 如果您在项目根目录learning-laravel-5之下的命令下运行,而不是localhost:8888则它自身会指向learning-laravel-5/public文件夹

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

In this case only localhost:8888 should work and you don't need to append learning-laravel-5 after that. 在这种情况下,仅localhost:8888应该可以工作,并且learning-laravel-5您无需附加learning-laravel-5

It seems like you are using XAMP..because For XAMP, localhost port is 8000 And For XAMP, localhost port is 8000. 似乎您正在使用XAMP ..因为对于XAMP,本地主机端口是8000,对于XAMP,本地主机端口是8000。

in the laravel directory, where you ran composer, type php artisan serve . 在您运行作曲家的laravel目录中,输入php artisan serve This will run an internal webserver, which opens up 8000 port by default. 这将运行一个内部Web服务器,默认情况下会打开8000端口。 Once you have that, open your browser and access http://localhost:8000 安装完后,打开浏览器并访问http:// localhost:8000

If that works, you have an issue with your MAMP configuration. 如果可行,则说明您的MAMP配置有问题。

If it is MAMP, check the following 如果是MAMP,请检查以下内容

1) make sure you set the document root to the /public directory in your laravel installation. 1)确保在laravel安装中将文档根目录设置为/ public目录。

2 make sure you have enabled rewrite module in your mamp. 2确保已在Mamp中启用重写模块。

Checkout How to get htaccess to work on MAMP 结帐如何使htaccess在MAMP上工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM