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
- Visit https://getcomposer.org/download/ and download the Composer installer for Windows.
- 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
- Open a command prompt or terminal window.
- Navigate to the directory where you want to install your Laravel project using the
cd
command. - 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
- For Apache:
- If you’re using Apache, make sure the
mod_rewrite
module is enabled. You can do this by uncommenting the lineLoadModule rewrite_module modules/mod_rewrite.so
in yourhttpd.conf
file. - Create a new virtual host configuration pointing to the
public
directory of your Laravel project. - Restart Apache to apply the changes.
- If you’re using Apache, make sure the
- 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.
- If you’re using Nginx, create a new server block configuration with the necessary settings to serve your Laravel application from the
Step 4: Configure the Database
- Install MySQL if you haven’t already, and ensure it’s up and running.
- Create a new database for your Laravel project using a MySQL client or command-line tools.
Step 5: Configure Environment Variables
- Rename the
.env.example
file in the root directory of your Laravel project to.env
. - 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
- Run the following command to generate a unique application key:
php artisan key:generate
Step 7: Test Your Installation
- Start your web server (Apache or Nginx).
- 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.