簡體   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