sgupta1979's avatar

Laravel application is not loading

I copied image of my server to new server which is having laravel application. Application is not loading with the domain and throwing below error

/ define('LARAVEL_START', microtime(true)); / |-------------------------------------------------------------------------- | Register The Auto Loader |-------------------------------------------------------------------------- | | Composer provides a convenient, automatically generated class loader for | our application. We just need to utilize it! We'll simply require it | into the script here so that we don't have to worry about manual | loading any of our classes later on. It feels great to relax. | / require DIR . '/../vendor/autoload.php'; / |-------------------------------------------------------------------------- | Turn On The Lights |-------------------------------------------------------------------------- | | We need to illuminate PHP development, so let us turn on the lights. | This bootstraps the framework and gets it ready for use, then it | will load up this application so that we can run it and send | the responses back to the browser and delight our users. | / $app = require_once DIR . '/../bootstrap/app.php'; / |-------------------------------------------------------------------------- | Run The Application |-------------------------------------------------------------------------- | | Once we have the application, we can handle the incoming request | through the kernel, and send the associated response back to | the client's browser allowing them to enjoy the creative | and wonderful application we have prepared for them. | */ $kernel = $app->make(Illuminate\Contracts\Http\Kernel::class); $response = $kernel->handle( $request = Illuminate\Http\Request::capture() ); $response->send(); $kernel->terminate($request, $response);

0 likes
3 replies
LaryAI's avatar
Level 58

It looks like you're encountering an issue with your Laravel application after migrating it to a new server. The error message you provided seems to be related to the initial bootstrapping of the Laravel application. Here are a few steps you can take to troubleshoot and resolve this issue:

  1. Check PHP Version: Ensure that the PHP version on the new server matches the version required by your Laravel application. Laravel has specific PHP version requirements, and using an incompatible version can cause issues.

  2. Install Composer Dependencies: After copying your application to the new server, you need to install the Composer dependencies. Navigate to your project directory and run:

    composer install
    
  3. Set File Permissions: Ensure that the storage and bootstrap/cache directories are writable by the web server. You can set the appropriate permissions using:

    sudo chown -R www-data:www-data storage bootstrap/cache
    sudo chmod -R 775 storage bootstrap/cache
    
  4. Environment Configuration: Make sure that the .env file is correctly configured for the new server environment. This includes database credentials, application URL, and other environment-specific settings.

  5. Clear Cache: Clear any cached configuration, routes, and views. You can do this by running the following Artisan commands:

    php artisan config:cache
    php artisan route:cache
    php artisan view:cache
    php artisan cache:clear
    
  6. Check Web Server Configuration: Ensure that your web server (Apache, Nginx, etc.) is correctly configured to serve your Laravel application. This includes setting the document root to the public directory of your Laravel application.

  7. Check Error Logs: Check the web server error logs and Laravel logs (located in storage/logs/laravel.log) for any specific error messages that can provide more insight into the issue.

Here is a summary of the steps in code format:

# Step 2: Install Composer dependencies
composer install

# Step 3: Set file permissions
sudo chown -R www-data:www-data storage bootstrap/cache
sudo chmod -R 775 storage bootstrap/cache

# Step 5: Clear cache
php artisan config:cache
php artisan route:cache
php artisan view:cache
php artisan cache:clear

By following these steps, you should be able to identify and resolve the issue preventing your Laravel application from loading on the new server. If you continue to experience problems, please provide more specific error messages or logs for further assistance.

tykus's avatar

You don't have PHP installed and/or the web server is not correctly configured to delegate to the PHP service.

What web server are you running on the new host?

Snapey's avatar

it just dumped the contents of index.php because your server does not understand what to do with php files

Please or to participate in this conversation.