Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»PHP Framework»How To Install Laravel on Debian 9

    How To Install Laravel on Debian 9

    RahulBy RahulSeptember 8, 20183 Mins ReadUpdated:July 15, 2021

    Laravel is one of the best open source, MVC PHP framework, designed for the faster development of web applications. You can simply install and use on your development system. This article will help you to install Laravel 7 PHP Framework on Debian 9 (Stretch) system.

    Laravel required following software and extensions to be installed on your system:

    • Apache
    • MySQL/MariaDB
    • PHP >= 7.0.0
    • OpenSSL PHP Extension
    • PDO PHP Extension
    • Mbstring PHP Extension
    • Tokenizer PHP Extension
    • XML PHP Extension

    Step 1 – Prerequsiteis

    To start with Laravel, we first need to set up a running LAMP server. If you have already running LAMP stack skip this step else use followings commands to set up the lamp on Debian 9 system.

    Install PHP 7

    sudo apt-get install git python-software-properties
    wget -q https://packages.sury.org/php/apt.gpg -O- | sudo apt-key add -
    echo "deb https://packages.sury.org/php/ stretch main" | sudo tee /etc/apt/sources.list.d/php.list
    
    sudo apt update
    sudo apt install php php-mcrypt php-gd php-mbstring php-xml
    

    Install Apache2

    sudo apt install apache2 libapache2-mod-php
    

    Install MySQL

    sudo apt install mysql-server php-mysql
    

    Step 2 – Install PHP Composer

    The composer is required for installing Laravel dependencies. So use below commands to download and use as a command in our system.

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

    Step 3 – Install Laravel on Debian 9

    Download the latest version of Laravel from the official git repository. Use the below command to clone the master branch of the Laravel from GitHub.

    cd /var/www
    git clone https://github.com/laravel/laravel.git
    

    Navigate to Laravel code directory and use composer to install all dependencies required for the Laravel framework.

    cd /var/www/laravel
    sudo composer install
    

    The dependencies installation may take some time as per your network speed. After successfully installing all dependencies, set the proper permissions on all files.

    chown -R www-data.www-data /var/www/laravel
    chmod -R 755 /var/www/laravel
    chmod -R 777 /var/www/laravel/storage
    

    Step 4 – Set Encryption Key

    Now, rename the .evn.example file to .env in projects main directory. This will use to setup application environment for the project.

    mv .env.example .env
    

    Now generate base64 random number encryption key, which used by the Illuminate encrypter service.

    php artisan key:generate
    
    Application key [base64:Wer9JfZHN4qYQt9i8Hn1hLt8LWPeT3urzdI0hVqfzJM=] set successfully.
    

    Edit the .env configuration file and update the required settings. Also, make sure APP_KEY is properly set as generated in above command.

    vi .env
    
    APP_NAME=Laravel
    APP_ENV=local
    APP_KEY=base64:Wer9JfZHN4qYQt9i8Hn1hLt8LWPeT3urzdI0hVqfzJM=
    APP_DEBUG=true
    APP_URL=http://localhost
    

    Step 5 – Creating MySQL Database

    You may also require creating a database for your Laravel application. Login to your MySQL server and create MySQL database and user.

    1
    2
    3
    4
    mysql> CREATE DATABASE laravel;
    mysql> GRANT ALL ON laravel.* to 'laravel'@'localhost' IDENTIFIED BY 'secret_password';
    mysql> FLUSH PRIVILEGES;
    mysql> quit

    Edit the .env file and update database settings.

    DB_CONNECTION=mysql
    DB_HOST=127.0.0.1
    DB_PORT=3306
    DB_DATABASE=laravel
    DB_USERNAME=laravel
    DB_PASSWORD=secret_password
    

    Step 6 – Apache Configuration

    You can create a new Apache configuration file or edit Apache default virtual host configuration file 000-default.conf and update DocumentRoot to Laravel public directory as below.

    vim /etc/apache2/sites-available/000-default.conf
    

    Update configuration as:

    <VirtualHost *:80>
    
            ServerAdmin [email protected]
            DocumentRoot /var/www/laravel/public
    
            <Directory />
                    Options FollowSymLinks
                    AllowOverride None
            </Directory>
            <Directory /var/www/laravel>
                    AllowOverride All
            </Directory>
    
            ErrorLog ${APACHE_LOG_DIR}/error.log
            CustomLog ${APACHE_LOG_DIR}/access.log combined
    
    </VirtualHost>
    

    Reload Apache configuration changes by restarting service using below command

    sudo service apache2 restart
    

    Step 7 – Access Laravel Application

    Laravel PHP framework has been successfully configured on your system. Access the Laravel application in your favorite web browser as per configured Apache.

    Install Laravel 5

    Let’s start building an awesome application using Laravel PHP Framework.

    Happy coding!

    Framework Laravel PHP php framework
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp
    Previous ArticleHow To Install Phalcon PHP on Debian 9 (Stretch)
    Next Article How to Configure Static IP Addresses on Ubuntu 18.04 Server Edition

    Related Posts

    How to Install Angular CLI on Ubuntu 22.04

    4 Mins Read

    How to Install Composer on Ubuntu 22.04

    Updated:June 24, 20223 Mins Read

    How To Install PHP (8.1, 7.4 or 5.6) on Ubuntu 22.04

    Updated:June 19, 20223 Mins Read

    How to Install Apache, MySQL, PHP (LAMP Stack) on Ubuntu 22.04

    Updated:June 28, 20225 Mins Read

    How To Setup Apache, PHP & MongoDB in Ubuntu & Debian

    Updated:October 8, 20213 Mins Read

    How To Install and Use PHP Composer on Debian 11

    Updated:February 16, 20224 Mins Read

    2 Comments

    1. Charly on October 18, 2019 3:29 am

      Thanks. I had to install php-zip too:

      $ apt install zip unzip php-zip

      Reply
    2. SALIM Souilah on July 10, 2019 5:57 pm

      at the end of the installation, does not open
      otherwise very nice tutorial

      [Wed Jul 10 19:53:45.906352 2019] [mpm_prefork:notice] [pid 28150] AH00169: caught SIGTERM, shutting down
      [Wed Jul 10 19:53:46.020916 2019] [mpm_prefork:notice] [pid 28674] AH00163: Apache/2.4.25 (Debian) configured — resuming normal operations
      [Wed Jul 10 19:53:46.020985 2019] [core:notice] [pid 28674] AH00094: Command line: ‘/usr/sbin/apache2’

      Reply

    Leave A Reply Cancel Reply

    Recent Posts
    • How To Install Docker on Ubuntu 22.04
    • How to Install Bower on Ubuntu 22.04 & 20.04
    • How to run “npm start” through Docker
    • Filesystem Hierarchy Structure (FHS) in Linux
    • How to accept user input in Python
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.