1
votes

I'm trying to upload my laravel project to cPanel. But till now, it doesn't seems to be working. I have moved following directories and files from my project into the directory 'lavravel' in root.

app/
bootstrap/
config/
database/
resources/
storage/
artisan
composer.json
composer.lock
.env

And moved files from my public folder to public_html Now my directory looks like this. Directory

I have made changes in following files. laravel/bootstrap/app.php

/*
|--------------------------------------------------------------------------
| Public Path
|--------------------------------------------------------------------------
|
| Set the path to the Laravel "public" directory so that any files/packages
| that use app('path.public') to get the "public" path find the right path.
| DO NOT include a trailing slash on the path.
|
*/
$app->bind('path.public', function ()
{
    return __DIR__.'/../../public_html';
});

public_html/index.php

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

But, it doesn't seems to work. It displays a blank page. As you can see via this URL. nepalride.com

3

3 Answers

0
votes

You should take a look at the Laravel

After uploading the files, make sure you set the correct permissions on the storage and bootstrap/cache folders.

Also, you need to run composer install to install the vendor packages required by Laravel. Your uploaded laravel folder doesn't have a vendors folder.

Look through the error logs and you will see all the issues you're encountering.

0
votes

The easiest way to do it if you have ssh access is create a laravel directory with your app in. Then:

rm -rf public_html
ln -s laravel/public public_html

This deletes the current public_html (make sure there is nothing inside it you need before running it) and creates a symbolic link from public_html to your apps public folder.

-1
votes

manual path configuration of index.php will lead to problems down the road and so the proper way of configuring it would be to have ssh or terminal access. First make sure you have shell or terminal access(not usually accessible in shared hosting accounts). Open terminal and check for php version

$ php -v

make sure php version is above the required version of your laravel app. if not change it to the latest available version. Configure shell environment to use composer

$ echo 'alias composer="php -d allow_url_fopen=On /home/username/composer.phar"' >> ~/.bashrc

$ source ~/.bashrc

after that download and install composer on your cpanel account

$ cd ~

$ curl -k -O https://getcomposer.org/installer

$ php -d allow_url_fopen=On installer

make sure you have installed it

$ composer -v

go to the uploaded project either using ftp or git and run

$ composer install

to install dependencies

make sure your .env files are properly configured

run $ php artisan key:generate

run migrations $php artisan migrate

make sure you have proper access $ chmod -R 775 storage

optimize your app $ php artisan optimize

make app accessible to public by running $ mv public_html public_html_old

create the symlink $ ln -s /home/user/app/public /home/user/public_html

and all should be good and app should be running.