Since few months back, I have been using idcloudhost.com for my some of my Indonesia-based clients due to its familiar brand, competitive price, features and speed. All of my projects deployed there are built with Laravel.
In other post, I shared about how to deploy Laravel in shared hosting (in general). But at that time I didn’t notice that idcloudhost.com supported git
versioning system (with limitations). I believe nowadays, there are many shared hosting provider support it to. So now I’d like to share one way (there may be other way) to utilize it for Laravel project ?.
⚠️ Before you get hyped, there are few catches/limitations that I experience (may differ with other hosting providers):
composer
even if you managed to install it. So what I do is copying the whole vendor
directory to the shared hosting. Unfortunately, I also need to copy the vendor directory again every time new dependencies added and/or new seeder/migration files created (sigh) ?Ok, here we go.
First, find “Git™ Version Control” menu in your cPanel and go through the simple wizard to create a repo & clone from a public URL.
If everything goes well, you should see all your files pulled from remote repository to the configured path from your cPanel File Manager.
Second, after you setup Laravel .env
properly and copy vendor
directory, create a simple bash
script to trigger git pull
from remote repo & deploy the latest version. We will run this script automatically using cron job.
# customize this based on your own paths SRCPATH=/home/user/app # path to your git repo PUBLICPATH=/home/user/public_html/app # public entry-point for the app. In this example, I use subdomain eg. app.example.com BACKUPPATH=/home/user/backup # where I store customized index.php # print the date for logging purpose /bin/date # trigger git pull # for some reason, directly running git binary is prohibited /usr/bin/uapi VersionControl update repository_root=$SRCPATH branch=master # laravel migration and cache management # customize this to suit your need cd $SRCPATH && /usr/local/bin/php artisan migrate:fresh --seed cd $SRCPATH && /usr/local/bin/php artisan cache:clear cd $SRCPATH && /usr/local/bin/php artisan config:cache # copy public files to public_html path /bin/cp -Rf $SRCPATH/public/* $PUBLICPATH /bin/cp -Rf $SRCPATH/public/.htaccess $PUBLICPATH # replace original index.php with custom one /bin/cp -f $BACKUPPATH/index.php $PUBLICPATH
Save this file inside your home directory, eg. /home/user/deploy_latest.sh
then call it from a cron job (adjust the frequency to your need). I’d also suggest piping the output to a log file for eg. /home/user/deploy_latest.log
debugging purpose:
*/5 * * * * /bin/bash /home/user/deploy_latest.sh > /home/user/deploy_latest.log
That’s it!
Hope this help you ?
Reference
Getting verified SSL information with Python (3.x) is very easy. Code examples for it are…
By default, Spring Data Couchbase implements single-bucket configuration. In this default implementation, all POJO (Plain…
Last year, Google released Firebase Auth Emulator as a new component in Firebase Emulator. In…
One of the authentication protocol that is supported by most of Google Cloud services is…
If you need to to add a spatial information querying in your application, PostGIS is…
Amazon Web Service Transcribe provides API to automatically convert an audio speech file (mp3/wav) into…