Upload laravel app to  Cpanel host with git

Tip: Makes sure the PHP version running in you local development is the same version on your remote server!

LOCAL DEV
$ cd HOSTING_FOLDER_NAME
$ git init
$ git add .
$ git commit

Create repo in github and copy the URL of the new REPO.

MAKE SURE TO SELECT PRIVATE OR PUBLIC

$ git remote add production https.....github/repo
$ git remote -v
$ git push production master

PRODUCTION REMOTE: CPANEL

Create a sub domain: example.domain.com

Login to Cpanel Main Dashboard, scroll to ADVANCED and look for Terminal:
example URL: https://xxxxxxxx.prod.xxx.secureserver.net:2083/cpsessxxxxxxxxx/frontend/paper_lantern/terminal/index.html

access shell - video t=114

NOTE: Godaddy Cpanel will alreay or should already have git and composer installed in their shared hosting. For example, these are the version i have as of Oct. 2023:

  • git version 2.37.5
  • Composer version 2.2.12 2022-04-13 16:42:25

Cd to the root directory of the hosting domain folder you will be installing Laravel:

$ cd ~/

$ mkdir-p laravel/[PROJECTNAME]

$ cd laravel/[PROJECTNAME]

Once inside the hosting folder:
$ git init
$ git remote add production https.....github/repo
$ git pull production master
$ composer install --ignore-platform-reqs --optimize-autoloader --no-dev

>>>>>>>>>>>>>>>>>>>>>> ERRORS <<<<<<<<<<<<<<<<<<<<<<<<<

Error #1: Your lock file does not contain a compatible set of packages. Please run composer update.

Solution: $ composer update

Error #2 Your requirements could not be resolved to an installable set of packages.

Solution: $composer install --ignore-platform-reqs or $composer update --ignore-platform-reqs

Error #3 - > Illuminate\Foundation\ComposerScripts::postAutoloadDump Parse error: syntax error, unexpected ':', expecting '{' in /home/g01oza5iw2jh/laravel/uplv1/vendor/symfony/deprecation-contracts/function.php on line 23

Solution: Run $php -v , you may be not be running the correct php version. In my case, Cpanel had version 5, this was the ouput of $php -v:

PHP 5.6.40 (cli) (built: Aug 17 2023 16:16:52)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2015, by Zend Technologies

STOPPED!!! I stopped here with Godaddy Cpanel :( because my sharedhosting does not provide MultiPHP so I can't select a later version of PHP to a specific domain. Sucks.

Mmake copy and open .env to update database infromation

$ mv .env.example .env
$ nano .env
APP_NAME
APP_ENV=production
APP_DEBUG=false
APP_URL=https://DOMAIN.COM

DB_CONNECTION

DB_CONNECTION=mysql
DB_HOST=xxxxxxxxxxx
DB_PORT=3306
DB_DATABASE=xxxxxxxx
DB_USERNAME=xxxxxx
DB_PASSWORD=xxxx

For Twilio If any:

# SMS TEXT MESSAGES
TWILIO_SID=xxxxxxxxxx
TWILIO_TOKEN=xxxxxxxx
TWILIO_FROM=+xxxxxxx

[SAVE CHANGES]: control + x > y

$ php artisan key:generate
$ php artisan migrate
$ php artisan config:cache
$ php artisan route:cache
$ php artisan view:cache
$ php artisan storage:link
$ cd ..
video  t=411
$ ln -s HOSTING_FOLDER_NAME/public chatapp

CREATE SYMBOLIC LINK
ln -s private/laravel/public public_html
ln: failed to create symbolic link 'public_html': Permission denied

SOLUTION:
cd /home/edwin/web/share.[DOMAIN].com/
sudo ln -s private/laravel/public public_html
sudo chown edwin:www-data private/laravel/public/
sudo chown -h edwin:www-data public_html
ls -la

drwxr-x--x 3 edwin edwin    4096 Jun 21 07:30 private
lrwxrwxrwx 1 edwin www-data   22 Jun 22 18:20 public_html -> private/laravel/public
drwxr-x--x 2 edwin www-data 4096 Jun 21 07:27 public_html_OG
dr-xr-x--x 2 edwin edwin    4096 Jun 21 07:27 stats


LOCAL DEV
ANY CHANGES IN THE LOCAL DEV, just push the new changes to github
/f/apachefriends/xampp/htdocs/over-imgV5/REACT/MYOWN/IONIC/BACKEND-laravel-api-template/laravel-api-upload

$ git push production master

PRODUCTION REMOTE:
~/web/share.[DOMAIN].com/private/laravel/

$ cd HOSTING_FOLDER_NAME
$ php artisan down
$ git pull production master
User: [email protected]
Password: example key location: g/Program Files/winscp/keys/Hestia-SSH/github.txt
$ php artisan optimize
$ php artisan view:cache
$ php artisan up

Video: X6t7xw1HU-s