Skip to content

Instantly share code, notes, and snippets.

@bedus-creation
Last active July 2, 2019 05:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bedus-creation/cf1b2311cd793d479936e9a16719392a to your computer and use it in GitHub Desktop.
Save bedus-creation/cf1b2311cd793d479936e9a16719392a to your computer and use it in GitHub Desktop.
Deploy Laravel on the server

To run on local computer

I believe php of 7.x, composer, git, mysql and sqlite database is installed on your machine.

  1. Clone the repository
git clone git@gitlab.....
  1. GO to the project root
cd /path/to/cloned/git-repo/
  1. install depenency
composer install 
  1. install node depedency and build the assets(css and vue)
npm install && npm run watch
  1. setup environment for laravel(initially database) i.e go to the project folder and edit .env

DB_CONNECTION=mysql
DB_HOST=192.168.10.10
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
  1. migrate the migrations
php artisan migrate
  1. serve the project
php artisan serve --port=8080

To Edit css

  1. Go to resources/assets/sass you will see all the resources of sass
  2. after changing the file you need to rebuild the file
npm run dev # for development process
npm run watch # to watch file changed rebuild for development version
npm run prod # for production version

To deploy on the server

There is a script file deploy.sh, please copy the code and paste on forge server's deploy script.

# Turn on maintenance mode
php artisan down
# Pull the latest changes from the git repository
git pull origin master
# Install/update composer dependecies
composer install --no-interaction --prefer-dist --optimize-autoloader --no-dev
# Run database migrations
php artisan migrate
# Clear caches
php artisan cache:clear
# Clear expired password reset tokens
php artisan auth:clear-resets
# Clear and cache routes
php artisan route:clear
php artisan route:cache
# Clear and cache config
php artisan config:cache
php artisan config:clear
# Turn off maintenance mode
php artisan up
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment