Host a Laravel Application

How to Host a Laravel Application on Windows Server

Laravel is one of the most popular PHP frameworks for building modern web applications. While Linux servers are commonly used for deployment, many developers and organizations run Laravel applications on Windows Server as well. In this guide, we’ll walk through the process of hosting a Laravel application on Windows using XAMPP and PHP.


Prerequisites

Before starting, make sure you have the following installed:

  • Windows Server (or Windows 10/11 for local setup)

  • XAMPP with Apache and MySQL

  • PHP 8.2 (or the version required by your Laravel app)

  • Composer (PHP dependency manager)

  • A Laravel project ready to be deployed


Step 1: Place Your Laravel Project in XAMPP’s htdocs

  1. Copy your Laravel project folder to:

    C:\xampp\htdocs\

    For example:

    C:\xampp\htdocs\admission_crm
  2. Verify that the public directory of your Laravel project contains index.php, which will act as the entry point.


Step 2: Configure Laravel Environment

  1. Navigate to your project directory:

  2. Copy the .env.example file and rename it to .env:

  3. Update your .env file with database credentials, app URL, and other configurations. Example:


Step 3: Clear and Rebuild Laravel Cache

Run the following commands to clear cached configurations, routes, and application cache:

Then, generate a new application key:


Step 4: Run Database Migrations

To create database tables, run:

If Laravel reports "Nothing to migrate", it means your migrations are already applied.


Step 5: Install Dependencies with Composer

Laravel requires dependencies from Composer. Run the following command inside your project:

This will install all packages listed in composer.json.


Step 6: Start Laravel Development Server

Laravel has a built-in development server. Run:

  • The app will be accessible on: 👉 http://localhost:9000

  • If you want to access it from another machine in the same network, use your server’s IP: 👉 http://<your-server-ip>:9000


Step 7: Configure Apache Virtual Host (Optional for Production)

For production hosting, it’s better to configure Apache instead of running PHP’s built-in server.

  1. Open Apache configuration file:

  2. Add a VirtualHost entry:

  3. Edit C:\Windows\System32\drivers\etc\hosts and add:

  4. Restart Apache from the XAMPP control panel.

Now you can access your app at: http://admission-crm.local


Conclusion

By following these steps, you can successfully host a Laravel application on Windows Server using XAMPP. For development, Laravel’s built-in PHP server works fine, but for production, it’s recommended to configure Apache or Nginx with proper environment settings and security hardening.


REFERENCES

Last updated

Was this helpful?