0
votes

I create small registration system for my site with laravel framework.
Now I want to upload that on my "shared host".
my host control panel is Direct Admin.

1.first is create sub domain like this: reg.mydomain.me. after that I created a reg folder on my root directory and copy all of laravel folders and files in that.

/home/mydomain.me/public_html/

  1. I moved all the main file of Laravel (app, boostrap, vendor, composer.json, composer.lock, phpunit.xml etc) into reg folder **except Public folder.

  2. Opened /home/username/main-laravel/bootstrap/paths.php and edit to look like this:

    • replace 'app' => DIR.'/../app', to 'app' => DIR.'/../../main-laravel/app',

    • replace 'public' => DIR.'/../public', to 'public' => DIR.'/../../public_html/laravel',

    • replace 'base' => DIR.'/..', to 'base' => DIR.'/../../main-laravel',

    • replace 'storage' => DIR.'/../app/storage', to 'storage' => DIR.'/../../main-laravel/app/storage',

and create a new folder inside public_html

' /home/username/public_html/reg/laravel '

  1. I moved all the content in public folder of Laravel into 'public_html/reg/laravel' folder (step 4)

  2. Open /home/username/public_html/reg/laravel/index.php and edit to look like this:-

    • replace require DIR.'/../bootstrap/autoload.php'; to require DIR.'/../../main-laravel/bootstrap/autoload.php';

    • replace $app = require_once DIR.'/../bootstrap/start.php'; to $app = require_once DIR.'/../../main-laravel/bootstrap/start.php';

but when I run the reg.mydomain.me I get blank page!!!

what can I do for run laraval in subdomain ?

tnx

3
Why do you need to separate the public folder and the actual application like that? Can't you just place everything in /home/username/reg and then let your subdomain document root point at /home/username/reg/public?lukasgeiter

3 Answers

0
votes

Here is step by step method what i did to host my laravel 5 site on host gator with baby plan.

Step 1 - Pre-Requisite: (Set Up SSH access on Windows)

  1. Check do you have SSH access to your host gator account. If not talk to support team they are good and will give access to ssh.
  2. Download Putty from here to access your hostgator account from Windows. Linux user don't need it as SSH is already present and accessible from terminal
  3. You are ready to go. Double click on putty and put ip and port then enter username and password.
  4. Check simple command like "pwd" . "cd" , "cd ..". If you feel some problem till this step, comment below

Step 2- Check PHP version (Laravel 5 needs PHP v >= 5.4)

  1. As you have Set up ssh and now you can access your account. Now need to type some commands to check and setup php version. Following command should show something like PHP 5.5.6 (cli) ....

    $ php -v

  2. If you dont get version > 5.4 Dont worry. Make a .htaccess file in public_html folder and put following one line code.

    AddHandler application/x-httpd-php55 .php

Step 3 - Installing Composer and laravel 5

  1. Come to putty. Use pwd command and check you are in root directory (/home2/your_cpanel_name). If yes than execute following command it will download a composer.phar file at root directory (/home2/your_cpanel_name/composer.phar)

    curl -sS https://getcomposer.org/installer | php

  2. Now run follwoing command from anywhere.

    php /home2/your_cpanel_name/composer.phar

  3. Now composer is installed and you are ready to anything this is given in laravel 5 docs site. Now run following command

    composer global require "laravel/installer=~1.1"

  4. Now run this command from anywhere in you directory structure to install laravel.

    ~/.composer/vendor/bin/laravel new your_site_name

0
votes

Here are the steps to do it.

  1. once you create a subdomain, you will have a root path /home/public_html/reg.
  2. Get all your laravel code in root path or some directory.
  3. Move the contents of public folder to /home/public_html/reg.
  4. Update index.php to reflect the directory where you have the laravel code and bootstrap.
  5. Run the composer update in the root directory of your code. This is done so that the vendor folders comes up.

The below link helped me in getting my app on hostgator. http://laravel.io/forum/03-06-2015-how-to-setup-laravel-5-in-shared-hosting

0
votes

Actually, setting up Laravel on a subdomain is even easier that setting it as the main application, reason being that, you have the opportunity to point your domain to your public folder and it helps you stop worrying about .htaccess file.

so I'm assuming you are installing in

 /home/public_html/reg

well if that is the case, then all you have to do is move all your files there, you dont have to run composer on your remote server if you dont have access to it. All you neeed to move all files into the new folder

Then let your subdomain point to the public folder of your new application. It would be something like the below.

 /home/public_html/reg/public

I hope this helps someone.