Skip to content

Instantly share code, notes, and snippets.

@meganlkm
Last active January 3, 2019 19:49
Show Gist options
  • Star 36 You must be signed in to star a gist
  • Fork 16 You must be signed in to fork a gist
  • Save meganlkm/15ae87674642590172c5 to your computer and use it in GitHub Desktop.
Save meganlkm/15ae87674642590172c5 to your computer and use it in GitHub Desktop.
setup a laravel5 project to deploy to a shared hosting provider
#!/bin/bash
myproject='myproject'
mywww='public_html'
# initialize project
composer create-project laravel/laravel $myproject --prefer-dist
cd $myproject
# fix paths to public
for f in server.php storage/framework/compiled.php; do
perl -pi -e "s|/public|/../${mywww}|" $f
done
# this regex needs to be executed every time the vendor code is updated
oldstr="\$this->basePath.DIRECTORY_SEPARATOR.'public'"
newstr="dirname(\$this->basePath).DIRECTORY_SEPARATOR.'${mywww}'"
sed -i '' "s|${oldstr}|${newstr}|" vendor/laravel/framework/src/Illuminate/Foundation/Application.php
# fix path to bootstrap
perl -pi -e "s|/bootstrap|/${myproject}/bootstrap|" public/index.php
# rename the public folder to match hosting providers web root
mv public $mywww
# create a directory for everything except the public directory
mkdir $myproject
# move stuff to app dir
mv {app,bootstrap,config,database,resources,storage,tests,vendor,artisan,.env*,*.js*,*.lock,*.php,*.xml,*.yml} $myproject
# use artisan to remove the compiled app
cd $myproject
php artisan clear-compiled
@TCB13
Copy link

TCB13 commented Feb 16, 2015

Great script, works just fine! Thank you.

@jebog
Copy link

jebog commented May 18, 2015

Great Job. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment