skip to Main Content

SOLVED: My machine didn’t have MySQL installed and was having a hard time installing it and I still do.

I recently downloaded a Laravel project from cPanel and I wish to work on it. But when I try to run the project I get “500 server error”.

After searching on Google, I tried the following steps

composer update --no-scripts
php artisan key:generate
php artisan migrate

This does not seem to be doing anything. How do I run the project on my local machine that I downloaded from the cPanel?

3

Answers


  1. First , Download the database from cpanel which is used in laravel project .

    Then follow any one step below .

    1. Upload the database in your localhost mysql .

      • then Change your env files as per your local system .
      • Install composer using following command .

        composer install

      • Then update the compsoser From your composer.json file .
        Composer update
        composer dump-autoload
      • Now run php artisan serve

    If you find any difficult in the first step , follow the second one.

    Install new laravel project using following command .

      `composer global require laravel/installer`
    

    Create new project Laravel

     `laravel new projectname`
    

    Then just copy paste the directories app/ , Resources, /Public , /config .

    Do not touch anything inside config/config.php

    Just change the database name and username, password in .env file ..

    Then run
    php artisan serve

    If you still cant able to do it , comment here

    Login or Signup to reply.
  2. You may want to see what that error is in the log file:

    Log file location:

    /storage/logs/laravel.log`
    

    The laravel.log file mentioned above may have a date with it on the name.

    The 500 error is because the stack trace is turned off in the .env file with APP_DEBUG=falsewhich may be by design since it’s on a live server.

    Login or Signup to reply.
    1. Download the files in "public_html" folder and project folder(in my case it is "LMS" folder – refer screenshot).
      enter image description here
    1. Export the database from phpmyadmin in cPanel which is used in Laravel project

    2. Go inside the Project folder(in my case LMS folder) and delete all the content inside the "public" folder. Then you will have an empty public folder inside your project folder(LMS folder)

    3. Now copy and paste all the content inside "public_html" folder that is downloaded from cPanel into the previously emptied "public" folder inside the project folder(LMS)

    4. Import the exported database to locally created database

    5. Change following lines in index.php file which is inside the local "public" folder

    These two lines

    require __DIR__.'/../LMS/vendor/autoload.php';
    $app = require_once __DIR__.'/../LMS/bootstrap/app.php';
    

    into these two

    require __DIR__.'/../vendor/autoload.php';
    $app = require_once __DIR__.'/../bootstrap/app.php';
    

    Notice that we have removed the "LMS" in the paths

    1. Go to the .env file in the project root and change these settings that matches to your local environment

      DB_CONNECTION=mysql

      DB_HOST=127.0.0.1

      DB_PORT=3306

      DB_DATABASE=lms_trends_new

      DB_USERNAME=root

      DB_PASSWORD=root

      //Only for MAMP users

      DB_SOCKET=/Applications/MAMP/tmp/mysql/mysql.sock

    2. Run following commands

      $ php artisan config:cache

      $ composer dump-autoload

    3. Finally run your project with following command

      php artisan serve

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search