Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

peter279k's avatar

Laravel 5.3 project deployment

Hi all, what's the proper way to deploy the Laravel 5.3 projects ? I usually use the following method to deploy the Laravel app. Step 1: ssh the server (either shared hosting or VPS.)

Step 2: cd /path/to/document_root.(public_html or /var/www/html)

Step 3:git clone https://github.com/peter279k/figlet-generator.git

Step 4: cd figlet-generator/

Step 5: download the Composer.

Step 6:php composer.phar install.

Step 7: cd public/

Step 8: download bowerphp.phar.

Step 9:php bowerphp.phar install then cd /path/to/document_root

Step 10: make sure the storage folders has the write permission.

Step 11:cp -r figlet-generator/ ../

Step 12:rm -r figlet-generator/*

Step 13: cp ../figlet-generator/public/* ./figlet-generator/

modify the index.php in ./figlet-generator

change require __DIR__.'/../bootstrap/autoload.php';

to require __DIR__.'/../../figlet-generator/bootstrap/autoload.php';

change $app = require_once __DIR__.'/../bootstrap/app.php';

to $app = require_once __DIR__.'/../../figlet-genertor/bootstrap/app.php';

Step 14: rm -rf ../figlet-generator/public

Step 15:cd ../figlet-generator

Step 16: cp .env.example .env then run: php artisan key:generate

Step 17: run: php composer.phar dumpautoload -o

Step 18: run: php artisan config:cache

Step 19: run: php artisan route:cache

Step 20: done.

Here is the link about this demonstration:

http://nttu.biz/figlet-generator/

perhaps it has the better way to deploy the Laravel projects?

0 likes
2 replies
willvincent's avatar

There is definitely a better way, by moving all of public into the root of the project, you expose all of the app's backend code to the web. Sure it can still be protected with webserver config/htaccess rules. But this is definitely not best practice. The app code should live outside of the docroot, always.

peter279k's avatar

Hi @willvincent , I think you misunderstand my approach. I move the root of project files to outside the document_root and move all the public into the root of projects. Here is my projects tree:

/var/www/html/
└── figlet-generator
    ├── bower_components
    │   ├── html2canvas
    │   │   ├── build
    │   │   ├── examples
    │   │   └── src
    │   │       └── renderers
    │   ├── jquery
    │   │   ├── dist
    │   │   ├── external
    │   │   │   └── sizzle
    │   │   │       └── dist
    │   │   └── src
    │   │       ├── ajax
    │   │       │   └── var
    │   │       ├── attributes
    │   │       ├── core
    │   │       │   └── var
    │   │       ├── css
    │   │       │   └── var
    │   │       ├── data
    │   │       │   └── var
    │   │       ├── deferred
    │   │       ├── effects
    │   │       ├── event
    │   │       ├── exports
    │   │       ├── manipulation
    │   │       │   └── var
    │   │       ├── queue
    │   │       ├── traversing
    │   │       │   └── var
    │   │       └── var
    │   └── materialize
    │       ├── bin
    │       ├── dist
    │       │   ├── css
    │       │   ├── fonts
    │       │   │   └── roboto
    │       │   └── js
    │       ├── extras
    │       │   └── noUiSlider
    │       ├── fonts
    │       │   └── roboto
    │       ├── js
    │       │   └── date_picker
    │       ├── sass
    │       │   └── components
    │       │       ├── date_picker
    │       │       └── forms
    │       ├── templates
    │       │   ├── masonry-template
    │       │   │   ├── css
    │       │   │   └── js
    │       │   ├── parallax-template
    │       │   │   ├── css
    │       │   │   └── js
    │       │   └── starter-template
    │       │       ├── css
    │       │       └── js
    │       ├── test
    │       │   └── html
    │       └── tests
    │           └── spec
    │               ├── cards
    │               ├── collapsible
    │               ├── scrollFire
    │               ├── select
    │               ├── tabs
    │               ├── toast
    │               └── tooltip
    ├── css
    └── js

lab223@lab223-lee:/var/www$ ls figlet-generator/
app      bootstrap      composer.lock  config    gulpfile.js   phpunit.xml  resources  server.php  tests
artisan  composer.json  composer.phar  database  package.json  readme.md    routes     storage     vendor

Please or to participate in this conversation.