Many articles that I read has wrong way of deploying Laravel application on shared hosted environment inside cPanel.
Most of them stated that uploading the project folders inside the cPanel and copy the public folder to public_html and modify the Laravel framework ( public/index.php).
I believe the following steps is the correct way to deploy and easier way to maintain continuous integration and continuous delivery.
STEP 1: Login to your cPanel
Login to you cpanel with your login credentials and then go to Advance section and inside it you will find terminal.
Note: Make sure you have SSH access from your provider
STEP 2: Install Composer
Configure your shell environment to use composer
echo 'alias composer="php -d allow_url_fopen=On /home/USERNAME/composer.phar"' >> ~/.bashrc
curl -k -O https://getcomposer.org/installer
php -d allow_url_fopen=On installer
STEP 3: Upload your Project
Upload you project to home directory of the cPanel file manager.
STEP 4: Run Following Commands
Lets say your app is in
app folder. Go your your
to install all php dependencies if you have not uploaded
Then change your environmental variables in the .env file
Generate a new application key
php artisan key:generate
Migrate and seed your database as per you need.
Set the correct folder permissions
chmod -R 775 storage
STEP 5: Make your app accessible for public
Back up your public_html folder and remove it.
Then create a symlink
ln -s /home/user/app/public /home/user/public_html
Create a symlink for your storage
ln -s /home/user/app/storage/app/public /home/user/public_html/storage
Run storage link
php artisan storage:link
Your app should work now.
1. Migrate Tables => `php artisan migrate`2. Seed Database => `php artisan db:seed --class=InitDbSeeder`3. Start Server => `php artisan serve`4. Watch Server => `yarn watch` or `npm run watch`
# Turn on maintenance mode
php artisan down# Turn off maintenance mode
php artisan up# Sync composer.local with composer.json
composer update --lock# Create Model
php artisan make:model Flight# Create Model & Migration
php artisan make:model Flight -m# Create Migration
php artisan make:migration create_users_table --create=users# Update Existing Migration
php artisan make:migration add_votes_to_users_table --table=users# Create Controller
php artisan make:controller PhotoController# Composer dump
composer dump-autoload# Clear caches
php artisan cache:clear# Clear and cache routes
php artisan route:clear
php artisan route:cache# Clear and cache config
php artisan config:clear
php artisan config:cache
YOU ARE DONE! HAPPY CODING!