user1380281
user1380281

Reputation: 299

Laravel setup on HostGator shared plan

I'm trying to setup Laravel on a HostGator shared plan. I've followed these instructions:

http://laravel.io/forum/02-13-2014-how-to-install-laravel-on-a-hostgator-shared-server

I created and uploaded the .bashrc and .bash_profile files as instructed, then I run:

source ~/.bashrc

in the terminal, but then when I run php -v I get

No such file or directoryphp

I also tried uploading an htaccess file with AddHandler application/x-httpd-php55 .php to the root directory. When I run phpinfo() now, it shows php version 5.5.10, but php -v (before I run the source command) still shows version 5.2.17.

Any idea what I'm doing wrong?

Upvotes: 1

Views: 15652

Answers (4)

yardpenalty.com
yardpenalty.com

Reputation: 1244

So there is one simple step that seems to get overlooked with most of the issues of setting up a subdomain to host a Laravel App using HostGator's Shared Hosting plan.

HostGator Shared Server Hosting Plan


Scenario:

Domain: https://yardpenalty.com is pointing to the home/username/public_html folder which has a WordPress installation.

Subdomain: https://games.yardpenalty.com is pointing to the home/username/games/public folder which has a Laravel App installation.

Problem:

We want the Laravel App to be accessed at the Subdomain's root level...

URI at https://games.yardpenalty.com

NOT at https://games.yardpenalty.com/public.

Solution:

Step 1:

Under our HostGator Shared Server Hosting Plan we can access the tools we need using cPanel.

Step 2:

In our cPanel we go-to Domains->Subdomains and we enter a name for our Subdomain (in this instance its called games).

Step 3:

Then we select a Domain from the dropdown list and in this scenario it is yardpenalty.com which is pointing to my public_html folder.

Step 4:

Finally, under the Document Root / (a.k.a. home/user) we point it to the /games/public folder!

It should look something like the second listing from your cPanel:

HostGator's cPanel Subdomain list

Upvotes: 0

Tushar
Tushar

Reputation: 1176

I recently wrote an article on how I was able to host my laravel 5.5 on a shared host. (Hostgator) https://www.5balloons.info/hosting-laravel-5-5-project-on-shared-hosting-hostgator/

Upvotes: 1

lalo
lalo

Reputation: 929

STEP 1 Copy your files

Copy your app in a non-public folder, example:

/home/foo/myapp

Move your public folder to a public folder, example:

/home/foo/public_html/public

Open your public/index.php file and change paths to reference your laravel non-public code, example:

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

STEP 2 Change php version in Cpanel

For laravel 5.2 you need at least php 5.5

https://laravel.com/docs/5.2/installation#server-requirements

change php version

this will add some lines in your .htaccess, for example, this will enable php7:

# Use PHP70 as default
AddHandler application/x-httpd-php70 .php
<IfModule mod_suphp.c>
    suPHP_ConfigPath /opt/php70/lib
</IfModule>

STEP 3 Make artisan work

php command line may not work, run this command to check php version:

php -v

if it doesn't give you the correct version you may run your commands directly with php 5.6 binary, like this:

/opt/php56/bin/php artisan

STEP 4 clear caches

Sometimes you need to clear your cache, there's two ways:

With artisan:

/opt/php56/bin/php artisan optimize

Manually:

Delete this two files

  • bootstrap/cache/compiled.php
  • bootstrap/cache/services.json

How to use SSL

Hostgator shared servers have a shared SSL certificate

To use the shared SSL certificate you must access your public folder by the root of your server and your username like this:

https://gator1234.hostgator.com/~username

So for example, if you put your application in a folder called myapp it will become:

https://gator1234.hostgator.com/~username/myapp

this will mess the routes file, so you have to add this lines to your .htaccess

RewriteEngine On
RewriteBase /~username/myapp

Upvotes: 3

user1380281
user1380281

Reputation: 299

I was finally able to get Laravel installed with some help from this:

http://shincoding.com/laravel/installing-configuring-laravel-shared-hosting/

Upvotes: -2

Related Questions