How to deploy Laravel 5.5 app to Godaddy cPanel shared hosting

11,670

Solution 1

I figured out how to deploy Laravel on a Godaddy shared hosting plan after reading more posts about the subject. Here are the steps I took:

  1. Created a new folder outside the public_html folder and uploaded all of the app files to that folder except the vendor folder.
  2. Using SSH access, I ran the command curl -sS https://getcomposer.org/installer | php in the newly created app folder on the server.
  3. I removed the public folder from the Laravel app folder, placed it inside the public_html folder and renamed it to the name of my project.
  4. I modified the file paths in the index.php in the project folder so they pointed to the laravel app folder like so:

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

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

  5. I installed the dependencies by running the command in SSH: php composer.phar install, then adding the necessary cache by running: php artisan config:cache

That was it. I did it using Godaddy cPanel shared hosting. Before attempting this make sure the PHP version is set to 7.1. I wanted to post my steps because I found some of the tutorials on this subject either were confusing, gave conflicting advice or didn't provide all the necessary steps.

Solution 2

The biggest problem you have is that GoDaddy's latest supported version of PHP is v5.6. Laravel v5.5 and later all require PHP v7.0 or higher. Apparently, they added PHP 7 support in late 2017.

I'd still highly recommend shifting to a much more reputable host like (closest comparison) BlueHost.com or DigitalOcean.com.


The second biggest problem you have is that GoDaddy won't let you actually run the artisan command, which Laravel really needs. It means 1. needing to apply database creation and migrations manually and 2. running all the artisan commands locally and uploading the entire project, in situ.

The third biggest problem is that composer doesn't run on GoDaddy, meaning you'll need to upload all the vendor directories, too.


Addendum: Here is a guide for how to deploy Laravel on shared hosts: https://www.youtube.com/watch?v=6g8G3YQtQt4

Solution 3

I do the followings steps in a shared hosting:

  1. compress the laravel proyect
  2. upload the new file .zip
  3. uncompress the project
  4. move all the project to the home directory, normally to public_html
  5. go to public folder and move index.php to public_html
  6. edit index.php in line 24 and 38 for laravel 5.8

line 24

require __DIR__.'/vendor/autoload.php';

line 38

require_once __DIR__.'/bootstrap/app.php';

this work for me in godaddy and inmotion

Share:
11,670
mdailey77
Author by

mdailey77

Software Developer interested in Angular, React, Typescript, Docker, and Azure DevOps.

Updated on June 08, 2022

Comments

  • mdailey77
    mdailey77 about 2 years

    I'm relatively new to Laravel. I'm confused on what is the proper way to deploy a Laravel 5.5 app to a Godaddy cPanel shared hosting. I've read multiple posts on the subject and they give conflicting advice.

    Part of what I'm not clear on is do I copy all my files to the server and then run the following composer commands?:

    composer install --optimize-autoloader and php artisan config:cache

    I get the part where I should create a folder on the server outside of the public_html folder, placing all of the app files there except what is in the app's public subfolder.

    If I want to run the app from a subfolder how would I do that? For example, www.mysite.com/laravelapp

    The examples I found where for only running it from the public_html folder itself. Would it just involve changing the file paths in the www/index.php?

  • mdailey77
    mdailey77 over 6 years
    I checked and Godaddy added support for PHP 7 last year. I'm using an existing database. I have SSH access on Godaddy. There isn't a way to install Composer using SSH?
  • Theodore R. Smith
    Theodore R. Smith over 6 years
    I think the info I viewed online was slightly outdated, then. The stuff I read was all in 2017 but prior to June. Good for them. I have ammended my answer with a video tutorial.
  • mdailey77
    mdailey77 over 6 years
    Thanks for the video tutorial link. Yeah Godaddy added PHP 7 last August. I did find a way to add composer to Godaddy. Using PuTTY, I ran this command in the home directory: curl -sS https://getcomposer.org/installer | php Got the idea from here
  • Y. Joy Ch. Singha
    Y. Joy Ch. Singha over 4 years
    ERR_ABORTED 403 (Forbidden) in css folder that i keep in public_html/laravel/assets/css
  • mdailey77
    mdailey77 over 4 years
    You should open a new question.