How to install Laravel in Ubuntu using terminal?

17.12.2024

Laravel is a popular PHP framework for web development that offers a simple and elegant syntax. Installing Laravel on Ubuntu using the terminal is a straightforward process that can be completed in a few simple steps. In this guide, we will walk you through the installation process.

Install Laravel on Ubuntu with Apache or Nginx - Tutorial ...

Step 1: Install PHP

Before you can install Laravel, you need to make sure that PHP is installed on your Ubuntu system. You can install PHP along with some commonly used extensions by running the following command:

Laravel development setup on Ubuntu Linux using Xampp – YouTube
Oct 29, 2017 … This video shows how to setup laravel development environment on Linux (ubuntu) using XAMPP.
sudo apt install php php-cli php-mbstring php-zip php-dom php-mysql

Step 2: Install Composer

Composer is a dependency manager for PHP that is used to install Laravel and its dependencies. You can install Composer by running the following command:

sudo apt install composer

Step 3: Install Laravel

Once Composer is installed, you can use it to install Laravel. Run the following command to create a new Laravel project:

composer create-project --prefer-dist laravel/laravel my_project_name

Replace my_project_name with the name you want to give to your Laravel project.

Step 4: Set Permissions

After installing Laravel, you need to set the correct permissions for your project. Navigate to your project directory and run the following commands:

cd my_project_name sudo chown -R www-data:www-data storage bootstrap/cache chmod -R 775 storage bootstrap/cache

Step 5: Configure Environment

Copy the .env.example file to .env and generate the application key by running the following commands:

cp .env.example .env

Step 5.1: Set key

That command will generate a new key for app

php artisan key:generate

Step 5.2: Install migrations to new database

That command will run the migrations for laravel app to work after first install

php artisan migrate

Step 6: Serve Your Application

You can use the following command to serve your Laravel application locally:

php artisan serve

This will start a development server at http://localhost:8000. You can access your Laravel application by visiting this URL in your web browser.

Step 7: Additional Configuration

Depending on your requirements, you may need to configure your database settings, mail settings, and other aspects of your Laravel application. Refer to the Laravel documentation for more information on how to customize your application.

Congratulations! You have successfully installed Laravel on your Ubuntu system using the terminal. You can now start building your web applications with this powerful PHP framework.

Yan Hadzhyisky

fullstack PHP+JS+REACT developer