Skip to content

Instantly share code, notes, and snippets.

@saranemohan
Last active December 7, 2023 05:57
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save saranemohan/1938fe3ce03b79dc1350d5d44dfc4b86 to your computer and use it in GitHub Desktop.
Save saranemohan/1938fe3ce03b79dc1350d5d44dfc4b86 to your computer and use it in GitHub Desktop.
Deploy laravel with ease. using command line, integrate latest update from git remote repository. all necessary steps to be followed for laravel is implemented. a log file is recorded for future reference.
#!/bin/bash
mkdir -p deploy_log
file_name=deploy_log/deploy_$(date "+%Y_%m_%d_%H_%M_%S")
echo 'Deployment Started . . . . .' |& tee $file_name
chown -R www-data:www-data storage/
chmod -R 777 storage/
chown -R www-data:www-data bootstrap/cache/
chmod -R 777 bootstrap/cache/
sudo -u www-data php artisan down |& tee -a $file_name
git reset --hard
git pull origin development |& tee -a $file_name
composer install --no-plugins --no-scripts |& tee -a $file_name
composer dump-autoload |& tee -a $file_name
chown -R www-data:www-data storage/
chmod -R 777 storage/
chown -R www-data:www-data bootstrap/cache/
chmod -R 777 bootstrap/cache/
sudo -u www-data php artisan migrate |& tee -a $file_name
sudo -u www-data php artisan cache:clear |& tee -a $file_name
sudo -u www-data php artisan optimize |& tee -a $file_name
npm install |& tee -a $file_name
npm run dev |& tee -a $file_name
sudo -u www-data php artisan up |& tee -a $file_name
chown -R www-data:www-data storage/
chmod -R 777 storage/
chown -R www-data:www-data bootstrap/cache/
chmod -R 777 bootstrap/cache/
echo 'Deploy finished . . . !' |& tee -a $file_name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment