# Deploy Guide — Daneshyar

## Requirement

```
pip install paramiko
```

---

## First-time deploy (3 commands)

### 1. Build assets locally

```bash
python scripts/build.py
```

Runs `composer install --no-dev`, `npm run build`, `artisan config/route/view cache`.
Output lands in `public/build/`.

---

### 2. Deploy to server

```bash
python scripts/deploy.py
```

Asks for SSH password (never stored). Then:

1. Shows server status
2. Installs PHP 8.3, Apache2, MySQL, Composer, Node.js 20
3. Configures Apache (VirtualHost, security headers, compression)
4. Optionally creates MySQL database + user
5. Pauses so you can create `.env` on the server (see below)
6. Uploads project zip via SFTP
7. Runs `composer install`, `artisan migrate`, `artisan key:generate`, caches, reloads Apache

---

### 3. Create `.env` on the server

During deploy you will be asked to create `.env`. SSH in separately:

```bash
ssh root@91.107.131.171
cp /var/www/html/.env.example /var/www/html/.env
nano /var/www/html/.env
```

Minimum values to fill in:

```
APP_ENV=production
APP_DEBUG=false
APP_URL=http://91.107.131.171

DB_DATABASE=daneshyar
DB_USERNAME=daneshyar
DB_PASSWORD=your_db_password
```

Press Enter in the deploy script when done.

---

## Re-deploy (after code changes)

```bash
python scripts/build.py
python scripts/deploy.py
```

Same two commands. Deploy skips already-installed packages.

---

## Config

Edit the top of `scripts/deploy.py` to change server details:

```python
SERVER_HOST = "91.107.131.171"
SERVER_PORT = 22
SSH_USER    = "root"
APP_DIR     = "/var/www/html"
PHP_VERSION = "8.3"
```

---

## Apache config only (if needed separately)

```bash
python scripts/configure_apache.py
```

Run **on the server** as root. Writes VirtualHost config, enables modules, reloads Apache.
