Expand deployment documentation to include database and file backup commands, web server configurations for Nginx and Apache, Supervisor setup for queue workers, and SSL/TLS installation via Certbot. Also update the project status badge in README.md to reflect progress completion.
340 lines
7.5 KiB
Markdown
340 lines
7.5 KiB
Markdown
# راهنمای استقرار IFNEX
|
||
|
||
> **آخرین بروزرسانی:** 2026-08-29
|
||
|
||
---
|
||
|
||
## محیطها
|
||
|
||
| محیط | دامنه | نقش |
|
||
|-------|-------|------|
|
||
| Production | api.ifnex.vernahost.ir | API لاراول |
|
||
| Production | ifnex.vernahost.ir | وبسایت وردپرس |
|
||
| Local | localhost:8000 | توسعه |
|
||
|
||
---
|
||
|
||
## پیشنیازها
|
||
|
||
- SSH دسترسی به سرور
|
||
- HestiaCP (مدیریت سرور)
|
||
- Git روی سرور
|
||
- Composer روی سرور (اختیاری — بهتره locallly نصب کنی)
|
||
|
||
---
|
||
|
||
## ۱. استقرار لاراول
|
||
|
||
### بکاپ دیتابیس
|
||
\```bash
|
||
# بکاپ کامل دیتابیس
|
||
mysqldump -u root -p ifnex_db > /backups/ifnex_$(date +%Y%m%d_%H%M%S).sql
|
||
|
||
# یا فشرده
|
||
mysqldump -u root -p ifnex_db | gzip > /backups/ifnex_$(date +%Y%m%d_%H%M%S).sql.gz
|
||
\```
|
||
|
||
### بکاپ فایلها
|
||
\```bash
|
||
# بکاپ فایلهای لاراول
|
||
tar -czf /backups/laravel_$(date +%Y%m%d_%H%M%S).tar.gz /home/USER/web/api.ifnex.vernahost.ir/public_html
|
||
|
||
# بکاپ فایلهای وردپرس
|
||
tar -czf /backups/wordpress_$(date +%Y%m%d_%H%M%S).tar.gz /home/USER/web/ifnex.vernahost.ir/public_html
|
||
\```
|
||
|
||
|
||
### ۱.۱ کلون مخزن روی سرور
|
||
|
||
```bash
|
||
cd /home/USER/web/api.ifnex.vernahost.ir/public_html
|
||
git clone https://www.git.vernahost.ir/gitmodir110/ifnex.git .
|
||
```
|
||
|
||
> اگر پوشه لاراول زیرمسیر `04_Laravel/` هست:
|
||
|
||
```bash
|
||
cd /home/USER/web/api.ifnex.vernahost.ir/public_html
|
||
git clone https://www.git.vernahost.ir/gitmodir110/ifnex.git tmp-ifnex
|
||
cp -r tmp-ifnex/04_Laravel/* .
|
||
# فقط فایلهای مخفی خاص را کپی کنید
|
||
cp -r tmp-ifnex/04_Laravel/.env.example .
|
||
cp -r tmp-ifnex/04_Laravel/.gitignore .
|
||
# یا بهتر است فایلها را دستی کپی کنید ...
|
||
|
||
### ۱.۲ نصب وابستگیها
|
||
|
||
```bash
|
||
cd /home/USER/web/api.ifnex.vernahost.ir/public_html
|
||
composer install --no-dev --optimize-autoloader
|
||
```
|
||
|
||
### ۱.۳ تنظیم .env
|
||
|
||
```bash
|
||
cp .env.example .env
|
||
nano .env
|
||
```
|
||
|
||
مقادیر مهم:
|
||
|
||
```env
|
||
APP_ENV=production
|
||
APP_DEBUG=false
|
||
APP_URL=https://api.ifnex.vernahost.ir
|
||
|
||
DB_HOST=localhost
|
||
DB_DATABASE=ifnex_db
|
||
DB_USERNAME=ifnex_user
|
||
DB_PASSWORD=STRONG_PASSWORD
|
||
|
||
CORS_ALLOWED_ORIGINS=https://ifnex.vernahost.ir
|
||
|
||
ZARINPAL_SANDBOX=false
|
||
ZARINPAL_MERCHANT_ID=YOUR_MERCHANT_ID
|
||
```
|
||
|
||
### ۱.۴ دیتابیس
|
||
|
||
```bash
|
||
# ایجاد دیتابیس (اگر وجود نداره)
|
||
mysql -u root -p -e "CREATE DATABASE ifnex_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
|
||
|
||
# اجرای migrations
|
||
php artisan migrate --force
|
||
|
||
# اجرای seeders (فقط بار اول)
|
||
php artisan db:seed --force
|
||
```
|
||
|
||
### ۱.۵ پیکربندی نهایی
|
||
|
||
```bash
|
||
php artisan config:cache
|
||
php artisan route:cache
|
||
php artisan view:cache
|
||
php artisan filament:clear-cached-components
|
||
```
|
||
|
||
---
|
||
|
||
## ۲. استقرار وردپرس (پلاگین و قالب)
|
||
|
||
### ۲.۱ آپلود فایلها
|
||
|
||
```bash
|
||
# قالب IFNEX
|
||
cd /home/USER/web/ifnex.vernahost.ir/public_html/wp-content/themes/
|
||
# فایلهای قالب را اینجا آپلود/بروزرسانی کن
|
||
|
||
# پلاگین IFNEX Bridge
|
||
cd /home/USER/web/ifnex.vernahost.ir/public_html/wp-content/plugins/
|
||
# فایلهای پلاگین را اینجا آپلود/بروزرسانی کن
|
||
```
|
||
|
||
### ۲.۲ تنظیم پلاگین
|
||
|
||
در پیشخوان وردپرس → تنظیمات → IFNEX Bridge:
|
||
|
||
| تنظیم | مقدار |
|
||
|--------|-------|
|
||
| API URL | `https://api.ifnex.vernahost.ir/api/v1` |
|
||
| Bridge API Key | کلید مشترک بین وردپرس و لاراول |
|
||
|
||
---
|
||
|
||
## ۳. بروزرسانی (بعد از تغییرات جدید)
|
||
|
||
### ۳.۱ لاراول
|
||
|
||
```bash
|
||
cd /home/USER/web/api.ifnex.vernahost.ir/public_html
|
||
|
||
# خاموش کردن موقت سایت
|
||
php artisan down
|
||
|
||
# بکاپ
|
||
cp .env .env.backup
|
||
|
||
# دریافت تغییرات
|
||
git fetch --all
|
||
git pull origin main
|
||
|
||
# وابستگیها (اگه composer.json تغییر کرده)
|
||
composer install --no-dev --optimize-autoloader
|
||
|
||
# مایگریشنهای جدید
|
||
php artisan migrate --force
|
||
|
||
# پاکسازی کش
|
||
php artisan config:clear
|
||
php artisan cache:clear
|
||
php artisan route:clear
|
||
php artisan view:clear
|
||
php artisan filament:clear-cached-components
|
||
|
||
# کش مجدد
|
||
php artisan config:cache
|
||
php artisan route:cache
|
||
php artisan view:cache
|
||
|
||
# روشن کردن سایت
|
||
php artisan up
|
||
```
|
||
|
||
### ۳.۲ وردپرس
|
||
|
||
```bash
|
||
cd /home/USER/web/ifnex.vernahost.ir/public_html/wp-content/plugins/ifnex-bridge
|
||
git pull origin main
|
||
```
|
||
|
||
> اگر پلاگین از طریق گیت کلون نشده، فایلها را دستی آپلود کن.
|
||
|
||
---
|
||
|
||
## ۴. تنظیمات Cron
|
||
|
||
```bash
|
||
crontab -e
|
||
```
|
||
|
||
```cron
|
||
# بهروزرسانی نرخ ارز (اگر ExchangeRateService فعال شد)
|
||
0 0 * * * cd /home/USER/web/api.ifnex.vernahost.ir/public_html && php artisan ifnex:update-exchange-rates >> /dev/null 2>&1
|
||
```
|
||
|
||
---
|
||
|
||
## ۵. عیبیابی
|
||
|
||
### بررسی لاگها
|
||
|
||
```bash
|
||
# لاگ لاراول
|
||
tail -f /home/USER/web/api.ifnex.vernahost.ir/public_html/storage/logs/laravel.log
|
||
|
||
# لاگ HestiaCP
|
||
tail -f /var/log/hestia.log
|
||
```
|
||
|
||
### کلیر کش
|
||
|
||
```bash
|
||
php artisan optimize:clear
|
||
```
|
||
|
||
### بررسی وضعیت
|
||
|
||
```bash
|
||
php artisan about
|
||
php artisan route:list --path=api/v1
|
||
```
|
||
|
||
---
|
||
|
||
## ۶. نکات امنیتی
|
||
|
||
- `.env` هرگز در گیت کامیت نشود (در `.gitignore` باشد)
|
||
- `APP_DEBUG=false` در Production
|
||
- `CORS_ALLOWED_ORIGINS` فقط دامنه وردپرس
|
||
- `IFNEX_API_KEY` یک کلید قوی و تصادفی باشد
|
||
- SSL/HTTPS فعال باشد
|
||
- رمز عبور دیتابیس قوی باشد
|
||
|
||
---
|
||
|
||
© 2026 VernaSoft Group. Internal use only.
|
||
|
||
|
||
## ۷. تنظیمات Web Server
|
||
|
||
### Nginx (لاراول)
|
||
\```nginx
|
||
server {
|
||
listen 80;
|
||
server_name api.ifnex.vernahost.ir;
|
||
root /home/USER/web/api.ifnex.vernahost.ir/public_html/public;
|
||
|
||
index index.php;
|
||
|
||
location / {
|
||
try_files $uri $uri/ /index.php?$query_string;
|
||
}
|
||
|
||
location ~ \.php$ {
|
||
fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
|
||
fastcgi_index index.php;
|
||
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
|
||
include fastcgi_params;
|
||
}
|
||
|
||
location ~ /\.(?!well-known).* {
|
||
deny all;
|
||
}
|
||
}
|
||
\```
|
||
|
||
### Apache (لاراول)
|
||
\```apache
|
||
<VirtualHost *:80>
|
||
ServerName api.ifnex.vernahost.ir
|
||
DocumentRoot /home/USER/web/api.ifnex.vernahost.ir/public_html/public
|
||
|
||
<Directory /home/USER/web/api.ifnex.vernahost.ir/public_html/public>
|
||
AllowOverride All
|
||
Require all granted
|
||
</Directory>
|
||
|
||
ErrorLog ${APACHE_LOG_DIR}/api.ifnex.error.log
|
||
CustomLog ${APACHE_LOG_DIR}/api.ifnex.access.log combined
|
||
</VirtualHost>
|
||
\```
|
||
|
||
|
||
|
||
## ۸. Queue Worker (اگر استفاده میشود)
|
||
|
||
### Supervisor Setup
|
||
\```bash
|
||
sudo nano /etc/supervisor/conf.d/ifnex-worker.conf
|
||
\```
|
||
|
||
\```ini
|
||
[program:ifnex-worker]
|
||
process_name=%(program_name)s_%(process_num)02d
|
||
command=php /home/USER/web/api.ifnex.vernahost.ir/public_html/artisan queue:work --sleep=3 --tries=3 --max-time=3600
|
||
autostart=true
|
||
autorestart=true
|
||
stopasgroup=true
|
||
killasgroup=true
|
||
user=USER
|
||
numprocs=2
|
||
redirect_stderr=true
|
||
stdout_logfile=/home/USER/web/api.ifnex.vernahost.ir/public_html/storage/logs/worker.log
|
||
\```
|
||
|
||
\```bash
|
||
sudo supervisorctl reread
|
||
sudo supervisorctl update
|
||
sudo supervisorctl start all
|
||
\```
|
||
|
||
|
||
## ۹. SSL/TLS (HTTPS)
|
||
|
||
### Let's Encrypt (رایگان)
|
||
\```bash
|
||
# نصب Certbot
|
||
sudo apt install certbot python3-certbot-nginx
|
||
|
||
# دریافت SSL certificate
|
||
sudo certbot --nginx -d api.ifnex.vernahost.ir -d ifnex.vernahost.ir
|
||
|
||
# تمدید خودکار (تست)
|
||
sudo certbot renew --dry-run
|
||
\```
|
||
|
||
|
||
|