You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

Laravel部署至InfinityFree服务器遇500内部错误求助

Troubleshooting Laravel 500 Error on InfinityFree

Hey there, let's work through this "Whoops, looks like something went wrong." 500 error you're hitting with your Laravel app on InfinityFree. These kinds of server errors usually boil down to a handful of common issues specific to cheap shared hosts like InfinityFree—let's break them down one by one:

1. First, Get the Exact Error Message

The generic 500 page doesn't tell us much. Let's enable debug mode to see what's really going on:

  • Open your .env file
  • Change APP_DEBUG=false to APP_DEBUG=true
  • Save the file and refresh your site. You should now see a detailed error message instead of the generic page. Important: Don't leave debug mode on once you fix the issue—it's a security risk.

If you still don't see a detailed error, check Laravel's log files in storage/logs/laravel.log. You can download this file via FTP to read it locally.

2. Fix File Permissions

InfinityFree has strict file permission rules, and Laravel needs write access to two key folders:

  • Connect via FTP or File Manager in your InfinityFree cPanel
  • Navigate to your Laravel project folder
  • Set the permissions for storage/ and bootstrap/cache/ folders to 755 (recursively, so all files inside get the same permission)
  • If 755 doesn't work, try 775 (but avoid 777—it's insecure)

3. Verify Your Full Database Configuration

You mentioned setting some DB values, but double-check you have all required fields filled in correctly in .env:

DB_CONNECTION=mysql
DB_HOST=sql302.epizy.com
DB_PORT=3306
DB_DATABASE=epiz_218...  # Make sure this is your full database name
DB_USERNAME=epiz_218...  # This is usually the same prefix as your database name
DB_PASSWORD=your_database_password_here  # Don't forget this!
  • Remove any extra spaces around the equals signs (e.g., DB_CONNECTION = mysql should be DB_CONNECTION=mysql—some servers choke on the spaces)
  • Confirm your database username and password match what's listed in your InfinityFree cPanel under "MySQL Databases"

4. Fix Your Deployment Directory Structure

This is a super common mistake with shared hosts:

  • InfinityFree's web root is public_html/—Laravel's public-facing files (like index.php) need to be inside this folder
  • Option 1 (recommended):
    1. Upload all your Laravel project files outside of public_html/ (e.g., in a folder called laravel/ at the same level as public_html/)
    2. Move all files from Laravel's public/ folder into public_html/
    3. Open public_html/index.php and update the paths to point to your Laravel folder:
      require __DIR__.'/../laravel/vendor/autoload.php';
      $app = require_once __DIR__.'/../laravel/bootstrap/app.php';
      
  • Option 2 (quick fix if you uploaded everything to public_html/):
    1. Move all Laravel files except the public/ folder up one level (out of public_html/)
    2. Move the contents of public/ into public_html/
    3. Update index.php paths as above

5. Clear Laravel Cache

Cached config or route files can cause issues after uploading. Since InfinityFree usually doesn't allow SSH access, try these steps:

  • Delete all files inside bootstrap/cache/ (don't delete the folder itself)
  • If you can enable debug mode, you can also create a temporary PHP file in public_html/ with this code, run it once, then delete it:
    <?php
    require __DIR__.'/../vendor/autoload.php';
    $app = require_once __DIR__.'/../bootstrap/app.php';
    $app->make(\Illuminate\Contracts\Console\Kernel::class)->call('config:clear');
    $app->make(\Illuminate\Contracts\Console\Kernel::class)->call('route:clear');
    echo "Cache cleared!";
    ?>
    

6. Check PHP Version Compatibility

Laravel has strict PHP version requirements:

  • Go to your InfinityFree cPanel > "PHP Configuration"
  • Make sure the selected PHP version matches what your Laravel version needs (e.g., Laravel 8 needs PHP 7.3+, Laravel 9 needs 8.0+, Laravel 10 needs 8.1+)
  • If your app uses an older Laravel version, you might need to switch to an older PHP version (but always try to keep Laravel updated for security)

Work through these steps one by one—chances are one of them will fix your 500 error. If you get a specific error message after enabling debug mode, we can dive deeper!

内容的提问来源于stack exchange,提问作者Igor Faria

火山引擎 最新活动