How to Install Laravel in Windows – An step by step guide

In this tutorial, we will walk you through the process of installing Laravel on a Windows operating system. By following these steps, you’ll not only install Laravel but also have a fully functional Laravel environment ready for your web development projects. Laravel, a powerful PHP framework, empowers developers to create feature-rich and dynamic web applications with ease.

Step 1: Install Composer

  1. Visit https://getcomposer.org/download/ and download the Composer installer for Windows.
  2. Run the installer and follow the installation instructions. Make sure to select the option to add Composer to your PATH during installation.

Step 2: Install Laravel

  1. Open a command prompt or terminal window.
  2. Navigate to the directory where you want to install your Laravel project using the cd command.
  3. Run the following command to create a new Laravel project:
composer create-project --prefer-dist laravel/laravel your-project-name

Replace your-project-name with the desired name of your Laravel project.

Step 3: Configure the Web Server

  1. For Apache:
    • If you’re using Apache, make sure the mod_rewrite module is enabled. You can do this by uncommenting the line LoadModule rewrite_module modules/mod_rewrite.so in your httpd.conf file.
    • Create a new virtual host configuration pointing to the public directory of your Laravel project.
    • Restart Apache to apply the changes.
  2. For Nginx:
    • If you’re using Nginx, create a new server block configuration with the necessary settings to serve your Laravel application from the public directory.
    • Restart Nginx to apply the changes.

Step 4: Configure the Database

  1. Install MySQL if you haven’t already, and ensure it’s up and running.
  2. Create a new database for your Laravel project using a MySQL client or command-line tools.

Step 5: Configure Environment Variables

  1. Rename the .env.example file in the root directory of your Laravel project to .env.
  2. Open the .env file and configure the database connection settings (DB_HOST, DB_PORT, DB_DATABASE, DB_USERNAME, and DB_PASSWORD) to match your MySQL setup.

Step 6: Generate Application Key

  1. Run the following command to generate a unique application key:
php artisan key:generate

Step 7: Test Your Installation

  1. Start your web server (Apache or Nginx).
  2. Open a web browser and visit http://localhost/your-project-name/public. You should see the Laravel welcome page.

Congratulations! You have successfully installed Laravel on your Windows machine. You’re now ready to start building powerful web applications using the Laravel framework.

Leave a Reply

Your email address will not be published. Required fields are marked *

Post comment