Skip to content

Setup Laravel development environment in Linux(Ubuntu)

Laravel is a very popular PHP web development framework. From last two years it’s at the top in the PHP frameworks list.

In this article we’ll see how to setup development environment for Laravel on Linux operating system. Linux have many flavors and distros to setup differs between these on a minor scale.

I personally like setting up virtual machines per project and inside that creating the development environment. This way my original OS (host OS) is not affected and my every project have it’s own dedicated machine, although it virtual but acts like real. This also require that your host machine must have sufficient RAM. If you don’t like creating virtual machines then you can follow these steps directly on your computer.

Skip this if you are not going to use virtual machine. First create a new virtual machine and install ubuntu in it. I use VirtualBox by Oracle. Now login to your newly installed ubuntu system.

Open browser and search for XAMPP. Download XAMPP for Linux.

After download is complete, open terminal and go to the file download location using terminal.

Run these two commands:

chmod 755 XAMPPfilename.run
sudo ./XAMPPfilename.run

It will show the UI installer window Follow the steps and install XAMPP on your system. When installation is complete, we need to add the PHP path in the system so that we can run PHP command easily from terminal. Run this command to edit the path environment:

sudo vi /etc/environment

Now add this in the end of this file.

:/opt/lamp/bin/php

Now link it by this command:

sudo ln -s /opt/lamp/bin/php /usr/local/bin/php

Start all xampp services by:

sudo /opt/lamp/lamp start

XAMPP is properly installed and setup on the system. Now we need to install composer. Composer is dependency manager for PHP applications. Install composer by running these :

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

Now go to any location where you want to create your project and from terminal run this command:

composer create-project --prefer-dist laravel/laravel blog

This will create a new laravel project and then it will install all the dependencies. To run this project go inside the project (your project name) and run this command:

php artisan serve

You must see default laravel project. Happy coding!

4 Comments

  1. Mark Sherrill Mark Sherrill

    Hello Siddharth,

    I have xampp and would like to run laravel globally, rather than within each new project….
    composer create-project –prefer-dist laravel/laravel blog

    Would this possible or recommended when using xampp?

    • SiddharthShankerMishra SiddharthShankerMishra

      Laravel gives only small development web server and that is limited to only that project. If you are using XAMPP then you will not need laravel dev server, because XAMPP (Apache web server) will handle all requests.

  2. Trevin Trevin

    Hi Mate,

    I tried to install the laravel project after installing composer and xampp. But unfortunately I’m getting the below error.

    Your requirements could not be resolved to an installable set of packages.

    Problem 1
    – phpunit/phpunit 7.5.x-dev requires ext-dom * -> the requested PHP extension dom is missing from your system.
    – phpunit/phpunit 7.5.1 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    – phpunit/phpunit 7.5.0 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    – phpunit/phpunit 7.4.5 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    – phpunit/phpunit 7.4.4 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    – phpunit/phpunit 7.4.3 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    – phpunit/phpunit 7.4.2 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    – phpunit/phpunit 7.4.1 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    – phpunit/phpunit 7.4.0 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    – phpunit/phpunit 7.3.5 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    – phpunit/phpunit 7.3.4 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    – phpunit/phpunit 7.3.3 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    – phpunit/phpunit 7.3.2 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    – phpunit/phpunit 7.3.1 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    – phpunit/phpunit 7.3.0 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    – phpunit/phpunit 7.2.7 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    – phpunit/phpunit 7.2.6 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    – phpunit/phpunit 7.2.5 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    – phpunit/phpunit 7.2.4 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    – phpunit/phpunit 7.2.3 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    – phpunit/phpunit 7.2.2 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    – phpunit/phpunit 7.2.1 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    – phpunit/phpunit 7.2.0 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    – phpunit/phpunit 7.1.5 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    – phpunit/phpunit 7.1.4 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    – phpunit/phpunit 7.1.3 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    – phpunit/phpunit 7.1.2 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    – phpunit/phpunit 7.1.1 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    – phpunit/phpunit 7.1.0 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    – phpunit/phpunit 7.0.3 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    – phpunit/phpunit 7.0.2 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    – phpunit/phpunit 7.0.1 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    – phpunit/phpunit 7.0.0 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    – Installation request for phpunit/phpunit ^7.0 -> satisfiable by phpunit/phpunit[7.0.0, 7.0.1, 7.0.2, 7.0.3, 7.1.0, 7.1.1, 7.1.2, 7.1.3, 7.1.4, 7.1.5, 7.2.0, 7.2.1, 7.2.2, 7.2.3, 7.2.4, 7.2.5, 7.2.6, 7.2.7, 7.3.0, 7.3.1, 7.3.2, 7.3.3, 7.3.4, 7.3.5, 7.4.0, 7.4.1, 7.4.2, 7.4.3, 7.4.4, 7.4.5, 7.5.0, 7.5.1, 7.5.x-dev].

    To enable extensions, verify that they are enabled in your .ini files:
    – /etc/php/7.2/cli/php.ini
    – /etc/php/7.2/cli/conf.d/10-opcache.ini
    – /etc/php/7.2/cli/conf.d/10-pdo.ini
    – /etc/php/7.2/cli/conf.d/20-calendar.ini
    – /etc/php/7.2/cli/conf.d/20-ctype.ini
    – /etc/php/7.2/cli/conf.d/20-exif.ini
    – /etc/php/7.2/cli/conf.d/20-fileinfo.ini
    – /etc/php/7.2/cli/conf.d/20-ftp.ini
    – /etc/php/7.2/cli/conf.d/20-gettext.ini
    – /etc/php/7.2/cli/conf.d/20-iconv.ini
    – /etc/php/7.2/cli/conf.d/20-json.ini
    – /etc/php/7.2/cli/conf.d/20-mbstring.ini
    – /etc/php/7.2/cli/conf.d/20-phar.ini
    – /etc/php/7.2/cli/conf.d/20-posix.ini
    – /etc/php/7.2/cli/conf.d/20-readline.ini
    – /etc/php/7.2/cli/conf.d/20-shmop.ini
    – /etc/php/7.2/cli/conf.d/20-sockets.ini
    – /etc/php/7.2/cli/conf.d/20-sysvmsg.ini
    – /etc/php/7.2/cli/conf.d/20-sysvsem.ini
    – /etc/php/7.2/cli/conf.d/20-sysvshm.ini
    – /etc/php/7.2/cli/conf.d/20-tokenizer.ini
    You can also run `php –ini` inside terminal to see which files are used by PHP in CLI mode.

    I’d appreciate if you could have a look at this and advise.

  3. Chisevo Chisevo

    Thanks man, its save me.

Leave a Reply to SiddharthShankerMishra Cancel reply

Your email address will not be published.