How can a host a Laravel 5.6
app to cpanel on a shared hosting.
Can someone give me an idea
require __DIR__.'/../vendor/autoload.php';
/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/
$app = require_once __DIR__.'/../bootstrap/app.php';
/*
\#########my index.php file
You have two methods available, one requiring ssh access. Under no circumstances do you put your entire Laravel directory into the public_html
directory.
If you have SSH access you'll want to do the following;
cd ~
public_html
directory ~/laravel
cd ~ && ln -s laravel/public public_html
If you don't have SSH access you'll want to do the following;
~/laravel
(above the public_html) ~/laravel/public
directory to public_html
Your new ~/public_html/index.php
should look like the following;
<?php
/**
* Laravel - A PHP Framework For Web Artisans
*
* @package Laravel
* @author Taylor Otwell <taylor@laravel.com>
*/
define('LARAVEL_START', microtime(true));
/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| our application. We just need to utilize it! We'll simply require it
| into the script here so that we don't have to worry about manual
| loading any of our classes later on. It feels great to relax.
|
*/
require __DIR__.'/../laravel/vendor/autoload.php';
/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/
$app = require_once __DIR__.'/../laravel/bootstrap/app.php';
/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request
| through the kernel, and send the associated response back to
| the client's browser allowing them to enjoy the creative
| and wonderful application we have prepared for them.
|
*/
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
$response->send();
$kernel->terminate($request, $response);
after googling around i found that you have to take content of public folder which has index.php file and put it in public_html. now we have to change the content of index.php file ie just provide the right link of app.php and autoload.php which would be require __DIR__.'/<project_folder_name>/vendor/autoload.php'
and $app = require_once __DIR__.'/<project_folder_name>/bootstrap/app.php';
also update your .env file and check it should work if it doesnt you have to clear cache and routes using php artisan cache:clear
and php artisan route:clear
you can do this using ssh or define the function in web.php and then hitting the link
An easy way if your shared hosting team is very supportive for you, Upload your files to public_html folder, and then incase if you donot have ssh access to server, contact your hosting team and ask them to point your domain name to public_html/public folder as root folder. And then ask them to execute following command via ssh
composer install
If you want to boost the peformance, please provide them the four commands listed in the following article.
https://www.techalyst.com/links/read/112/boosting-laravel-performance-in-production-server
Umm. Shared hosting does NOT support php 7, which larave 5.6 depends on. Have you guys found a workaround. I have been stuck for months with laravel 4.x on bluehost.
Laravel 5.6
requires PHP 7
.
First check your shared hosting support PHP 7
in Cpanel (PHP Selector), if yes but you have other projects which PHP 5
and you don't want to change default php version, then use this in .htaccess
file
For example: public_html/abc/.htaccess
RewriteEngine on
AddHandler application/x-httpd-php71 .php
Then PHP 7
Work and you can work with Laravel 5.6
on shared hosting
laravel -> all laravel file
public_html -> move all folder & file on *public* file laravel to *public_html*
change your index.php on public html
require __DIR__.'/../laravel/vendor/autoload.php';
$app = require_once __DIR__.'/../laravel/bootstrap/app.php';
don't forget to change your php version to 7.2
You can try the below structure in your public_html (root) of your shared hosting
Create a folder called laravel and place all the files and folders except public folder in it.
Copy all the files and folders of public directory directly to the public_html root. Your folder structure should look like this
public_html
- Laravel (Folder with all the laravel files and folders except public)
- css (from public folder)
- js (from public folder)
- .htaccess(from public folder)
- index.php (from public folder)
- robots (from public folder)
And edit the index.php to the following
require __DIR__.'/laravel/vendor/autoload.php';
/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/
$app = require_once __DIR__.'/laravel/bootstrap/app.php';
/*
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.