DEV Community

Cover image for How to Install Laravel (Latest Version) with Composer on Ubuntu
Chirag Patel
Chirag Patel

Posted on

How to Install Laravel (Latest Version) with Composer on Ubuntu

Are you looking for a simple way to install Laravel on Ubuntu? 🚀

In this guide, I’ll walk you step by step through installing the latest version of Laravel using Composer, the PHP dependency manager. Whether you’re new to Laravel or setting up a fresh development environment, this tutorial will help you get started quickly.

What is Laravel?

Laravel is a modern PHP framework known for its elegant syntax and powerful features such as routing, authentication, queues, and more. It’s widely used by developers to build fast, secure, and scalable web applications.


🛠 Prerequisites for Installing Laravel on Ubuntu

Before installing Laravel, make sure your system has the following:

1. PHP (>= 8.1)
Laravel requires PHP 8.1 or higher. Check your version with:

php -v
Enter fullscreen mode Exit fullscreen mode

If not installed, run:

sudo apt update
sudo apt install php php-cli php-mbstring php-xml php-bcmath unzip curl -y
Enter fullscreen mode Exit fullscreen mode

2. Composer
Laravel uses Composer to manage dependencies. Check if Composer is installed:

composer -V
Enter fullscreen mode Exit fullscreen mode

If not, install it with:

sudo apt install composer -y
Enter fullscreen mode Exit fullscreen mode

3. Database (Optional)
If you’re planning to use MySQL, install it with:

sudo apt install mysql-server -y
Enter fullscreen mode Exit fullscreen mode

Step 1: Install Laravel with Composer
Navigate to your projects directory and run:

composer create-project laravel/laravel myapp
Enter fullscreen mode Exit fullscreen mode

This will download and set up the latest Laravel version inside a folder named myapp.

Step 2: Navigate to the Project

cd myapp
Enter fullscreen mode Exit fullscreen mode

Step 3: Run the Laravel Development Server
Start Laravel’s built-in server with Artisan:

php artisan serve
Enter fullscreen mode Exit fullscreen mode

By default, your Laravel app will run at: http://127.0.0.1:8000

Step 4: Verify the Installation
Open your browser and visit the link above. If you see the Laravel welcome page, congratulations 🎉 — you’ve successfully installed Laravel on Ubuntu!


🔧 Troubleshooting Common Errors

  • PHP Extensions Missing: If you see errors about missing extensions, install them with:
sudo apt install php-xml php-mbstring php-bcmath -y
Enter fullscreen mode Exit fullscreen mode
  • Composer Memory Issues: If Composer runs out of memory, use:
COMPOSER_MEMORY_LIMIT=-1 composer create-project laravel/laravel myapp
Enter fullscreen mode Exit fullscreen mode

Conclusion

Now you know how to install the latest version of Laravel on Ubuntu using Composer. From here, you can start building routes, controllers, and awesome web applications.

Have you installed Laravel before? Share your tips or issues in the comments below!

Top comments (0)