Partner with experts to accelerate your digital transformation journey
Bobcares

How to Set Up and Install Laravel Framework on Debian 12

PDF Header PDF Footer

Install Laravel on Debian 12 for fast, reliable, and efficient web application setup. Our Laravel Support team is ready to assist you. 

Install Laravel on Debian 12

Looking to build modern, high-performance web apps with ease? Laravel is the PHP framework that developers love for its speed, simplicity, and scalability. In this guide, we’ll show you why Laravel shines and how to set it up seamlessly on Debian 12.

What is Laravel?

Laravel is an open-source PHP framework that simplifies modern web development. It follows the MVC architecture, ensuring clean code and easy maintenance. With features like Artisan CLI, Blade templating, and Eloquent ORM, Laravel empowers developers to build secure, scalable, and high-performance applications with ease.

Core Features of Laravel

Laravel comes with powerful features that make web development simple and efficient. Its MVC architecture keeps projects organized, while Eloquent ORM streamlines database management by replacing complex SQL with an object-oriented approach. Blade templating makes it easy to create dynamic, reusable views, and Artisan CLI helps automate tasks like code generation and migrations.

In addition, Laravel includes built-in authentication and authorization for secure user management, a flexible routing system for clean URLs, and database migrations for smooth version control. With queues, scheduling, and strong testing support, Laravel provides everything developers need to build modern, scalable, and reliable web applications.

Why Choose Laravel on Debian 12

Choosing Laravel on Debian 12 gives developers a secure, stable, and high-performing setup for modern web applications. Laravel speeds up development with Artisan CLI, Eloquent ORM, and MVC architecture, while Debian 12 adds stability, security, and fast performance. Together, they form a reliable platform for building scalable and secure projects.

Key benefits include:

  • Strong security features on both ends.
  • Lightweight Debian boosts Laravel’s speed.
  • Simple deployment and maintenance.
  • Handles heavy traffic with caching and queues.

This combination is perfect for e-commerce, APIs, CMS, and enterprise applications.

Laravel + Nginx setup on Ubuntu 24.04 made it simple!

Prerequisites

Before you install Laravel on Debian 12, you need to prepare your server with the right tools and services. This includes updating your system, installing the LAMP stack (PHP, a web server, and a database), and setting up Composer and Node.js. Once these prerequisites are in place, your server will be ready to run Laravel smoothly.

How to Install LAMP Stack

Step 1: Install Apache and Update Firewall

sudo apt update
sudo apt install apache2 -y
sudo ufw allow 'Apache Full'

Check if Apache is running:
systemctl status apache2

Step 2: Install MySQL Database
sudo apt install mysql-server -y
sudo mysql_secure_installation

Login to MySQL to confirm:
sudo mysql -u root -p

Step 3: Install PHP
sudo apt install php libapache2-mod-php php-mysql -y
php -v

Step 4: Setup Virtual Host (Optional but Recommended)
Create a directory for your site:
sudo mkdir -p /var/www/yourdomain
sudo chown -R $USER:$USER /var/www/yourdomain

Create a virtual host config file:
sudo nano /etc/apache2/sites-available/yourdomain.conf

Add the following:
<VirtualHost *:80>
ServerAdmin admin@yourdomain
ServerName yourdomain
ServerAlias www.yourdomain
DocumentRoot /var/www/yourdomain
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Enable the site and restart Apache:
sudo a2ensite yourdomain.conf
sudo a2dissite 000-default.conf
sudo systemctl reload apache2

Step 5: Test PHP Processing
Create a PHP test file:
sudo nano /var/www/yourdomain/info.php

Add:
<?php
phpinfo();
?>

Now visit http://yourdomain/info.php in your browser. If you see the PHP info page, your LAMP stack is working!

Troubleshoot missing Laravel Fortify features quickly and easily!

Configuring PHP

Before installing Laravel, enable the required PHP extensions. Open the PHP config file:

sudo nano /etc/php/8.2/apache2/php.ini

Uncomment these lines:
extension=fileinfo
extension=mbstring
extension=openssl

Save the file, restart Apache, and verify with:
sudo php -m

You should see the extensions listed in the output.

Configuring MariaDB Server

Installing and configuring MariaDB on Debian 12 is straightforward. Start by installing the MariaDB server with sudo apt install mariadb-server -y, then enable and start the service so it runs automatically. Next, secure your database by running mysql_secure_installation. This step lets you set a strong root password, remove anonymous users, disable remote root logins, and delete the default test database, making your server much safer.

Once secured, you can optimize performance by adjusting the configuration file located in /etc/mysql/mariadb.conf.d/50-server.cnf. Common tweaks include setting the bind-address for network access and adjusting innodb_buffer_pool_size for better memory usage. Finally, log in to the MariaDB shell to create new databases and users with proper privileges. With these steps, you’ll have a secure, high-performance MariaDB setup ready for your Laravel projects.

Installing Composer

Composer is a powerful PHP package manager that simplifies installing Laravel and its dependencies. To set it up on Debian 12, run:

sudo apt install composer -y

Once the installation is complete, check the version to confirm it’s installed correctly:
sudo -u www-data composer --version

If everything is successful, you will see the Composer version displayed.

Creating Your First Laravel Project

To begin, create a directory for your Laravel app and set the correct permissions:

sudo mkdir -p /var/www/{.cache,.config,testapp}
sudo chown -R www-data:www-data /var/www/{.cache,.config,testapp}

Next, move into the project folder and install Laravel using Composer:
cd /var/www/testapp/
sudo -u www-data composer create-project laravel/laravel .

After the installation, open the .env file to configure your app URL and database details:
APP_URL=http://testapp.local
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=testapp
DB_USERNAME=testapp
DB_PASSWORD=password

Finally, run the migration command to build the required database tables:
sudo -u www-data php artisan migrate

Your first Laravel project is now ready to run on Debian 12.

Configuring Apache Virtual Host

To make your Laravel project accessible through a web browser, you need to configure an Apache virtual host. Start by enabling the rewrite module, then create a new configuration file in the Apache sites-available directory. In this file, set your domain name and point the DocumentRoot to the Laravel public directory. Once you save the changes, enable the new site, check the configuration for syntax errors, and restart Apache. With these steps complete, your Laravel application on Debian 12 will be live and ready to access through your chosen domain.

Accessing Your Laravel Project

To access your Laravel project, edit the hosts file on your machine. On Linux, use sudo nano /etc/hosts, and on Windows, edit the file in C:\Windows\System32\drivers\etc\hosts. Add your server’s IP address along with the domain name, for example 192.168.10.15 testapp.local. Save the file, then open your browser and visit http://testapp.local to see the Laravel welcome page.

Step-by-step guide to handling Laravel errors effectively

[Need assistance with a different issue? Our team is available 24/7.]

Conclusion

In conclusion, choosing to install Laravel on Debian 12 provides developers with a reliable, secure, and high-performing environment. With Laravel’s robust features and Debian’s stability, this setup is ideal for creating scalable and modern web applications. By following the steps above, you can confidently deploy and manage your Laravel projects on Debian 12.

In brief, our Support Experts demonstrated how to fix the “554 5.7.1 : Relay access denied” error.

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!