How to Install Laravel and Create a New Project on Linux
Laravel is a popular PHP framework for web development. This guide will walk you through installing Laravel and creating a new project on a Linux system.
Step 1: Update System Packages
Before installing Laravel, ensure your system is up-to-date. Open the terminal and run:
Step 2: Install PHP and Required Extensions
Laravel requires PHP and some extensions. Install them using:
Check if PHP is installed correctly:
Step 3: Install Composer (PHP Dependency Manager)
Laravel requires Composer to manage dependencies. Install it using:
Verify installation:
Step 4: Install Laravel Installer
Now, install the Laravel Installer globally:
Add Composer’s bin directory to your system PATH so you can use the laravel
command:
Check if Laravel is installed correctly:
Step 5: Create a New Laravel Project
Once Laravel is installed, create a new project.
Option 1: Using Laravel Installer
Option 2: Using Composer
If laravel new
doesn’t work, use Composer instead:
Step 6: Navigate to Your Project and Start the Server
Move into your project directory:
Start the Laravel development server:
Now, open your browser and visit:
Step 7: (Optional) Install Laravel UI for React
If you want to use React with Laravel, install Laravel UI:
Then scaffold React:
Conclusion
Congratulations! 🎉 You have successfully installed Laravel on Linux and created a new project. Now, you can start building your web application.