If your host has PHP and MySQL, then there is a good chance that they can run Laravel. There are a few other requirements, such as certain PHP extensions, but those are fairly common. The only real issue is Composer. If your host can’t (or won’t) run Composer, then forget about it. 🙁

But if they can, then most likely you can install Laravel. 🙂

If they have Composer already installed, then you’re all set. If not, then you must install yourself, but it’s not too hard. The directions on the Composer Download page are great and they work on many machines. For shared hosting, however, you probably will need to make some small changes.

If you’re using CiviHosting, we of course install Composer for you, but here is the script we use to do it and you can use those on other hosts. You may need to change just the first line:

You can either run the above manually, or you can save all the above code in a file called installcomposer.sh or some such, make it executable, and then execute it. Then you will have the latest Composer installed and ready to go.

Now to install Laravel, we just use Composer, by first downloading Laravel:

and then making a new Laravel installation with this command:

But that only works if have you have an alias to the laravel executable, which you may not have. At CiviHosting, we don’t have (nor need) that. And even if you do, then there is the pesky sh: composer: command not found problem that doesn’t always have a solution. 🙁

Therefore the simplest way is to install Laravel via the Composer create-project command:

What this does is creates a new Laravel install in a subdirectory called blog. Yes, that’s kind of a silly example but that’s the one used online so we just copied it. In practice, you might want to use this:

which installs Laravel in the current directory.

What this does is give you a set of files and directories:

which is great, but if this is your document root (meaning the directory that is the “home” directory of your site) then you’ve got a problem, because the real document root of Laravel must be the public directory there. We we must change our document root to that directory.

Each host has a different way of allowing you to do that. On CiviHosting’s Control Panel, there is a tab called Document Roots. Click on that. Then find the URL you want to change and click the Change button.

On the next page you will see that you can either type in the directory you want, or you can click the little directory icon to get a popup window with a list of directories you can click on. Just click on the public directory and then click Select and then click Update.

That’s it. Your Laravel site is now ready. 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *