繁体   English   中英

Laravel:如何决定使用server.php或public / index.php

[英]Laravel: How to decide using server.php or public/index.php

Laravel的server.php和public / index.php是做同样的事情,server.php只是需要public / index.php。 因此,在我的Apache http.conf文件中,我可以使用DirectoryIndex中的server.php或public / index.php,还可以将DocumentRoot设置为项目根文件夹或项目的公用文件夹。 问题是我应该在哪种情况下使用正确的配置以及如何使用它。

file is used with the serve Artisan command to start a lightweight webserver using PHP's internal webserver: 文件与serve Artisan命令一起使用,以使用PHP的内部网络服务器启动轻量级网络服务器:

$ php artisan serve --port=8000 
Laravel development server started: <http://localhost:8000>

...相当于从项目的根目录运行以下命令:

$ php -S localhost:8000 -t public/ ../server.php

file in the directory. 仅当我们可能还没有或需要单独的Web服务器,并且生产Web服务器应始终将请求定向到目录中的文件时,这才用于简单的开发和原型制作。

server.php文件中的注释说明了它的用途-

该文件使我们可以从内置PHP Web服务器模拟Apache的“ mod_rewrite”功能。 这提供了一种测试Laravel应用程序的便捷方法,而无需在此处安装“真实的” Web服务器软件。

因此,如果您使用的是Apache,请使用public/index.php

暂无
暂无

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

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