Files
softclick-landing/scripts/docs/deploy-traditional-hosting.md
2026-04-02 23:35:06 +03:00

2.9 KiB
Raw Blame History

Деплой на традиционный хостинг

Для любого хостинга с FTP/SSH доступом

Шаг 1: Локальная сборка

npm install
npm run build

Шаг 2: Загрузка файлов

После сборки появится папка dist/ - её содержимое нужно загрузить на хостинг.

Через FTP:

  1. Подключитесь к хостингу через FileZilla/WinSCP
  2. Перейдите в папку public_html или www
  3. Загрузите ВСЁ содержимое папки dist/ (не саму папку!)

Через SSH:

# Соберите локально
npm run build

# Загрузите через rsync
rsync -avz --delete dist/ user@your-server.ru:/var/www/html/

Шаг 3: Настройка .htaccess (для Apache)

Создайте в корне сайта файл .htaccess:

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  RewriteRule ^index\.html$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.html [L]
</IfModule>

# Кеширование статических файлов
<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresByType image/jpg "access plus 1 year"
  ExpiresByType image/jpeg "access plus 1 year"
  ExpiresByType image/gif "access plus 1 year"
  ExpiresByType image/png "access plus 1 year"
  ExpiresByType image/svg+xml "access plus 1 year"
  ExpiresByType text/css "access plus 1 month"
  ExpiresByType application/javascript "access plus 1 month"
  ExpiresByType text/html "access plus 0 seconds"
</IfModule>

# Сжатие
<IfModule mod_deflate.c>
  AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/javascript
</IfModule>

Шаг 4: Настройка для Nginx

Если на сервере Nginx, добавьте в конфигурацию сайта:

server {
    listen 80;
    server_name your-domain.ru www.your-domain.ru;
    root /var/www/html;
    index index.html;

    # Сжатие
    gzip on;
    gzip_types text/plain text/css application/json application/javascript text/xml application/xml;

    # SPA роутинг
    location / {
        try_files $uri $uri/ /index.html;
    }

    # Кеширование статики
    location ~* \.(jpg|jpeg|png|gif|ico|css|js|svg|woff|woff2)$ {
        expires 1y;
        add_header Cache-Control "public, immutable";
    }
}

Рекомендуемые российские хостинги:

  1. Timeweb - от 169 ₽/мес, отличная поддержка
  2. Beget - от 200 ₽/мес, очень стабильный
  3. Reg.ru - от 120 ₽/мес, простой интерфейс
  4. HostiMan - от 150 ₽/мес
  5. SpaceWeb - от 150 ₽/мес

Все эти хостинги поддерживают Node.js и SSH доступ.