We help IT Professionals succeed at work.

Could you point the better strategy to deploy a Laravel project at host ?

Eduardo Fuerte
on
Hi Experts

Could you point the better strategy to deploy a Laravel project at host ?

My hosting provider offers cPanel.

(I intend to do that to my own site)

Another option could be FTP - but I guess to transfer a complete Laravel project (with vendor folder) would be cumbesome to be done that way.

Thanks in advance.
Comment
Watch Question

CERTIFIED EXPERT
Most Valuable Expert 2018
Distinguished Expert 2019
Commented:
Hey Eduardo,

There are a few things that you can do to make deployment easier. First off, you could push all of your development code to a central repo, such as those hosted by GitHub or BitBucket. Not ony does this keep all of your code version controlled and backed up, but it also makes deployment much easier. You tend to version control your application files and exclude the core libraries, such as Laravel itself, plus all of the Vendor libraries.

Once you've got a Git repo setup, then you would SSH into your server and pull the repo into the correct folder on the server. Once you've done that, you would run composer install, and that would pull down all the Composer libraries (vendor folder etc).

You would then need to edit your .env file (usually only the first time you deploy) as these settings are likely to be different between your dev server and your production server.

Finally, once everything is installed and configured, you'd run your normal artisan commands, such as artisan key:generate, artisan migrate, artisan db:seed etc. You might also want to clear down the cache etc.

In the future, when you want to deply updates, it's generally a little easier. You make sure you've pushed any local changes you've made to the remote Git repo. Login to your server, and run git pull. That pulls the changed files from the repo onto your server. Then you can run your migrations if needed (plus any cache clears etc). You could even write a simple bash script to do this - then the update becaomse as easier as running a single command on your server.
Eduardo FuerteDeveloper and Analyst

Author

Commented:
Hi Chris


I'm better studying your reply.

(it's not the company's site we are interacting last questions, just my one)
CERTIFIED EXPERT

Commented:
Hi,

Laravel or regular website I would use the same strategy.

Have a list of your actual PHP version, settings and ini file to compare with the one from the hosting company.

From Cpanel create the DB User and DB and import the data.
From Cpanel set PHP version, it is better to set it, If you keep the default value, when they will update the server it may break your code.
From Cpanel Install HTTPS.
Using FTP upoad your files. (some files and directories may need Chmod adjustment to work fine espacially upload dir and config file)
Test your pages and backend form. (it may required some PHP adjustment, ask your hosting company if you can have your own PHP.ini settings)

I usually remove everything is not required from the vendor directory but you know these days hosting package usually have enough space to keep it like it is.
Eduardo FuerteDeveloper and Analyst

Author

Commented:
Thank you for your replies.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.