lcopeland's avatar

Moving laravel to production - is it possible?

I'm having a lot of trouble getting my Laravel 5 development project onto a different server (Ubuntu LTS). I've tried moving the files with git, FTP, and even a thumb drive, but no matter how many times I move things around and change settings, I can't even get the most basic pages of my site to load properly. Just a few of the issues I'm seeing:

  1. untraceable White Screens Of Death
  2. caching issues where month old versions of my routes and views are called instead of the real ones
  3. permission complaints from composer and artisan even when the entire directory is given full permissions
  4. 404 errors from my controllers, even when the routes.php seems to be working fine.
  5. generally, the whole routes->controllers->views structure seems to fall apart when I move my filesystem to a different computer.

Does anybody have a workflow for moving laravel installs that they could share? What files to copy, what should just be installed locally, and what tips and tricks to keep in mind? I've been working on this for more than two days now and making no progress, and the particularities of this framework when it comes to installation are driving me up the wall.

Thanks!

0 likes
8 replies
HFH's avatar
  1. I've run into the WSOD numerous times. Changing the permissions of Storage/ fixed that particular problem for me.
sudo chmod o+w -R Storage/
pmall's avatar

generally, the whole routes->controllers->views structure seems to fall apart when I move my filesystem to a different computer.

Whoa.

HFH's avatar

Any time I move a Laravel application to production, I run a composer update and a php artisan clear:cache.

composer update
php artisan cache:clear
lcopeland's avatar

@HFH I've run into that a couple times but I've resolved it the way you've said. But not all of my WSODs have been based around storage, and often they clear up only to reveal another issue...

Thanks for that cache clear command, though. I didn't know about that one. However, it does strike me as strange that the caching issues only showed up after I moved the installation - shouldn't it stand to reason that they should have been present on my development server as well?

lcopeland's avatar

My current issue is getting these 404 errors from my controllers. Interestingly, while trying to copy over my project files into an existing laravel install, I noticed that the Welcome controller (with the logo/cheesy quote) would work just fine... but I can't get any of the other ones to do the same. Is this another permissions issue or something?

MikeHopley's avatar

Is your development environment using Windows, by any chance?

I develop locally on a Windows machine, but my web hosting is Ubuntu. Occasionally this causes irritating bugs, because Windows is case insensitive and Unix is not.

For example, say you have a route called /userProfile, but in your routes file you accidentally typed /UserProfile. When you visit the /userProfile route in Windows, it will work. But when you visit it in Unix, it will fail with a 404.

lcopeland's avatar

Gah, I ended up figuring out the 404 issue, it was a typo in the apache2 .conf file that was preventing mod_rewrite from taking effect on the URLs. Now to just figure out all the rest of them!

EDIT: After two days, I've finally gotten through it. I'll share some tips for anybody else who might be running into similar issues:

Problem: WSOD

Solution: Usually a permissions issue with /storage (make sure your chmods are recursive!) but this can also be caused by a missing or typo-ridden .env file. Make sure it contains the correct app and db stuff.

Problem: Seeing an old version of your website when you visit with a browser, and your routes don't work.

Solution: Laravel is storing incorrect cached versions of the site's resources. Make sure you clear the view cache AND the routes cache as these can double up.

Problem: 404 errors

Solution: this usually isn't laravel, but a problem with mod_rewrite. Double check that apache/whatever is running your server has it enabled and that the .conf files for your site are enabled properly

Problem: [Runtime error] service provider does not exist and could not be created

Solution: Another permissions issue, this time on composer: make sure composer update runs with sudo permissions

Problem: Css not updating.

Solution: Check and make sure your Public folder has everything up to date, since it's a little more susceptible to slipping through the cracks when synchronizing versions. You do not need bower, gulp, or node.js for a production laravel installation to run, so those will not fix your problem.

Ultimately, I'd also suggest installing laravel on your target machine first, and then updating only the Http, Resources, Public, Database, Config/app.php, and .env files if nothing seems to be working. Then it might be worth it to try an auto-updating git solution to save on time. Hopefully this goes easier for others than it did for me.

nate.a.johnson's avatar

A combination of git, forge, envoyer and a cloud host like linode is well worth the monthly price in terms of frustration and convenience.

Please or to participate in this conversation.