Steps to move laravel project from localhost to production server

Steps to move laravel project from localhost to production server

    Moving laravel from localhost to a live server you should follow the three steps

    1. Configure your .env file

    2. Execute the artisan commands

    3. Permission command if you have 403 error

    1. Configure your .env file


    In the above, you need to make sure, you have write your correct url name, database name and password and user name.

    2. Execute the artisan commands

    Run the below commands in your linux terminal

    1. composer install

    2. php artisan key:generate 

    3. php artisan cache:clear

    4. php artisan migrate

    5. chmod -R 775 storage/

    6. composer dump-autoload

    7. sudo chown -R apache storage

    8. sudo chown -R apache bootstrap/cache

    9. chmod -R 775 storage

    10. chmod -R 775 bootstrap/cache

    The above commands should be use for Linux or Mac user.

    Three commands I often run, these are very useful

    php artisan config:clear
    php artisan cache:clear
    php artisan optimize

    Windows users

    For windows follow the below command

    1. Go to the root of your Laravel installation

    (where composer.json and artisan live).

    2. Change the owning user and group, where yourusername is your username:

    sudo chown -R yourusername:www-data storage

    This recursively (-R) sets the user:group owners to yourusername:www-data in all files and folders from storage onward.

    3. Add the write permission for both you and the www-data group

    sudo chmod -R ug+w storage
    This recursively (-R) adds (+) the write flag (w) to the user (u) and group (g) that own the files and folders from app/storage onward.

    4. Additionally, some suggest you may need to flush the application cache and regenerate the Laravel autoload files.

    php artisan cache:clear

    5. Finally, you may want to regenerate Composer’s autoload files

    composer dump-autoload


    3. Permission command if you have 403 error

    Now if you see the below error or 403 error

    pcfg_openfile: unable to check htaccess file

    It means .htaccess file is not readable apache

    chmod 644 /var/www/html/ 

    Also the public directory needs to be executable and readable 

    chmod 755 /var/www/html/www.example/public/ 

    Solutions for Laravel Admin Panel

    Share hosting Laravel