4.5 KiB
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
-
Start the Vue dev server:
cd thanasoft-front npm run serve- Frontend runs on: http://localhost:8080
- API calls to
/api/*are proxied to Laravel backend
-
Start the Laravel backend (in another terminal):
cd thanasoft-back php artisan serve- Backend runs on: http://localhost:8000
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
Option 1: Automated Deployment (Recommended)
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:
- Build the Vue.js frontend
- Upload all files to the server
- Set correct permissions
- Clear and cache Laravel routes/config
- 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 .htaccesshandles routing
URLs
- Production: http://78.138.58.60/
- API: http://78.138.58.60/api/
- API Endpoints:
- POST /api/auth/register
- POST /api/auth/login
- GET /api/auth/me (requires auth)
- POST /api/auth/logout (requires auth)
Troubleshooting
Frontend shows 404
-
Check if build files exist:
ls -la /var/www/html/New-Thanasoft/thanasoft-back/public/build/ -
Verify
routes/web.phppoints to correct path:public_path('build/index.html') // Correct -
Clear route cache:
php artisan route:clear php artisan route:cache
API returns 404
-
Check Apache mod_rewrite is enabled:
sudo a2enmod rewrite sudo systemctl restart apache2 -
Verify
.htaccessexists inpublic/ -
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! 🚀