How to Install Laravel on DomainIndia.com cPanel Hosting and Create Your First Program Print

  • 0

Title: Installing Laravel on DomainIndia.com cPanel Hosting and Creating Your First Program: A Step-by-Step Guide

Introduction:
Laravel is a powerful PHP framework designed to simplify the process of web application development. In this article, we will walk you through the process of installing Laravel on DomainIndia.com cPanel hosting and creating your first program, covering both manual and Softaculous installation methods.

Part 1: Installing Laravel on DomainIndia.com cPanel Hosting

Method 1: Installation using Softaculous

Step 1: Log in to your DomainIndia.com cPanel account.

Step 2: Navigate to the "Softaculous Apps Installer" in the "Software" section.

Step 3: Search for "Laravel" and click on the Laravel icon.

Step 4: Click on the "Install" button and fill in the required details, such as domain, directory, database name, and admin credentials.

Step 5: Click on the "Install" button at the bottom of the page, and Softaculous will automatically install Laravel on your hosting account.

Method 21: Manual Installation

Step 1: Log in to your DomainIndia.com cPanel account.

Step 2: Navigate to the "File Manager" in the "Files" section.

Step 3: Access the "public_html" folder or the folder where you want to install Laravel.

Step 4: Click on the "Upload" button and upload the Laravel zip file downloaded from the Laravel website (https://laravel.com/).

Step 5: Once the upload is complete, extract the Laravel zip file into your desired folder.

Step 6: Open the ".env" file in the Laravel folder and update the database credentials (DB_HOST, DB_DATABASE, DB_USERNAME, and DB_PASSWORD) with the details provided by DomainIndia.com.

Step 7: In the cPanel, navigate to the "Databases" section and create a new MySQL database and user with the same credentials as in the ".env" file.

Step 8: Open the "Terminal" in cPanel or use an SSH client to access your hosting account.

Step 9: Navigate to your Laravel folder using the "cd" command (e.g., cd /home/username/public_html/laravel).

Step 10: Run the following command to install the necessary dependencies: composer install

Step 11: Finally, run the command to generate an application key: php artisan key:generate

Part 2: Creating Your First Laravel Program

Step 1: Open the "Terminal" in cPanel or use an SSH client to access your hosting account.

Step 2: Navigate to your Laravel folder using the "cd" command (e.g., cd /home/username/public_html/laravel).

Step 3: Run the following command to create a new controller: php artisan make:controller MyFirstController

Step 4: Open the newly created controller file located in "app/Http/Controllers/MyFirstController.php" and add a new function:


public function index()
{
return view('myfirstview');
}

Step 5: In the "routes" folder, open the "web.php" file and add a new route for your controller action:


use App\Http\Controllers\MyFirstController;

Route::get('/myfirst', [MyFirstController::class, 'index']);

Step 6: Create a new Blade template in the "resources/views" folder named "myfirstview.blade.php" and add some HTML content:


<!DOCTYPE html>
<html>
<head>
<title>My First Laravel Program</title>
</head>
<body>
<h1>Welcome to My First Laravel Program!</h1>
</body> </html> 

Step 7: Save all your changes and close the files.

Step 8: Open your web browser and navigate to your Laravel application's URL, followed by "/myfirst" (e.g., http://example.com/myfirst). You should now see the "Welcome to My First Laravel Program!" message displayed on the page.

Conclusion: Installing Laravel on DomainIndia.com cPanel hosting is a straightforward process, whether you choose to install it manually or use the Softaculous Apps Installer. By following the steps in this guide, you have successfully installed Laravel and created your first program. Now you can continue exploring Laravel's features and functionalities, building more complex applications as you gain experience with the framework.


Was this answer helpful?

« Back