# umai.fit — VPS Deployment Guide (Apache)

---

## Before You Upload (on your Mac)

### 1. Fill in wp-config.php

Open `wp-config.php` and set your database credentials:

```php
define( 'DB_NAME',     'umaifit_db' );
define( 'DB_USER',     'umaifit_user' );
define( 'DB_PASSWORD', 'YourStrongPassword' );
```

Then replace the 8 salt/key lines. Visit this URL in your browser, copy everything it returns, and paste it replacing those 8 lines:

```
https://api.wordpress.org/secret-key/1.1/salt/
```

### 2. Edit fix_database.sql

Open `fix_database.sql` and update the domain on line 7:

```sql
-- Change this:
SET option_value = 'https://yourdomain.com'

-- To your actual domain:
SET option_value = 'https://umai.fit'
```

---

## Upload to VPS (on your Mac)

Run this from your Mac terminal:

```bash
rsync -avz --progress /Users/hashircp/Downloads/Umaifit/linux_vps_umaifit/ jabir@vps:/home/jabir/umai.fit/
```

This uploads all files including the hidden `.htaccess`. Takes a few minutes depending on your connection.

---

## On the VPS

SSH into your server:

```bash
ssh jabir@vps
```

### 3. Create the MySQL database

```bash
mysql -u root -p
```

Run these SQL commands:

```sql
CREATE DATABASE umaifit_db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'umaifit_user'@'localhost' IDENTIFIED BY 'YourStrongPassword@!!';
GRANT ALL PRIVILEGES ON umaifit_db.* TO 'umaifit_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;
```

### 4. Import the database

```bash
cd /home/jabir/umai.fit

gunzip -c umaifit_web.sql.gz | mysql -u umaifit_user -p umaifit_db


YourStrongPassword@!1
```

### 5. Run the database fix script

```bash
mysql -u umaifit_user -p umaifit_db < fix_database.sql
```

This removes the 27 spam posts, fixes the active plugin list, and clears stale cache entries.

### 6. Set file permissions

```bash
find /home/jabir/umai.fit -type f -exec chmod 644 {} \;
find /home/jabir/umai.fit -type d -exec chmod 755 {} \;
chmod 600 /home/jabir/umai.fit/wp-config.php
chown -R www-data:www-data /home/jabir/umai.fit
```

### 7. Configure Apache virtual host

Create a new vhost config file:

```bash
nano /etc/apache2/sites-available/umaifit.conf
```

Paste this (replace `umai.fit` with your domain if different):

```apache
<VirtualHost *:80>
    ServerName umai.fit
    ServerAlias www.umai.fit
    DocumentRoot /home/jabir/umai.fit

    <Directory /home/jabir/umai.fit>
        AllowOverride All
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/umaifit_error.log
    CustomLog ${APACHE_LOG_DIR}/umaifit_access.log combined
</VirtualHost>
```

Enable the site and required modules:

```bash
a2ensite umaifit.conf
a2enmod rewrite
systemctl restart apache2
```

### 8. Point your domain to the VPS

In your domain registrar or DNS panel, set an A record:

```
umai.fit      →  your-vps-ip
www.umai.fit  →  your-vps-ip
```

DNS changes can take up to 24 hours to propagate, but usually work within minutes.

### 9. Add SSL (HTTPS) — recommended

```bash
apt install certbot python3-certbot-apache -y
certbot --apache -d umai.fit -d www.umai.fit
```

Certbot will automatically update the Apache config and set up auto-renewal.

---

## Final Checks in WordPress Admin

Visit `https://umai.fit/wp-admin` and log in with your existing credentials.

1. **Settings → Permalinks** → click **Save Changes**
   Regenerates the URL rewrite rules.

2. **Elementor → Tools → Regenerate CSS & Data**
   Rebuilds all page styles with the correct new paths.

3. **Delete the database file from the server** (security):
   ```bash
   rm /home/jabir/umai.fit/umaifit_web.sql.gz
   rm /home/jabir/umai.fit/fix_database.sql
   ```

4. **Check the site** — visit the homepage, a program page, the blog, and the contact form to confirm everything loads correctly.

---

## Troubleshooting

**White screen / 500 error**
Check Apache error log: `tail -f /var/log/apache2/umaifit_error.log`

**Images not loading**
Confirm uploads folder permissions: `chmod -R 755 /home/jabir/umai.fit/wp-content/uploads`

**"Error establishing database connection"**
Double-check `wp-config.php` credentials match what you set in Step 3.

**Pages return 404 (except homepage)**
`mod_rewrite` is not active or `AllowOverride All` is missing. Re-run `a2enmod rewrite && systemctl restart apache2`.

**Elementor pages look broken**
Go to Elementor → Tools → Regenerate CSS & Data and run it again.
