online software programming courses

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

APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:J7lE5o1vez3Z7oypDuB9KENMn7azHatg7qMhOfX8/tg=
APP_DEBUG=true
APP_URL=https://info.dbestinfo.com/
FORCE_HTTPS = true
ADMIN_HTTPS = true
LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=info_dbestinfo
DB_USERNAME=root
DB_PASSWORD=xxxxxxxxxxx

 

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

 

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/www.example.com/public/.htaccess 

Also the public directory needs to be executable and readable 

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