Asked  7 Months ago    Answers:  5   Viewed   38 times

I'm trying to deploy my laravel (Laravel Framework 7.28.3) to Cpanel, but got a 404 error. I uploaded my project into /public_html, modified the index.php file to point to the correct files (as below). I think there must be some mistake in the index.php file but couldn't figure it out. This is my first time asking my question (after searching for it several times), so hope that I will get the answer!

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

this is my file structure in File Manager:

file structure in File Manager

 Answers

41

Deploy laravel application in Cpanel

  • Setup 1 : - upload file to Cpanel the root directory – not the public_html.

  • Setup 2 : - Open the that folder and MOVE the CONTENTS of the public folder to your cpanel’s public_html .

  • Setup 3 : - Navigate to the public_html folder and locate the index.php file. Right click on it and select Code Editor from the menu.

and change this line

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

NOTE : - folderName here is in root where you laravel application stay

that's it now all your request will come inside public_html folder index.php and this file will include require __DIR__.'/../folderName/vendor/autoload.php; and run laravel application


Folder structure will look like

/laravel
/public_html/index.php

indside index.php

require __DIR__.'/../laravel/vendor/autoload.php';;
$app = require_once __DIR__.'/../laravel/bootstrap/app.php'; // here laravel is folder name
Wednesday, March 31, 2021
 
Maury
answered 7 Months ago
71

first check if your model login has a field password in the login database schema after that change this :

if (Auth::attempt(['username' => $request->get('username'), 'pw' => $request->get('password')])) {
    return redirect('RegView');
}

to:

if (Auth::attempt(['username' => $request->get('username'), 'password' => $request->get('password')])) {
    return redirect('RegView');
}

also go to your app/Http/Auth/LoginController.php and add this :

  /**
     * Get the login username to be used by the controller.
     *
     * @return string
     */
    public function username()
    {
        return 'username';
    }

and finally change this :

'providers' => [
        'users' => [
            'driver' => 'eloquent',
            'model' => AppUser::class,
        ],

        // 'users' => [
        //     'driver' => 'database',
        //     'table' => 'users',
        // ],

        'users' => [
            'driver' => 'eloquent',
            'model' => Applogin::class,
        ],

to this :

'providers' => [

        'users' => [
            'driver' => 'eloquent',
            'model' => Applogin::class,
        ],

check if there is any errors if the page refresh :

@if ($errors->any())
    <div class="alert alert-danger">
        <ul>
            @foreach ($errors->all() as $error)
                <li>{{ $error }}</li>
            @endforeach
        </ul>
    </div>
@endif

if you really want to use pw instead of password look at this answer : https://stackoverflow.com/a/39382427/4369087

Wednesday, March 31, 2021
 
viper
answered 7 Months ago
25

This thread should be helpful in explaining the mysql permission issue:

http://lists.mysql.com/mysql/206422

Also I should have asked what mysql user account you were running the query, as in root or another possibly limited user?

Saturday, May 29, 2021
 
Eddas
answered 5 Months ago
31

The Maximum execution time of 30 seconds exceeded error is not related to Laravel but rather your PHP configuration.

Here is how you can fix it. The setting you will need to change is max_execution_time.

;;;;;;;;;;;;;;;;;;;
; Resource Limits ;
;;;;;;;;;;;;;;;;;;;

max_execution_time = 30     ; Maximum execution time of each script, in seconds
max_input_time = 60 ; Maximum amount of time each script may spend parsing request data
memory_limit = 8M      ; Maximum amount of memory a script may consume (8MB)

You can change the max_execution_time to 300 seconds like max_execution_time = 300

You can find the path of your PHP configuration file in the output of the phpinfo function in the Loaded Configuration File section.

Friday, June 18, 2021
 
Manmay
answered 5 Months ago
89

After many weeks of trying to resolve this error. The following fixes worked

  1. Upgrade project from Laravel 5.2 to 5.4
  2. On CPanel using "Select Php version" set PHP version to 7
  3. Or on CPanel using "MultiPHP Manager" set PHP version to ea-php70

Now, cron job runs smoothly. I hope this helps someone.

Saturday, July 3, 2021
 
Asnexplore
answered 4 Months ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :