Debian 11 allows installing PHP 7.4, but the latest Laravel (at the time of this writing is version 10) has as a requirement to have a PHP version equal to or higher than 8.1. We will use the DPA (Debian Package Archive) available at https://deb.sury.org/, since the official version is not so updated.

sudo apt install apt-transport-https
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list
sudo apt update
sudo apt upgrade

PHP Packages

Install the PHP 8.1 along with its modules that are required by Laravel, such as SQLite, MySQL, GD, BZ2, ZIP etc.

sudo apt install php8.1-{cli,sqlite3,mysql,bz2,zip,gd,curl,intl,mbstring,xml}

After the installation completed, you can check the installed PHP on your system by running the command php --version.

$ php --version
PHP 8.1.18 (cli) (built: May 17 2023 15:59:20) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.18, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.18, Copyright (c), by Zend Technologies

Install PHP Composer

There are several way to install Laravel, but in this writing I’ll install the Laravel application with Composer. Download & Install PHP Composer with following steps:

wget https://getcomposer.org/installer -O - -q | php -- --quiet

You can check the installation with following command:

$ ./composer.phar --version
Composer version 2.5.7 2023-05-24 15:00:39

Put the composer.phar into a directory on your PATH, so you can simply call composer from any directory (Global install):

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

Install Laravel Application

We are now ready to install a Laravel application in your system. Run the composer create-project command to create a new Laravel application. For example I want to create an application named “myapp”:

composer create-project laravel/laravel myapp

After the installation succeeded, run the artisan serve command. Include the --host=0.0.0.0 option in the command so that it runs outside the server.

cd myapp
php artisan serve --host=0.0.0.0

Open the browser and navigate to your server application:

Leave a comment

Leave a Reply