Partner with experts to accelerate your digital transformation journey
Bobcares

Install Laravel on Debian 11: Quick and Simple Installation Process

PDF Header PDF Footer

Complete guide to Install Laravel on Debian 11 and configure it for smooth setup. Our Laravel Support team is ready to assist you. 

Install Laravel on Debian 11:

Laravel is a powerful PHP framework for modern web apps. To install it on Debian 11, you need PHP, Composer, a web server, a database, and Node.js ready before starting the setup. This article includes the prerequisites, installation steps, and web server configuration to get Laravel running smoothly.

Prerequisites for Laravel Installation

Before installing Laravel on Debian 11, it helps to know why developers trust this framework. Laravel is widely used for its clean syntax, speed, and flexibility. In fact, there are at least 7 reasons for Laravel being the preferred choice when building secure and scalable web applications.

To get started, you need PHP 8.2 or higher with extensions like BCMath, Ctype, cURL, DOM, Fileinfo, JSON, Mbstring, OpenSSL, PCRE, PDO, Tokenizer, and XML. Composer is also required to manage libraries and make installation smooth. A web server such as Apache or Nginx and a database like MySQL or PostgreSQL are also essential.

You should also set up Node.js with NPM or Bun to handle frontend assets like CSS and JavaScript. Using a code editor such as Visual Studio Code or PHPStorm will make development easier. With these tools ready, you can move forward to Install Laravel on Debian 11 or even Install Laravel on Plesk Server if you prefer a managed hosting environment.

Step 1 Update the System and Install Tools

Make sure your server is up to date and has the basic utilities you will need.

sudo apt update && sudo apt upgrade -y
sudo apt install -y curl wget git unzip

Step 2 Install PHP with Extensions

Laravel requires PHP along with specific extensions. Install them with this command:

sudo apt install -y php-cli php-fpm php-mysql php-mbstring php-xml php-bcmath php-json php-zip

Step 3 Install Composer

Composer is the dependency manager that handles Laravel’s packages. Install it globally:

curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer

Check the version:
composer -V

Step 4 Install a Web Server<

Laravel can run on Apache or Nginx. Pick the one you prefer.

Apache

sudo apt install -y apache2 libapache2-mod-php
sudo a2enmod rewrite
sudo systemctl restart apache2

Nginx

sudo apt install -y nginx
sudo systemctl restart nginx

Step 5 Install Laravel Project

Move to the web root folder and create a new Laravel project.

cd /var/www/html
sudo composer create-project laravel/laravel myapp

Replace myapp with your project name.

Step 6 Set Permissions

Give the web server access to Laravel’s storage and cache directories.

sudo chown -R www-data:www-data /var/www/html/myapp
sudo chmod -R 775 /var/www/html/myapp/storage
sudo chmod -R 775 /var/www/html/myapp/bootstrap/cache

Step 7 Configure Web Server

Apache Configuration
Create a new virtual host file:

sudo nano /etc/apache2/sites-available/myapp.conf

Add:
<VirtualHost *:80>
ServerName your-domain.com
DocumentRoot /var/www/html/myapp/public
<Directory /var/www/html/myapp/public>
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Enable the site and restart Apache:
sudo a2ensite myapp.conf
sudo systemctl restart apache2

Nginx Configuration

Create a new server block:

sudo nano /etc/nginx/sites-available/myapp

Paste:
server {
listen 80;
server_name your-domain.com;
root /var/www/html/myapp/public;
index index.php index.html;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
}

Enable the config and restart Nginx:

sudo ln -s /etc/nginx/sites-available/myapp /etc/nginx/sites-enabled/
sudo systemctl restart nginx

Step 8 Access Laravel in Browser

Open your browser and enter your domain or server IP. You should see the Laravel welcome page, which confirms that the installation is complete.

Conclusion 

By following these steps, you can successfully Install Laravel on Debian 11 and start building powerful web applications. With the right setup of PHP, Composer, database, and web server, your Laravel project will run smoothly and be ready for development.

 

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Get featured on the Bobcares blog and share your expertise with a global tech audience.

WRITE FOR US
server management

Spend time on your business, not on your servers.

TALK TO US

Or click here to learn more.

Speed issues driving customers away?
We’ve got your back!