You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

无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:

1. Prep Your Project Locally First

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
    Run npm run prod in your local project directory. This will compile all your Vue components, CSS, and JS into minified files in the public/js and public/css folders. 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.example to .env and fill in your shared host’s database credentials (host, name, username, password). Run php artisan key:generate to create an APP_KEY, and keep this value handy (you’ll need it in the uploaded .env file).
    • Set APP_DEBUG=false and APP_URL to your actual domain in .env—debug mode should never be on in production.
    • Run php artisan config:cache and php artisan route:cache locally. 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-autoloader to get a lean vendor folder without development tools.
2. Upload Files to Your Shared Host

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 usually public_html. Upload everything from your local public folder directly into public_html (this is where your app’s entry point index.php lives).

  • Upload Remaining Project Files
    Create a new folder outside public_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 the index.php file in public_html and update the paths to point to your new laravel-app folder. 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.

3. Set Critical File Permissions

Using your host’s file manager, update these permissions:

  • Set the storage folder and bootstrap/cache folder to 755 (if that doesn’t work, try 777 temporarily—just remember to switch back to 755 if possible for security).
  • Set your .env file to 644—this prevents unauthorized access to your database credentials and other sensitive settings.
4. Set Up the Database
  • 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 .env file.
  • Export your local database (use phpMyAdmin or mysqldump locally) and import the SQL file into your shared host’s database via phpMyAdmin.
5. Test Your App

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=true in .env to see detailed error messages (don’t forget to set it back to false after troubleshooting).
Quick Troubleshooting Tips
  • Vue components not rendering? Double-check that you ran npm run prod locally and uploaded the compiled app.js and app.css files to public_html/js and public_html/css.
  • 500 Server Error? Verify permissions on storage and bootstrap/cache, confirm your .env database credentials are correct, and make sure the APP_KEY is set properly.
  • Autoloader issues? Re-run composer dump-autoload --optimize locally and re-upload the vendor folder.

内容的提问来源于stack exchange,提问作者Vishnu Sharma

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 09:33:02