Compare commits
2 Commits
feature/au
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
94eeb3e3d3 | ||
| 8f06d79f42 |
219
DEPLOYMENT.md
Normal file
219
DEPLOYMENT.md
Normal file
@ -0,0 +1,219 @@
|
||||
# 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:**
|
||||
```bash
|
||||
cd thanasoft-front
|
||||
npm run serve
|
||||
```
|
||||
- Frontend runs on: http://localhost:8080
|
||||
- API calls to `/api/*` are proxied to Laravel backend
|
||||
|
||||
2. **Start the Laravel backend (in another terminal):**
|
||||
```bash
|
||||
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/`:
|
||||
|
||||
```bash
|
||||
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:
|
||||
|
||||
```bash
|
||||
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
|
||||
|
||||
```bash
|
||||
cd thanasoft-front
|
||||
npm run build
|
||||
```
|
||||
|
||||
#### Step 2: Upload to Server
|
||||
|
||||
```bash
|
||||
# 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:
|
||||
|
||||
```bash
|
||||
ssh root@78.138.58.60
|
||||
cd /var/www/html/New-Thanasoft/thanasoft-back
|
||||
```
|
||||
|
||||
Set permissions:
|
||||
|
||||
```bash
|
||||
chown -R www-data:www-data storage bootstrap/cache public/build
|
||||
chmod -R 775 storage bootstrap/cache
|
||||
```
|
||||
|
||||
Clear and cache Laravel:
|
||||
|
||||
```bash
|
||||
php artisan route:clear
|
||||
php artisan cache:clear
|
||||
php artisan config:clear
|
||||
php artisan route:cache
|
||||
php artisan config:cache
|
||||
```
|
||||
|
||||
Restart Apache:
|
||||
|
||||
```bash
|
||||
systemctl restart apache2
|
||||
```
|
||||
|
||||
## How It Works
|
||||
|
||||
### Vue.js Configuration (`vue.config.js`)
|
||||
|
||||
```javascript
|
||||
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`)
|
||||
|
||||
```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
|
||||
|
||||
```apache
|
||||
DocumentRoot /var/www/html/New-Thanasoft/thanasoft-back/public
|
||||
```
|
||||
|
||||
- Points to Laravel's `public/` directory
|
||||
- `.htaccess` handles 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
|
||||
|
||||
1. Check if build files exist:
|
||||
```bash
|
||||
ls -la /var/www/html/New-Thanasoft/thanasoft-back/public/build/
|
||||
```
|
||||
|
||||
2. Verify `routes/web.php` points to correct path:
|
||||
```php
|
||||
public_path('build/index.html') // Correct
|
||||
```
|
||||
|
||||
3. Clear route cache:
|
||||
```bash
|
||||
php artisan route:clear
|
||||
php artisan route:cache
|
||||
```
|
||||
|
||||
### API returns 404
|
||||
|
||||
1. Check Apache mod_rewrite is enabled:
|
||||
```bash
|
||||
sudo a2enmod rewrite
|
||||
sudo systemctl restart apache2
|
||||
```
|
||||
|
||||
2. Verify `.htaccess` exists in `public/`
|
||||
|
||||
3. Check Apache virtual host has `AllowOverride All`
|
||||
|
||||
### Permission errors
|
||||
|
||||
```bash
|
||||
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:
|
||||
|
||||
```bash
|
||||
cd "/media/creator/6226b912-8ba7-45dc-88a2-4b10d3dd1655/kandra/Thanasoft v2"
|
||||
./deploy-to-server.sh
|
||||
```
|
||||
|
||||
That's it! 🚀
|
||||
160
QUICK_START.md
Normal file
160
QUICK_START.md
Normal file
@ -0,0 +1,160 @@
|
||||
# Thanasoft Quick Start Guide
|
||||
|
||||
## ✅ Setup Complete!
|
||||
|
||||
Your Thanasoft application is now configured to automatically build the Vue.js frontend into the Laravel backend's `public/build` directory.
|
||||
|
||||
## 📁 Project Structure
|
||||
|
||||
```
|
||||
Thanasoft v2/
|
||||
├── thanasoft-front/ # Vue.js Frontend
|
||||
│ ├── src/
|
||||
│ ├── vue.config.js # ✨ Configured to build to ../thanasoft-back/public/build/
|
||||
│ └── package.json
|
||||
│
|
||||
└── thanasoft-back/ # Laravel Backend
|
||||
├── app/
|
||||
├── routes/
|
||||
│ ├── api.php # API routes (/api/*)
|
||||
│ └── web.php # Frontend fallback route
|
||||
└── public/
|
||||
├── index.php # Laravel entry point
|
||||
├── .htaccess # Routing rules
|
||||
└── build/ # ✨ Vue.js build output (auto-generated)
|
||||
├── index.html
|
||||
├── css/
|
||||
├── js/
|
||||
└── img/
|
||||
```
|
||||
|
||||
## 🚀 Development
|
||||
|
||||
### Local Development
|
||||
|
||||
**Terminal 1 - Start Laravel backend:**
|
||||
```bash
|
||||
cd "thanasoft-back"
|
||||
php artisan serve
|
||||
```
|
||||
Backend: http://localhost:8000
|
||||
|
||||
**Terminal 2 - Start Vue.js frontend:**
|
||||
```bash
|
||||
cd "thanasoft-front"
|
||||
npm run serve
|
||||
```
|
||||
Frontend: http://localhost:8080
|
||||
(API calls are proxied to backend)
|
||||
|
||||
## 📦 Building for Production
|
||||
|
||||
From the frontend directory:
|
||||
|
||||
```bash
|
||||
cd "thanasoft-front"
|
||||
npm run build
|
||||
```
|
||||
|
||||
This will:
|
||||
- Build optimized production files
|
||||
- Output directly to `../thanasoft-back/public/build/`
|
||||
- Ready to deploy!
|
||||
|
||||
## 🌐 Deploy to Server
|
||||
|
||||
### Quick Deploy (Automated)
|
||||
|
||||
```bash
|
||||
cd "/media/creator/6226b912-8ba7-45dc-88a2-4b10d3dd1655/kandra/Thanasoft v2"
|
||||
chmod +x deploy-to-server.sh
|
||||
./deploy-to-server.sh
|
||||
```
|
||||
|
||||
### Manual Deploy
|
||||
|
||||
1. **Build locally:**
|
||||
```bash
|
||||
cd thanasoft-front
|
||||
npm run build
|
||||
```
|
||||
|
||||
2. **Upload to server:**
|
||||
```bash
|
||||
rsync -avz --exclude 'node_modules' --exclude 'vendor' --exclude '.git' \
|
||||
thanasoft-back/ root@78.138.58.60:/var/www/html/New-Thanasoft/thanasoft-back/
|
||||
```
|
||||
|
||||
3. **On server, set permissions and cache:**
|
||||
```bash
|
||||
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
|
||||
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
|
||||
```
|
||||
|
||||
## 🔗 Your Live Application
|
||||
|
||||
- **Website**: http://78.138.58.60/
|
||||
- **API**: http://78.138.58.60/api/
|
||||
|
||||
### API Endpoints
|
||||
|
||||
- `POST /api/auth/register` - Register new user
|
||||
- `POST /api/auth/login` - Login
|
||||
- `GET /api/auth/me` - Get current user (requires token)
|
||||
- `POST /api/auth/logout` - Logout
|
||||
- `POST /api/auth/logout-all` - Logout from all devices
|
||||
|
||||
## ✨ What Changed
|
||||
|
||||
### Created/Modified Files:
|
||||
|
||||
1. **`thanasoft-front/vue.config.js`** ✅ NEW
|
||||
- Configured to build to `../thanasoft-back/public/build/`
|
||||
- Set public path to `/build/`
|
||||
- Added dev server proxy for API calls
|
||||
|
||||
2. **`thanasoft-back/app/Models/User.php`** ✅ UPDATED
|
||||
- Added `HasApiTokens` trait for Laravel Sanctum
|
||||
|
||||
3. **`thanasoft-back/routes/web.php`** ✅ VERIFIED
|
||||
- Serves frontend from `public_path('build/index.html')`
|
||||
|
||||
4. **`thanasoft-back/composer.json`** ✅ UPDATED
|
||||
- Added `laravel/sanctum` dependency
|
||||
|
||||
## 🎯 Workflow Summary
|
||||
|
||||
**Development:**
|
||||
```bash
|
||||
# Terminal 1
|
||||
cd thanasoft-back && php artisan serve
|
||||
|
||||
# Terminal 2
|
||||
cd thanasoft-front && npm run serve
|
||||
```
|
||||
|
||||
**Build:**
|
||||
```bash
|
||||
cd thanasoft-front && npm run build
|
||||
```
|
||||
|
||||
**Deploy:**
|
||||
```bash
|
||||
./deploy-to-server.sh
|
||||
```
|
||||
|
||||
That's it! 🎉
|
||||
92
deploy-to-server.sh
Executable file
92
deploy-to-server.sh
Executable file
@ -0,0 +1,92 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Deployment script for Thanasoft application
|
||||
# This script builds the Vue frontend and deploys to the server
|
||||
|
||||
set -e # Exit on error
|
||||
|
||||
echo "=========================================="
|
||||
echo "Thanasoft Deployment Script"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
|
||||
# Configuration
|
||||
SERVER_USER="root"
|
||||
SERVER_IP="78.138.58.60"
|
||||
SERVER_PATH="/var/www/html/New-Thanasoft"
|
||||
LOCAL_BACKEND_PATH="./thanasoft-back"
|
||||
LOCAL_FRONTEND_PATH="./thanasoft-front"
|
||||
|
||||
# Step 1: Build Vue.js frontend
|
||||
echo "📦 Building Vue.js frontend..."
|
||||
cd "$LOCAL_FRONTEND_PATH"
|
||||
npm run build
|
||||
echo "✓ Frontend built successfully"
|
||||
echo ""
|
||||
|
||||
# Step 2: Check if build was created
|
||||
if [ ! -d "../thanasoft-back/public/build" ]; then
|
||||
echo "❌ Error: Build directory not found!"
|
||||
exit 1
|
||||
fi
|
||||
echo "✓ Build directory found"
|
||||
echo ""
|
||||
|
||||
# Step 3: Deploy to server
|
||||
echo "🚀 Deploying to server..."
|
||||
cd ..
|
||||
|
||||
# Upload backend (routes, controllers, models, etc.)
|
||||
echo "Uploading backend files..."
|
||||
rsync -avz --progress \
|
||||
--exclude 'node_modules' \
|
||||
--exclude 'vendor' \
|
||||
--exclude '.git' \
|
||||
--exclude 'storage/logs/*' \
|
||||
--exclude 'storage/framework/cache/*' \
|
||||
--exclude 'storage/framework/sessions/*' \
|
||||
--exclude 'storage/framework/views/*' \
|
||||
"$LOCAL_BACKEND_PATH/" \
|
||||
"$SERVER_USER@$SERVER_IP:$SERVER_PATH/thanasoft-back/"
|
||||
|
||||
echo "✓ Backend files uploaded"
|
||||
echo ""
|
||||
|
||||
# Step 4: Run server commands
|
||||
echo "🔧 Running server commands..."
|
||||
ssh "$SERVER_USER@$SERVER_IP" << 'ENDSSH'
|
||||
cd /var/www/html/New-Thanasoft/thanasoft-back
|
||||
|
||||
# Set permissions
|
||||
echo "Setting permissions..."
|
||||
chown -R www-data:www-data storage bootstrap/cache public/build
|
||||
chmod -R 775 storage bootstrap/cache
|
||||
|
||||
# Clear and cache Laravel
|
||||
echo "Clearing Laravel caches..."
|
||||
php artisan route:clear
|
||||
php artisan cache:clear
|
||||
php artisan config:clear
|
||||
php artisan view:clear
|
||||
|
||||
echo "Caching for production..."
|
||||
php artisan route:cache
|
||||
php artisan config:cache
|
||||
php artisan view:cache
|
||||
|
||||
# Restart Apache
|
||||
echo "Restarting Apache..."
|
||||
systemctl restart apache2
|
||||
|
||||
echo "✓ Server setup complete"
|
||||
ENDSSH
|
||||
|
||||
echo ""
|
||||
echo "=========================================="
|
||||
echo "✅ Deployment Complete!"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
echo "Your application is now live at:"
|
||||
echo "🌐 http://78.138.58.60/"
|
||||
echo "🔌 API: http://78.138.58.60/api/"
|
||||
echo ""
|
||||
28
thanasoft-back/fix-routes.sh
Normal file
28
thanasoft-back/fix-routes.sh
Normal file
@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "Fixing routes/web.php on server..."
|
||||
|
||||
# Update the web.php file
|
||||
cat > /var/www/html/New-Thanasoft/thanasoft-back/routes/web.php << 'EOF'
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::get('/{any}', function () {
|
||||
return file_get_contents(public_path('index.html'));
|
||||
})->where('any', '.*');
|
||||
EOF
|
||||
|
||||
echo "✓ Updated routes/web.php"
|
||||
|
||||
# Clear and cache routes
|
||||
cd /var/www/html/New-Thanasoft/thanasoft-back
|
||||
php artisan route:clear
|
||||
php artisan route:cache
|
||||
php artisan config:clear
|
||||
|
||||
echo ""
|
||||
echo "✓ Done! Routes updated and cached."
|
||||
echo ""
|
||||
echo "Testing website..."
|
||||
curl -I http://78.138.58.60/
|
||||
7
thanasoft-back/routes/web.php.server
Normal file
7
thanasoft-back/routes/web.php.server
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::get('/{any}', function () {
|
||||
return file_get_contents(public_path('index.html'));
|
||||
})->where('any', '.*');
|
||||
78
thanasoft-back/server-setup.sh
Normal file
78
thanasoft-back/server-setup.sh
Normal file
@ -0,0 +1,78 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Laravel Server Setup Script
|
||||
echo "==================================="
|
||||
echo "Laravel Server Setup"
|
||||
echo "==================================="
|
||||
|
||||
# Navigate to project directory
|
||||
cd /var/www/html/New-Thanasoft/thanasoft-back
|
||||
|
||||
# Enable Apache mod_rewrite
|
||||
echo "Enabling mod_rewrite..."
|
||||
sudo a2enmod rewrite
|
||||
|
||||
# Set proper permissions
|
||||
echo "Setting permissions..."
|
||||
sudo chown -R www-data:www-data /var/www/html/New-Thanasoft/thanasoft-back
|
||||
sudo chmod -R 775 storage bootstrap/cache
|
||||
|
||||
# Clear all caches
|
||||
echo "Clearing caches..."
|
||||
php artisan route:clear
|
||||
php artisan cache:clear
|
||||
php artisan config:clear
|
||||
php artisan view:clear
|
||||
|
||||
# Cache routes for production
|
||||
echo "Caching routes..."
|
||||
php artisan route:cache
|
||||
php artisan config:cache
|
||||
|
||||
# Check .htaccess exists
|
||||
echo "Checking .htaccess..."
|
||||
if [ -f public/.htaccess ]; then
|
||||
echo "✓ .htaccess exists"
|
||||
else
|
||||
echo "✗ .htaccess NOT found - copying from framework..."
|
||||
cat > public/.htaccess << 'EOF'
|
||||
<IfModule mod_rewrite.c>
|
||||
<IfModule mod_negotiation.c>
|
||||
Options -MultiViews -Indexes
|
||||
</IfModule>
|
||||
|
||||
RewriteEngine On
|
||||
|
||||
# Handle Authorization Header
|
||||
RewriteCond %{HTTP:Authorization} .
|
||||
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
|
||||
|
||||
# Redirect Trailing Slashes If Not A Folder...
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteCond %{REQUEST_URI} (.+)/$
|
||||
RewriteRule ^ %1 [L,R=301]
|
||||
|
||||
# Send Requests To Front Controller...
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteRule ^ index.php [L]
|
||||
</IfModule>
|
||||
EOF
|
||||
echo "✓ .htaccess created"
|
||||
fi
|
||||
|
||||
# Restart Apache
|
||||
echo "Restarting Apache..."
|
||||
sudo systemctl restart apache2
|
||||
|
||||
echo ""
|
||||
echo "==================================="
|
||||
echo "Setup Complete!"
|
||||
echo "==================================="
|
||||
echo ""
|
||||
echo "Testing API endpoint..."
|
||||
curl -I http://78.138.58.60/api/auth/login
|
||||
|
||||
echo ""
|
||||
echo "Check Apache error logs with:"
|
||||
echo "sudo tail -f /var/log/apache2/thanasoft_error.log"
|
||||
@ -7,6 +7,8 @@
|
||||
"scripts": {
|
||||
"serve": "vue-cli-service serve",
|
||||
"build": "vue-cli-service build",
|
||||
"build:prod": "vue-cli-service build && npm run deploy",
|
||||
"deploy": "echo 'Built to ../thanasoft-back/public/build'",
|
||||
"lint": "vue-cli-service lint"
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
27
thanasoft-front/vue.config.js
Normal file
27
thanasoft-front/vue.config.js
Normal file
@ -0,0 +1,27 @@
|
||||
const path = require("path");
|
||||
|
||||
module.exports = {
|
||||
// Output directory - build directly into Laravel's public/build folder
|
||||
outputDir: path.resolve(__dirname, "../thanasoft-back/public/build"),
|
||||
|
||||
// Public path for assets
|
||||
publicPath: process.env.NODE_ENV === "production" ? "/build/" : "/",
|
||||
|
||||
// Index path
|
||||
indexPath: "index.html",
|
||||
|
||||
// Clean output directory before build
|
||||
productionSourceMap: false,
|
||||
|
||||
// Dev server configuration
|
||||
devServer: {
|
||||
port: 8080,
|
||||
proxy: {
|
||||
"/api": {
|
||||
target: "http://localhost:8000", // Laravel backend
|
||||
changeOrigin: true,
|
||||
secure: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
Loading…
x
Reference in New Issue
Block a user