无SSH权限下Laravel 5.6+Vue.js项目共享主机部署咨询
Hey there, I’ve been in your exact spot before—deploying a Laravel 5.6 + Vue.js app on a shared host without SSH access can feel like hitting a wall, but it’s totally manageable. Let me break down the step-by-step solution that worked for me and many others:
Since you can’t run commands on the shared host, you need to handle all build and setup steps on your local machine first:
Compile Vue.js Assets
Runnpm run prodin your local project directory. This will compile all your Vue components, CSS, and JS into minified files in thepublic/jsandpublic/cssfolders. Make sure these compiled files are included when you upload your project—they’re what the browser will load.Configure Laravel for Production
- Copy
.env.exampleto.envand fill in your shared host’s database credentials (host, name, username, password). Runphp artisan key:generateto create anAPP_KEY, and keep this value handy (you’ll need it in the uploaded.envfile). - Set
APP_DEBUG=falseandAPP_URLto your actual domain in.env—debug mode should never be on in production. - Run
php artisan config:cacheandphp artisan route:cachelocally. This generates cached config and route files so the server doesn’t need to run these commands later. If you ever change configs or routes, repeat these steps and re-upload the updated files. - Install production-only dependencies: Run
composer install --no-dev --optimize-autoloaderto get a leanvendorfolder without development tools.
- Copy
Most shared hosts use cPanel or a similar control panel with a file manager—here’s how to structure your upload:
Move Public Folder Content to Web Root
Your shared host’s web root is usuallypublic_html. Upload everything from your localpublicfolder directly intopublic_html(this is where your app’s entry pointindex.phplives).Upload Remaining Project Files
Create a new folder outsidepublic_html(e.g.,laravel-app) and upload all other project files/folders here:app,bootstrap,config,database,storage,vendor,.env, etc. Keeping these outside the web root is critical for security.Fix File Paths in
index.php
Open theindex.phpfile inpublic_htmland update the paths to point to your newlaravel-appfolder. Change these lines:require __DIR__.'/../vendor/autoload.php'; $app = require_once __DIR__.'/../bootstrap/app.php';To something like:
require __DIR__.'/../laravel-app/vendor/autoload.php'; $app = require_once __DIR__.'/../laravel-app/bootstrap/app.php';Adjust the path to match whatever you named your project folder outside
public_html.
Using your host’s file manager, update these permissions:
- Set the
storagefolder andbootstrap/cachefolder to 755 (if that doesn’t work, try 777 temporarily—just remember to switch back to 755 if possible for security). - Set your
.envfile to 644—this prevents unauthorized access to your database credentials and other sensitive settings.
- In your shared host control panel, create a new MySQL database and user, then grant the user full access to the database. Make sure these details match what you put in your
.envfile. - Export your local database (use phpMyAdmin or
mysqldumplocally) and import the SQL file into your shared host’s database via phpMyAdmin.
Visit your domain in a browser—your Laravel + Vue app should load! If you run into issues:
- Check the host’s error logs (cPanel has an "Error Logs" section) for details.
- Temporarily set
APP_DEBUG=truein.envto see detailed error messages (don’t forget to set it back tofalseafter troubleshooting).
- Vue components not rendering? Double-check that you ran
npm run prodlocally and uploaded the compiledapp.jsandapp.cssfiles topublic_html/jsandpublic_html/css. - 500 Server Error? Verify permissions on
storageandbootstrap/cache, confirm your.envdatabase credentials are correct, and make sure theAPP_KEYis set properly. - Autoloader issues? Re-run
composer dump-autoload --optimizelocally and re-upload thevendorfolder.
内容的提问来源于stack exchange,提问作者Vishnu Sharma

