How to Install Laravel on Debian 11 / Debian 10

0

Laravel is an open-source web application framework with expressive, elegant syntax. It is one of the most popular PHP frameworks in the world, and it’s great for developers looking to build modern web applications.

But setting up a development environment can be frustrating to newcomers. Thankfully, once you understand the basics of the installation process, you can the Laravel project up and running in no time!.

Here, you will learn how to install Laravel on Debian 11 / Debian 10.

Install PHP

Laravel requires PHP version 7.3 or newer. Since Debian 11 and Debian 10 comes with PHP 7.4 and PHP 7.3, respectively, you do not need to get PHP packages from external repositories.

Update the repository information.

sudo apt update

Install PHP and few other extensions with the below command.

sudo apt install -y php-common php-cli php-gd php-mysql php-curl php-intl php-mbstring php-bcmath php-imap php-xml php-zip

Check the PHP version post the installation of packages.

php -v

Ensure the PHP version is 7.3 or later.

PHP 7.4.21 (cli) (built: Jul  2 2021 03:59:48) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.21, Copyright (c), by Zend Technologies

Install PHP Composer

Composer is a dependency manager for PHP. It will help you download and install Laravel with the necessary components for your project development.

You can install composer locally, on your project directory, or globally on $PATH directories (ex /bin or /usr/bin).

wget -qO - https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin/ --filename=composer

Verify the composer version.

composer --version

Output:

Composer version 2.1.6 2021-08-19 17:11:08

Install Laravel

Since you already have PHP Composer on your system, you can easily create a Laravel project using the below command.

composer create-project laravel/laravel my_example_app

Once the project is created, go to the project directory.

cd my_example_app

And then, start Laravel’s local development server using the Artisan CLI’s serve command.

php artisan serve

You will get the message something like this.

Starting Laravel development server: http://127.0.0.1:8000

By default, Laravel listens on the localhost with port 8000. In case if you want, you can use the --host <ip_address> and --port <port_number> option to change the listening address and port of Laravel, respectively.

You can open up your browser and access the Laravel development server with the IP address and the port number displayed in the previous command output. You will get the below web page.

Laravel Development Server
Laravel Development Server

Conclusion

That’s All. I hope you how to install Laravel on Debian 11 / Debian 10. As a next step, you can perform initial configurations and follow the documentation to learn Laravel.

You might also like