Hi, I've researched many tutorials how to deploy a laravel project. I'm using bitbucket, thus I want my laravel project to be retained so I can push easily. What I did was create a folder named projects, then another folder inside it named hrmis, then cloned my laravel project there from github/bitbucket. After that, I delete the public_html folder from root directory of the website, then symlinked my --public-- folder to public_html using the code:
ln -s ~projects/hrmis/public ~/public_html
But I'm getting 403 forbidden error. I tried setting all my files' permission temporarily to 777 but got no luck. Do you have any suggestions?
I know it is quite boring but really really really try https://forge.laravel.com/ I love it and I do not want to get back to install it yourself times.
Back to your question however. For me it looks like the simplest way to solve your problem is not to edit the project but to edit ngnix config (sites-available) and point it to the correct laravel directory. It should look something like this:
This is my build shell script for one of my projects. you may be able to take something from this;
#!/bin/sh
UNIX_TIME=$(date +%s)
DEPLOYMENT_DIRECTORY=$UNIX_TIME
mkdir -p $DEPLOYMENT_DIRECTORY
git clone --depth 1 [email protected]:novate/speakernetv6.git $DEPLOYMENT_DIRECTORY
cd $DEPLOYMENT_DIRECTORY
cp ../master/.env .
composer install --no-dev
cd ..
echo emptying storage
rm -R $DEPLOYMENT_DIRECTORY/storage/app
#rm -R $DEPLOYMENT_DIRECTORY/storage/framework
rm -R $DEPLOYMENT_DIRECTORY/storage/logs
rm -R $DEPLOYMENT_DIRECTORY/storage/medialibrary
rm -R $DEPLOYMENT_DIRECTORY/storage/debugbar
chgrp -R www-data $DEPLOYMENT_DIRECTORY/storage $DEPLOYMENT_DIRECTORY/bootstrap/cache
chmod -R ug+rwx $DEPLOYMENT_DIRECTORY/storage $DEPLOYMENT_DIRECTORY/bootstrap/cache
#link to the latest deployment from Live
ln -s -n -f -T $DEPLOYMENT_DIRECTORY Live
# create a link from storage/app to public
ln -s -n -f -T /var/www/html/speakernet.co.uk/master/storage/app $DEPLOYMENT_DIRECTORY/storage/app
cd Live
echo link public to storage
php artisan storage:link
echo route:cache command
php artisan route:cache
echo config:cache command
php artisan config:cache
cd ..
echo Done!
echo Migrations required?
echo
exit
The script uses the unix time as the name for a deployment folder.
It clones the repository into the deployment folder
It runs composer to install all dependencies
copies the .env file from a master folder
creates a symlink from deployment into the master folder for storage
sets the permissions of everything
changes into the Live folder and clears laravel caches
My Apache virtualHost points to the Live folder for its directory
Deployment (running ./build.sh from the project folder) takes about 5 seconds and the changeover is immediate. Any logged in users will be logged out because their sessions will be lost.
I can find a quiet time to switch and use Google Analytics real-time view to see if I will upset anyone.
The script has been robust but of course needs to be adapted to your own circumstances.