Javascript required
Skip to content Skip to sidebar Skip to footer

How to Upload Php Project on Hostgator

Deploy Laravel Awarding on Shared Hosting

In this tutorial, I will demonstrate the steps involved to deploy Laravel Application on Shared Hosting. I am demonstrating the steps on Hostgator.

The steps involved to Host Laravel Application on Shared Hosting will be pretty much aforementioned for whatever other Hosting as well.

Note: This tutorial will piece of work well for Installing your Laravel Project to SiteGround, Bluehost, GoDaddy and other shared hosting servers.

Earlier moving forrard make sure yous have following Ready.

  • Shared Hosting Business relationship Created (Sign Upwardly for Hostgator)
  • You take Admission to cPanel.
  • Laravel Awarding source code available via Git (GitHub / Bitbucket etc.) or whatever other SVN

Alright, Let'due south dig into the steps to Deploy Laravel Awarding on Shared Hosting


PHP Version

Laravel 5.5 requires PHP version greater than 7.0. Hostgator comes with default of five.4.

Login to your cPanel using credentials sent to your e-mail on Hostgator account signup.

Choose  optionChange PHP Version and change the current version to >vii.one

Note : Y'all can ignore this step if your Laravel version requires PHP 5.four or your hosing provider by defaults provides PHP v > vii.0

Change PHP Version Hostgator for Laravel

SSH into Shared Hosting Box

As the first step, Open your final / command line and SSH into your Shared Hosting Server

Notation: SSH instructions are usually included in the welcome email. Hither is the general command to SSH into the Server

          $ ssh [username]@[server-ip]    //Supersede username with cPanel username and server-ip with Server IP Address.        

Once information technology'due south able to connect to the server, It will prompt you lot for the SSH password, which should exist aforementioned as your cPanel account password

The abode directory structure of shared server looks something similar this.

Directory Structure hostgator user home

As you can come across we have a directory public_html which is a public directory for keeping our projects. www is symlink to public_html. So basically, they both points to same stuff.


Clone Laravel Projection

Let say in your hosting server (VPS, or shared hosting…whatever), you have currentworld wide web/ directory, which is accessible publicly via web domain, for example:

          /Users/username-blah/www/        

At present, clone your project in a new directory, which contains all your awarding source lawmaking, at the same level aswww/, for example:

          /Users/username-apathetic/myLaravelProject/        

Y'all tin use git clone command to clone your project. Something like

          $ git clone https://username@bitbucket.org/username/myLaravelProject.git        

Make public files available to world wide web

Next step is to copy all contents within themyLaravelProject/public directory towww directory. The like shooting fish in a barrel instance is that, with the fresh Laravel 5 installation application, the myLaravelProject/public/index.php should exist copied to the world wide web/alphabetize.php

Makes Sense?

Basically you need to run this command, on your server home directory (/abode/username-apathetic)

          $ cp -a myLaravelProject/public/. world wide web/        

Now, your www should accept following contents

Hostgator www directory construction

Annotation : Make certain you copy thepublic/.htaccess to thewww/ also. Don't forget this, it is very important for your app routes. Without it, your routes won't exist working and there will exist a bare or empty folio in every road.


Alter www/index.php to reverberate new Structure

At present let'southward change the world wide web/alphabetize.php to reflect the new structure. Don't change theproject/public/alphabetize.php, okay? Merely changeworld wide web/index.php, remember this!

Discover the following line

          crave __DIR__.'/../bootstrap/autoload.php';   $app = require_once __DIR__.'/../bootstrap/app.php';        

And update them to the correct paths as following

          require __DIR__.'/../myLaravelProject/bootstrap/autoload.php';  $app = require_once __DIR__.'/../myLaravelProject/bootstrap/app.php';        

We are well-nigh there, but couple of more steps !


Modify Directory Permissions

It'due south time to modify directory permissions of storage and bootstrap/cache directory and so that information technology's writable.

Move to your Laravel Project into the concluding and run the post-obit commands.

          $ sudo chmod -R 777 storage  $ sudo chmod -R 777 bootstrap/enshroud        

.env Configuration File

In that location is an .env file in your project which contains all the projection variables dedicated to the environment in which the project is working.

Since our .env file should not exist committed to your awarding's source control. Your application should comprise a .env.example file available. You can go alee and copy the aforementioned file and name it .env

Generate a new application encyption key

          $ php artisan fundamental:generate        

Note: Brand sure to clear enshroud via artisan command after generating the new key file (php artisan cache:clear)

Change the .env file for other required parameters such as database variables, Mail Setting Variables. etc.

There you become !!! Everything should work now


Composer

Hostgator comes with composer (dependency manager tool) already installed and about other shared hosting server's comes with composer installed.

Check past running composer command on your last.

If not, you tin hands install composer with following commands.

          $ cd /User/username-blah/project/  $ coil -sS https://getcomposer.org/installer | php — –filename=composer        

At present yous can execute composer to manage dependencies.

          $ php composer install  $ php composer dumpautoload -o  $ php artisan config:enshroud  $ php artisan road:cache        

That's information technology ! Have fun with deployed Laravel Project.

Related Articles

irvinghered1952.blogspot.com

Source: https://5balloons.info/hosting-laravel-5-5-project-on-shared-hosting-hostgator/