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
htdocsCopy your Laravel project folder to:
C:\xampp\htdocs\For example:
C:\xampp\htdocs\admission_crmVerify that the
publicdirectory of your Laravel project containsindex.php, which will act as the entry point.
Step 2: Configure Laravel Environment
Navigate to your project directory:
Copy the
.env.examplefile and rename it to.env:Update your
.envfile 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:9000If 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.
Open Apache configuration file:
Add a VirtualHost entry:
Edit
C:\Windows\System32\drivers\etc\hostsand add: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?