簡體   English   中英

在本地主機上運行 Laravel 時出現內部服務器錯誤

[英]Internal Server Error while run laravel on localhost

我是 Laravel 的初學者。 現在,我想在本地主機上運行 laravel 項目。 現在,我做了什么? 我在resource/view/index.blade.php創建了index.blade.php文件並在routes/web.php修改了web.php文件

路線/ web.php

<?php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('index', function () {
    return view('index');
});

資源/視圖/index.blade.php

<!doctype html>
<html>
    <head>
        <title>Demo</title>
    </head>
    <body>
        <h1>Laravel start</h1>  
    </body>
</html>

我已將server.php更改為index.php並將.htaccess文件從public移動到根目錄並重新啟動apache服務器。 但它向我顯示500 Internal Server Error 我已經運行localhost/laravel但它不工作。 那么,我該如何解決這個問題? 請幫我。

發生錯誤

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at webmaster@dummy-host2.example.com to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

Apache/2.4.29 (Win32) OpenSSL/1.0.2l PHP/5.6.32 Server at localhost Port 80

謝謝你

after fresh install , just run command "php artisan serve" , 
because server.php is modified to run server on any directory without putting project in xampp\htdocs , 
If You want to run through localhost replace index.php and .htaccess from public to root directory of project
hope this helps :)

如果您只需要創建新文件夾或文件,然后按您所知的方式運行它,請不要更改 laravel 項目上的任何文件。

如果你只想運行 laravel 項目,你可以運行它,但如果你想使用數據庫,你應該使用 xampp 或 wampp localhost 服務器。

希望你能成功。

這可能是由於各種問題:

  • 工匠服務不工作
  • 觸發文件權限問題
  • 文件夾權限問題
  • Apache 服務器狀態

您需要一一測試,例如創建一個單獨的文件夾,然后在一個新文件中使用簡單的echo "I am here"; 看看它是否有效。

下一步您需要檢查命令或替代

然后你需要檢查文件夾和文件的權限

如果問題仍然存在,則可能需要檢查服務器設置。

如果你們已經從遠程存儲庫或本地項目克隆項目

  1. 確保你有.env.example文件
  2. 如果存在,則復制內容並寫入名為.env 的新文件
  3. 如果沒有 .env.example 文件,則創建.env文件並從新的 Laravel 項目.env文件中粘貼文件

這樣我就解決了我的問題。 也希望能幫到你!!!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM