In this tutorial, I'll guide you through the process of cloning a Laravel project from GitLab. I'll cover the steps for cloning a Laravel project from GitHub, GitLab, or Bitbucket and setting it up on an Ubuntu server from scratch. This tutorial is applicable for Laravel versions 6 through 10.
By following the step-by-step instructions below, you’ll be able to easily clone and set up your Laravel application on the server.
Prerequisites:
-
Git: Git is a version control system used to track changes in source code during software development. Ensure that Git is installed on your system. You can download Git from here and follow the installation instructions based on your operating system.
-
PHP: Laravel requires PHP to be installed on your system. You need PHP version 7.3 or higher. To check your PHP version, run
php -v
in your terminal. -
Composer: Composer is a dependency manager for PHP, which is used to install Laravel and its dependencies. You can download Composer from here and follow the installation instructions based on your operating system.
-
Web Server: A web server is required to serve your Laravel application. While Laravel comes with a built-in development server, it’s recommended to use Apache or Nginx for production deployments.
-
Database: If the cloned project uses a database, ensure you have the required database management system installed on your system (e.g., MySQL, PostgreSQL, SQLite).
Steps to Clone and Set Up the Project:
-
Clone the Laravel Project: Open a terminal or command prompt and navigate to the directory where you want to clone your Laravel project. Run the following command to clone the repository:
git clone https://gitlab.com/SoengSouy/hr-system-management-laravel-11.git
Replace
<repository-url>
with the URL of your Laravel project's Git repository. You can find this URL on your Git hosting service (GitHub, GitLab, Bitbucket, etc.). -
Navigate to the Project Directory: Change into the project directory using the following command:
cd <project-directory>
Replace
<project-directory>
With the name of your project directory. -
Install Composer Dependencies: Laravel uses Composer to manage its dependencies. Run the following command to install the necessary dependencies:
composer install
-
Create a Copy of the Environment File: Laravel requires a
.env
file for configuration. Create a copy of the.env.example
file and name it.env
:cp .env.example .env
Afterward, edit the
.env
file to configure your database connection and other settings. -
Generate the Application Key: Run the following command to generate the application key:
php artisan key:generate
-
Update Your Database Credentials: Open the
.env
file located in the root of your project, and update your database credentials as follows:DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=your_db DB_USERNAME=root DB_PASSWORD=your_database_password
-
Migrate the Database: Run the database migrations to create the necessary tables in your database:
php artisan migrate
-
Serve the Application: To start the Laravel development server, run the following command:
php artisan serve
This will make your application accessible at
http://localhost:8000
by default.