Whether you're working with Laravel 6, 7, 8, 9, or 10, this guide will help you get your Laravel application up and running quickly and efficiently.
What You'll Learn:
-
How to clone a Laravel project from a Git repository (GitHub, GitLab, or Bitbucket)
-
How to set up an Ubuntu server for Laravel
-
Step-by-step instructions for configuring and running your Laravel project
Follow the detailed steps below to successfully clone and run your Laravel application on a server.
Prerequisites
Before setting up a Laravel project, ensure the following tools are installed on your system:
-
Git: A version control system for tracking code changes. Download and install Git from git-scm.com, and follow the setup instructions for your OS.
-
PHP: Laravel requires PHP 7.3 or higher. Verify your version using:
-
Composer: A dependency manager for PHP. Download it from getcomposer.org and follow the installation guide for your platform.
-
Web Server: Laravel comes with a built-in development server, but Apache or Nginx is recommended for production.
-
Database: Ensure your system has a compatible DBMS (e.g., MySQL, PostgreSQL, or SQLite) if your project requires database interaction.
Steps to Clone and Set Up a Laravel Project
1. Clone the Repository
Open your terminal and navigate to the directory where you want to store the project. Run:
Replace the URL with your project’s Git repository if it's different.
2. Navigate to the Project Directory
Replace
<project-directory>
with the folder name of your cloned project.
3. Install Composer Dependencies
This command installs all required PHP packages.
4. Set Up the Environment File
Create a copy of the example environment configuration:
Edit the .env
file and configure your database and other environment settings.
5. Generate the Application Key
This command sets the APP_KEY
in your .env
file, which is essential for encrypted data.
6. Configure Database Credentials
In your .env
file, update the following with your database details:
7. Run Migrations
This command will create the necessary tables in your database.
8. Serve the Application
Your Laravel app should now be accessible at:
http://localhost:8000