How to deploy Laravel 5.5 app to Godaddy cPanel shared hosting

心已入冬 提交于 2019-12-03 09:41:26

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

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.

Following are the 11 steps to deploy laravel on shared linux hosting

  1. Open Terminal
  2. Clone git repository outside the public_html directory
  3. Run composer install
  4. Move contents of public directory to public_html and delete public directory from project
  5. Edit index.php in public_html and set its permission as 644
  6. Create MySQL database and Database User
  7. Rename .env.example in project directory to .env and edit mysql data values as shown in step 6
  8. Run php artisan migrate:fresh –seed
  9. Create Storage directory symlink
  10. Give permission to storage and bootstrap directories
  11. Run php artisan config:clear, php artisan key:generate and composer dump-autoload

Each step is explained at decodeweb.in

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!