# Stellar Dominion - Web Hosting Deployment Guide

## Shared Hosting (cPanel, Plesk, etc.)

### 1. Upload Files
Upload the entire `scifi-mmo` folder to your hosting account via FTP or file manager.

### 2. Set Document Root
Point your domain to the `public` folder:
- In cPanel: **Domains** → **Subdomains/Addon Domains** → Set document root to `scifi-mmo/public`
- Or ask your host to set the document root

### 3. Create MySQL Database
- In cPanel: **MySQL Databases** → Create database and user
- Note your database name, username, and password

### 4. Run Installer
Visit `https://yourdomain.com/install.html` and complete the setup wizard.

---

## VPS/Dedicated Server (Apache)

```bash
# Clone/upload files
cd /var/www
git clone [your-repo] stellar-dominion
# or upload via SFTP

# Set permissions
chown -R www-data:www-data stellar-dominion
chmod -R 755 stellar-dominion
chmod -R 777 stellar-dominion/config  # For installer to write config

# Apache virtual host
sudo nano /etc/apache2/sites-available/stellar-dominion.conf
```

```apache
<VirtualHost *:80>
    ServerName yourdomain.com
    DocumentRoot /var/www/stellar-dominion/public
    
    <Directory /var/www/stellar-dominion/public>
        AllowOverride All
        Require all granted
    </Directory>
    
    ErrorLog ${APACHE_LOG_DIR}/stellar-dominion-error.log
    CustomLog ${APACHE_LOG_DIR}/stellar-dominion-access.log combined
</VirtualHost>
```

```bash
# Enable site
sudo a2ensite stellar-dominion.conf
sudo a2enmod rewrite
sudo systemctl restart apache2
```

---

## VPS/Dedicated Server (Nginx)

```nginx
server {
    listen 80;
    server_name yourdomain.com;
    root /var/www/stellar-dominion/public;
    index index.php index.html;
    
    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }
    
    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
    
    location ~ /\. {
        deny all;
    }
}
```

---

## Game Tick (Cron Job)

For the game to progress, set up a cron job:

### Shared Hosting (cPanel)
Go to **Cron Jobs** and add:
```
*/5 * * * * php /home/yourusername/scifi-mmo/cron/tick.php
```

### VPS/Server
```bash
crontab -e
# Add:
*/5 * * * * php /var/www/stellar-dominion/cron/tick.php >> /var/log/stellar-tick.log 2>&1
```

This runs the game tick every 5 minutes (adjust as needed).

---

## SSL/HTTPS

Most hosts offer free SSL via Let's Encrypt:
- cPanel: **SSL/TLS** → **Run AutoSSL**
- VPS: `sudo certbot --apache` or `sudo certbot --nginx`

---

## Troubleshooting

| Issue | Solution |
|-------|----------|
| 500 Error | Check `config/` folder is writable |
| Can't connect to DB | Verify credentials in `config/config.php` |
| Blank page | Enable PHP error display temporarily |
| Sessions not working | Check PHP session directory permissions |
