Install Laravel Framework on Debian 11 (2023)

On this page

  1. Prerequisites
  2. Install Apache Web Server
  3. Install PHP and Other Required Extensions
  4. Install Composer
  5. Install Laravel
  6. Configure Apache for Laravel
  7. Access Laravel
  8. Conclusion

Laravel is a free and open-source PHP web framework based on the Symfony framework. It is used for the faster development of web applications. Laravel makes it easier to perform some common tasks such as authentication, routing, sessions and caching. It has several useful features including, Artisan, Object-relational mapping, Template Engine, MVC Architecture, Unit-Testing, and Database Migration System.

In this tutorial, I will show you how to install Laravel on Debian 11.


  • A server running Debian 11.
  • A valid domain name pointed with your server IP.
  • A root password is configured on the server.

Install Apache Web Server

First, you will need to install the Apache package to your server. You can install it using the following command:

apt-get install apache2 -y

Once the Apache package is installed, verify the Apache version using the following command:

apache2ctl -v

You should see the following output:

(Video) Install Laravel 9 and PHP 8.1 on Debian 11

Server version: Apache/2.4.48 (Debian)Server built: 2021-08-12T11:51:47

Install PHP and Other Required Extensions

Next, you will need to install PHP and other extensions required for the Laravel application. First, install the required dependencies using the following command:

apt-get install apt-transport-https gnupg2 ca-certificates -y

Next, add the GPG key and PHP repository with the following command:

wget -O /etc/apt/trusted.gpg.d/php.gpg
sh -c 'echo "deb $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'

Next, update the repository and install PHP with other extensions using the following command:

apt-get update -y
apt-get install libapache2-mod-php php php-common php-xml php-gd php8.0-opcache php-mbstring php-tokenizer php-json php-bcmath php-zip unzip curl -y

Once PHP is installed, edit the php.ini file and make some changes:

nano /etc/php/8.0/apache2/php.ini

Change the following lines:

cgi.fix_pathinfo=0 date.timezone = Asia/Kolkata

Save and close the file then verify the PHP version using the following command:

(Video) Debian 11 | Laravel

php -v

Sample output:

PHP 8.0.10 (cli) (built: Aug 26 2021 16:06:19) ( NTS )Copyright (c) The PHP GroupZend Engine v4.0.10, Copyright (c) Zend Technologies with Zend OPcache v8.0.10, Copyright (c), by Zend Technologies

Install Composer

Next, you will need to install the Composer to your system. You can install it using the following command:

curl -sS | php

Sample output:

All settings correct for using ComposerDownloading...Composer (version 2.1.6) successfully installed to: /root/composer.pharUse it: php composer.phar

Next, move the Composer binary to the system path using the following command:

mv composer.phar /usr/local/bin/composer

Next, verify the Compsoer version with the following command:

composer --version

You should see the following output:

(Video) Install Laravel 8 on Linux Ubuntu 20.04LTS via Composer

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

Install Laravel

Next, change the directory to Apache webroot and download the latest version of Laravel using the Composer:

cd /var/www/html
composer create-project --prefer-dist laravel/laravel laravel

You should get the following output:

> @php artisan package:discover --ansiDiscovered Package: facade/ignitionDiscovered Package: fruitcake/laravel-corsDiscovered Package: laravel/sailDiscovered Package: laravel/sanctumDiscovered Package: laravel/tinkerDiscovered Package: nesbot/carbonDiscovered Package: nunomaduro/collisionPackage manifest generated successfully.76 packages you are using are looking for funding.Use the `composer fund` command to find out more!> @php artisan vendor:publish --tag=laravel-assets --ansiNo publishable resources for tag [laravel-assets].Publishing complete.> @php artisan key:generate --ansiApplication key set successfully.

Next, set proper permissions and ownership to the Laravel directory with the following command:

chown -R www-data:www-data /var/www/html/laravel
chmod -R 775 /var/www/html/laravel

Once you are finished, you can proceed to the next step.

Configure Apache for Laravel

Next, you will need to create an Apache virtual host configuration file for Laravel. You can create it with the following command:

nano /etc/apache2/sites-available/laravel.conf

Add the following lines:

(Video) How to install Laravel 9 on Ubuntu 20.04 | Linux | create and deploy Laravel project via Composer

<VirtualHost *:80> ServerName ServerAdmin [emailprotected] DocumentRoot /var/www/html/laravel/public <Directory /var/www/html/laravel> Options Indexes MultiViews AllowOverride None Require all granted </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined</VirtualHost>

Save and close the file then enable the Apache virtual host and rewrite module with the following command:

a2enmod rewrite
a2ensite laravel.conf

Finally, restart the Apache service to apply the changes:

systemctl restart apache2

You can also check the status of the Apache with the following command:

systemctl status apache2

You should get the following output:

? apache2.service - The Apache HTTP Server Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled) Active: active (running) since Fri 2021-08-27 06:00:25 UTC; 7s ago Docs: Process: 14020 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS) Main PID: 14025 (apache2) Tasks: 6 (limit: 2341) Memory: 13.2M CPU: 97ms CGroup: /system.slice/apache2.service ??14025 /usr/sbin/apache2 -k start ??14026 /usr/sbin/apache2 -k start ??14027 /usr/sbin/apache2 -k start ??14028 /usr/sbin/apache2 -k start ??14029 /usr/sbin/apache2 -k start ??14030 /usr/sbin/apache2 -k startAug 27 06:00:25 debian11 systemd[1]: Starting The Apache HTTP Server...

Access Laravel

Now, open your web browser and access the Laravel web UI using the URL You should see the Laravel default page on the following screen:

(Video) How to Install PHP 8 on Debian 9/10/11


Congratulations! you have successfully installed Laravel with Apache on Debian 11. You can now start developing your application using the Laravel framework. Feel free to ask me if you have any questions.


1. How to install laravel php framework on CentOS 7
(Cloud Surph)
2. How to install laravel in ubuntu 20.04 step by step | install laravel on ubuntu 20.04
(Mursalin Ahmed)
3. How to Install Laravel and Create Laravel Project (Hindi)
(Geeky Shows)
4. Setup Laravel On Ubuntu 20.04 LTS step by step
(Tech Blog)
5. How to Install Laravel using Composer in Hindi - Complete Setup | Laravel Tutorial #2
(WsCube Tech)
6. How to install Laravel 9 and create a project via Composer with XAMPP server on Windows 11
Top Articles
Latest Posts
Article information

Author: Eusebia Nader

Last Updated: 19/09/2023

Views: 5784

Rating: 5 / 5 (60 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Eusebia Nader

Birthday: 1994-11-11

Address: Apt. 721 977 Ebert Meadows, Jereville, GA 73618-6603

Phone: +2316203969400

Job: International Farming Consultant

Hobby: Reading, Photography, Shooting, Singing, Magic, Kayaking, Mushroom hunting

Introduction: My name is Eusebia Nader, I am a encouraging, brainy, lively, nice, famous, healthy, clever person who loves writing and wants to share my knowledge and understanding with you.