New-Thanasoft/DEPLOYMENT.md
2025-10-06 19:37:32 +03:00

4.5 KiB

Thanasoft Deployment Guide

This guide explains how to build and deploy your Thanasoft application.

Project Structure

/var/www/html/New-Thanasoft/
├── README.md
├── thanasoft-back/          # Laravel Backend
│   ├── app/
│   ├── routes/
│   ├── public/
│   │   ├── index.php        # Laravel entry point
│   │   └── build/           # Vue.js build output (auto-generated)
│   └── ...
└── thanasoft-front/         # Vue.js Frontend
    ├── src/
    ├── public/
    ├── vue.config.js        # Build configuration
    └── package.json

Development Workflow

Frontend Development

  1. Start the Vue dev server:

    cd thanasoft-front
    npm run serve
    
  2. Start the Laravel backend (in another terminal):

    cd thanasoft-back
    php artisan serve
    

Building for Production

The Vue.js frontend is configured to build directly into thanasoft-back/public/build/:

cd thanasoft-front
npm run build

This will:

  • Build optimized production files
  • Output to ../thanasoft-back/public/build/
  • Create index.html, css/, js/, img/, etc.

Deployment to Server

Use the deployment script:

cd "/media/creator/6226b912-8ba7-45dc-88a2-4b10d3dd1655/kandra/Thanasoft v2"
chmod +x deploy-to-server.sh
./deploy-to-server.sh

This script will:

  1. Build the Vue.js frontend
  2. Upload all files to the server
  3. Set correct permissions
  4. Clear and cache Laravel routes/config
  5. Restart Apache

Option 2: Manual Deployment

Step 1: Build Frontend Locally

cd thanasoft-front
npm run build

Step 2: Upload to Server

# Upload backend and frontend build
rsync -avz --progress \
  --exclude 'node_modules' \
  --exclude 'vendor' \
  --exclude '.git' \
  thanasoft-back/ root@78.138.58.60:/var/www/html/New-Thanasoft/thanasoft-back/

Step 3: Server Configuration

SSH into your server:

ssh root@78.138.58.60
cd /var/www/html/New-Thanasoft/thanasoft-back

Set permissions:

chown -R www-data:www-data storage bootstrap/cache public/build
chmod -R 775 storage bootstrap/cache

Clear and cache Laravel:

php artisan route:clear
php artisan cache:clear
php artisan config:clear
php artisan route:cache
php artisan config:cache

Restart Apache:

systemctl restart apache2

How It Works

Vue.js Configuration (vue.config.js)

outputDir: path.resolve(__dirname, '../thanasoft-back/public/build')
publicPath: '/build/'
  • Builds output to Laravel's public/build/ directory
  • Assets are served from /build/ path

Laravel Configuration (routes/web.php)

Route::get('/{any}', function () {
    return file_get_contents(public_path('build/index.html'));
})->where('any', '.*');
  • Catch-all route serves Vue.js SPA
  • API routes (/api/*) bypass this and go to Laravel controllers

Apache Configuration

DocumentRoot /var/www/html/New-Thanasoft/thanasoft-back/public
  • Points to Laravel's public/ directory
  • .htaccess handles routing

URLs

Troubleshooting

Frontend shows 404

  1. Check if build files exist:

    ls -la /var/www/html/New-Thanasoft/thanasoft-back/public/build/
    
  2. Verify routes/web.php points to correct path:

    public_path('build/index.html')  // Correct
    
  3. Clear route cache:

    php artisan route:clear
    php artisan route:cache
    

API returns 404

  1. Check Apache mod_rewrite is enabled:

    sudo a2enmod rewrite
    sudo systemctl restart apache2
    
  2. Verify .htaccess exists in public/

  3. Check Apache virtual host has AllowOverride All

Permission errors

cd /var/www/html/New-Thanasoft/thanasoft-back
sudo chown -R www-data:www-data storage bootstrap/cache public/build
sudo chmod -R 775 storage bootstrap/cache

Quick Deploy

After making changes, just run:

cd "/media/creator/6226b912-8ba7-45dc-88a2-4b10d3dd1655/kandra/Thanasoft v2"
./deploy-to-server.sh

That's it! 🚀