laravel.htaccesspermissionsruntime-errorlaravel-artisan

403 Forbidden and 500 Internal Server Error after moving Laravel to a new server without terminal access


I'm encountering an issue after migrating my Laravel application from one server to another. When I try to access the website, I get the following errors:

I do not have terminal access on the new server, so I can't run any artisan or composer commands. Here are the details of my setup:

  1. Migration steps I followed:

I transferred all Laravel files to the new server using File Manager. I migrated the database and updated the .env file accordingly.

  1. Errors encountered:

403 Forbidden occurs when accessing the root domain. 500 Internal Server Error appears when trying to handle custom error pages via .htaccess.

  1. What I've tried:

Updated the .env file to match the new database settings. Checked and changed file and folder permissions (set storage and bootstrap/cache to 775, .env to 644). Ensured the .htaccess file exists in the root Laravel directory with the following content:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
  1. New server environment:

cPanel without terminal access. PHP 8.0. Apache web server.

Main Question: How can I resolve the 403 Forbidden and 500 Internal Server Error issues in Laravel after migrating to a new server without terminal access? Is there anything else I should check or configure in cPanel or the Laravel files to ensure the application works correctly?

Additional Details: I checked the Error Logs in cPanel, which indicated an issue with Collection.php related to PHP. However, I am unable to run composer or artisan commands due to lack of terminal access.


Solution

  • Check whether the required PHP version is compatible with the PHP version on your server.

    1. Open the composer.json file and check the required PHP version under the require section.

    2. If the required PHP version is higher than what you have, add "platform-check": false in the config section.

    3. Run composer dump-autoload locally, then upload the changes using file manager.