Deploy laravel + vuejs to shared hosting
Stefan Bogdanescu
Founder & Senior Architect · 2026-06-29
Deploying Laravel + Vue.js on Shared Hosting: A Developer's Guide
Deploying a modern full-stack application, especially one involving a monolithic backend like Laravel and a separate frontend framework like Vue.js, to restrictive shared hosting environments can feel like navigating a maze of incompatible tools. You are right to seek clarity—the process often seems overly complicated when all you want is to test your application quickly.
As senior developers, we understand that shared hosting introduces significant constraints regarding SSH access, environment configuration (like Composer and Node versions), and file permissions. This post will break down the challenges and provide practical, developer-focused solutions for deploying a Laravel/Vue application where managed services are not an option.
The Shared Hosting Dilemma: Why It’s Tricky
The fundamental issue with deploying full-stack applications to shared hosting is the mismatch between local development environments and the server environment. Local setups rely on robust tools like npm and Composer to manage dependencies, compile assets, and handle complex build processes. Shared hosts often lack the necessary root access or pre-installed dependencies required for these operations.
Your specific concern about uploading the entire node_modules directory via FTP is valid. It is generally impractical, extremely slow, and highly error-prone due to file size limits and potential permission issues. We need a strategy that minimizes manual intervention and respects the limitations of the hosting environment.
Strategy 1: Decoupling the Frontend Build Process
The most effective strategy for shared hosting is to separate the build process from the deployment process. Instead of trying to run the entire npm install and compilation cycle on the limited server, we perform the heavy lifting locally and only deploy the final, compiled static assets.
Step 1: Local Compilation (The Heavy Lifting)
Always ensure your Vue application is built locally into optimized, production-ready static files. This ensures that what gets uploaded to the server is ready to run immediately, regardless of the server's capabilities.
In your Vue project directory, execute the standard build command:
npm run build
This command compiles your Vue components (using Vite or Vue CLI) into a highly optimized /dist folder containing minified JavaScript and CSS files.
Step 2: Deploying Assets via FTP/SFTP
Once you have the compiled assets in the /dist directory, you only need to upload this specific folder to your hosting environment. This is much faster and less prone to error than uploading entire dependency trees.
For a Laravel application, these static assets are typically placed within the public directory where Laravel expects to serve them (e.g., public/build or similar structure depending on your setup).
Strategy 2: Handling Backend Dependencies (Laravel)
The Laravel backend requires Composer dependencies. While you cannot easily run complex Composer installations on shared hosting, there are two ways to manage this:
- Pre-installing Locally: Ensure all necessary PHP packages are installed locally using
composer install. - Server-Side Installation (If Possible): If your host allows basic SSH access, you can attempt to run
composer installon the server after uploading the vendor files. If this fails due to permission issues or missing extensions, you must rely solely on pre-installing everything locally and moving only the necessary code files.
Remember that when working with Laravel, understanding dependency management is key. For more advanced deployment scenarios, leveraging tools like CI/CD pipelines (even simple ones) becomes crucial for maintaining consistency across environments, as discussed in documentation related to frameworks like those found at laravelcompany.com.
Conclusion: Focus on Simplicity and Assets
Deploying a Laravel + Vue stack to shared hosting is less about magically forcing a full development environment onto the server, and more about optimizing what you deploy. Forget trying to replicate your local build machine entirely. Focus solely on compiling the frontend assets locally, ensuring your Laravel backend files are clean, and deploying only the final, static output. This approach respects the limitations of shared hosting while delivering a functional application ready for testing.