Deploying Laravel/Lumen Projects
This is very short blog on what should be the steps when deploying any laravel/lumen project on your server.
Its very easy to get started with laravel/lumen as we have very strong commans avaialble to use i.e artisan which also helps us to start a loal web server for testing, but things become very complicated when you are tryng to deploy application on server for the very first time.
So in this blog I will list down the steps that I follow as well as try to exlpain my reasons behind it.
- Check you PHP version(In case of multiple PHP version installed, check which one is configured for your application in NGINX/Apache). This is very important steps and it should be within the range that your laravel version supports it.
- Copy you application source code inside the websites root directory. for eg, in Apache its generally /var/www/your-website-name.
- Rename .env-sample to .env and updates it’s configuration accordingly
- Install Composer if its not installed already
- Run composer install to resolved any dependencies.
- Run your migration command to created your database schema and seed any values if needed.
- Run chown command to updated owner of all files within you application(eg. for apache its www-data)
- Run chgrp command to update the group(eg. for apache its www-data)
- Create a link for storage folder in your application’s public folder
ln -s /path/to/laravel/storage/app/public /path/to/public/storage
Note: Make sure to delete any logs file that you have in storage folder, otherwise it will create some issues in productions when you are woprking on windows system and deploying application on linux based OS( eg. CentOS, Debian etc)
- After that open you web server configuration file and point you web server to your applications public directory. Make sure to restart your web server after making any changes to it for it to take effect.
- Add cron job if available any to cron tab
* * * * * cd /path-to-your-project && php artisan schedule:run >> /dev/null 2>&1
Thanks for reading…