# WordPress Codebase Upload - Exact Commands

**Your Configuration:**
```
Server IP:           168.231.120.147
SSH Username:        gloca6781
SSH Port:            22
Document Root:       /home/glocalconsultants.com
Database Host:       localhost
Database Name:       gloc_flocal
Database User:       gloc_glocal
Database Password:   Developer@123
Upload Method:       SSH/SCP
```

---

## STEP 1: PREPARE wp-config.php

**I've created:** `wp-config-production.php`

This file has your database credentials already configured:
- DB_NAME: gloc_flocal
- DB_USER: gloc_glocal
- DB_PASSWORD: Developer@123
- DB_HOST: localhost

**Before uploading, verify this file has correct credentials:**

```bash
cat /Users/gouravmanna/Downloads/Temp/glocalconsultant/wp-config-production.php | grep "define('DB_"
```

**You should see:**
```
define('DB_NAME', 'gloc_flocal');
define('DB_USER', 'gloc_glocal');
define('DB_PASSWORD', 'Developer@123');
define('DB_HOST', 'localhost');
```

✅ **Verified - Ready to upload**

---

## STEP 2: CREATE TEMPORARY UPLOAD DIRECTORY

**In SSH terminal on server:**

```bash
mkdir -p /tmp/wordpress_upload
```

✅ **Directory created on server**

---

## STEP 3: UPLOAD WORDPRESS FILES (LARGE UPLOAD)

**In your local terminal, run this exact command:**

```bash
# Compress and upload all WordPress files to server
tar czf - \
  -C /Users/gouravmanna/Downloads/Temp/glocalconsultant \
  --exclude='DATABASE' \
  --exclude='public_html' \
  --exclude='glocalconsultants.com_BACKUP' \
  --exclude='*.zip' \
  --exclude='*.md' \
  --exclude='.claude' \
  --exclude='.DS_Store' \
  wp-admin wp-includes wp-content index.php wp-*.php .htaccess wp-salt.php license.txt readme.html | \
  ssh -p 22 gloca6781@168.231.120.147 "tar xzf - -C /tmp/wordpress_upload"
```

**What happens:**
- Compresses WordPress files locally
- Uploads directly to server
- Extracts to `/tmp/wordpress_upload/`
- Skips all unnecessary files (saves bandwidth)

**Wait for completion** (should take ~5-10 minutes depending on connection)

**You'll see:**
```
[Files being extracted...]
[Returns to prompt when done]
```

✅ **Files uploaded to /tmp/wordpress_upload/**

---

## STEP 4: UPLOAD wp-config.php SEPARATELY

**In local terminal, upload custom wp-config:**

```bash
scp -P 22 /Users/gouravmanna/Downloads/Temp/glocalconsultant/wp-config-production.php gloca6781@168.231.120.147:/tmp/wordpress_upload/wp-config.php
```

**You'll see:**
```
wp-config-production.php     100%   2.3 KB
```

✅ **wp-config.php uploaded (with your database credentials)**

---

## STEP 5: VERIFY UPLOAD ON SERVER

**In SSH terminal, verify files:**

```bash
ls -lah /tmp/wordpress_upload/ | head -20
```

**You should see:**
```
total 214M
drwxr-xr-x  5 gloca6781 gloca6781  4.0K Apr 22 12:30 .
drwxrwxrwt 10 root      root       4.0K Apr 22 12:35 ..
drwxr-xr-x 103 gloca6781 gloca6781  3.3M Apr 22 12:31 wp-admin
drwxr-xr-x 274 gloca6781 gloca6781  8.8M Apr 22 12:32 wp-includes
drwxr-xr-x  12 gloca6781 gloca6781 148.0M Apr 22 12:34 wp-content
-rw-r--r--  1 gloca6781 gloca6781  2.3K Apr 22 12:35 wp-config.php
-rw-r--r--  1 gloca6781 gloca6781  52K Apr 22 12:31 wp-login.php
... (and other wp-*.php files)
```

✅ **Files verified on server**

---

## STEP 6: MOVE FILES TO DOCUMENT ROOT

**In SSH terminal, move files from temp to production:**

```bash
# Remove any existing WordPress files (backup first if needed)
rm -rf /home/glocalconsultants.com/*

# Move uploaded files to document root
mv /tmp/wordpress_upload/* /home/glocalconsultants.com/

# Verify
ls -lah /home/glocalconsultants.com/ | head -10
```

**You should see:**
```
drwxr-xr-x 103 gloca6781 gloca6781   3.3M Apr 22 12:35 wp-admin
drwxr-xr-x 274 gloca6781 gloca6781   8.8M Apr 22 12:35 wp-includes
drwxr-xr-x  12 gloca6781 gloca6781 148.0M Apr 22 12:35 wp-content
-rw-r--r--  1 gloca6781 gloca6781   2.3K Apr 22 12:35 wp-config.php
-rw-r--r--  1 gloca6781 gloca6781   52K Apr 22 12:35 wp-login.php
```

✅ **Files in production document root**

---

## STEP 7: CHECK FILE OWNER (FROM PREVIOUS STEP)

**Before setting permissions, determine file owner:**

```bash
# Who owns current files?
ls -la /home/glocalconsultants.com/ | head -3
```

**Look at the third column - that's your file owner**

**Common results:**
- `gloca6781` (your SSH username)
- `www-data` (web server user)
- `glocalconsultants.com` (account user)

**Note this username, we'll need it next**

---

## STEP 8: SET CORRECT PERMISSIONS

**First, determine if we need to change ownership:**

```bash
# Check current owner
stat -c "%U:%G" /home/glocalconsultants.com/index.php
```

**If owner is NOT the web server user, change it:**

```bash
# Option A: If web server is www-data
chown -R www-data:www-data /home/glocalconsultants.com

# Option B: If web server is apache
chown -R apache:apache /home/glocalconsultants.com

# Option C: If web server is your username (gloca6781)
chown -R gloca6781:gloca6781 /home/glocalconsultants.com
```

**Then set directory and file permissions:**

```bash
# Set directory permissions to 755
find /home/glocalconsultants.com -type d -exec chmod 755 {} \;

# Set file permissions to 644
find /home/glocalconsultants.com -type f -exec chmod 644 {} \;

# EXCEPT: wp-content needs write permission
chmod -R 755 /home/glocalconsultants.com/wp-content
find /home/glocalconsultants.com/wp-content -type f -exec chmod 644 {} \;
```

✅ **Permissions set correctly**

---

## STEP 9: VERIFY wp-config.php

**Verify database credentials in wp-config.php:**

```bash
grep "define('DB_" /home/glocalconsultants.com/wp-config.php
```

**You should see:**
```
define('DB_NAME', 'gloc_flocal');
define('DB_USER', 'gloc_glocal');
define('DB_PASSWORD', 'Developer@123');
define('DB_HOST', 'localhost');
```

✅ **Database credentials correct**

---

## STEP 10: TEST DATABASE CONNECTION

**In SSH terminal, test connection:**

```bash
mysql -u gloc_glocal -pDeveloper@123 -h localhost gloc_flocal -e "SELECT COUNT(*) as Posts FROM wp_posts;"
```

**You should see:**
```
+-------+
| Posts |
+-------+
|   320 |
+-------+
```

✅ **Database connection successful - data intact!**

---

## STEP 11: TEST WORDPRESS IN BROWSER

**Open your browser and visit:**

```
https://glocalconsultants.com/
```

Or if you don't have DNS configured yet:

```
https://168.231.120.147/
```

**You should see:**
- ✅ WordPress homepage loads
- ✅ No "Error establishing database connection"
- ✅ You may see URL errors (expected - will fix next)
- ✅ Services page shows 86 posts

**Note any errors you see** (we'll address them in next step)

---

## STEP 12: ACCESS WORDPRESS ADMIN

**Try to access admin panel:**

```
https://glocalconsultants.com/wp-admin
```

**Login with:**
```
Username: Pankaj
Password: Admin@123Local
```

⚠️ **Note:** This is the temporary local password. You'll need to change it on production.

**Expected behavior:**
- May redirect to weird URL (expected)
- Admin dashboard may show errors (expected)
- We'll fix URL issues in next step

---

## SUCCESS CRITERIA

**After all steps, verify:**

- [ ] WordPress homepage loads without "database connection error"
- [ ] Services page accessible (shows 86 posts)
- [ ] Admin panel accessible
- [ ] No file permission errors in logs
- [ ] Database connection test passed

---

## TROUBLESHOOTING

### Problem: "Error establishing database connection"
**Solution:**
```bash
# Check credentials
grep "define('DB_" /home/glocalconsultants.com/wp-config.php

# Test MySQL
mysql -u gloc_glocal -pDeveloper@123 -h localhost gloc_flocal -e "SELECT 1;"
```

### Problem: "Permission denied" errors
**Solution:**
```bash
# Fix permissions
find /home/glocalconsultants.com -type d -exec chmod 755 {} \;
find /home/glocalconsultants.com -type f -exec chmod 644 {} \;
chmod -R 755 /home/glocalconsultants.com/wp-content
```

### Problem: Files didn't upload
**Solution:**
```bash
# Check what's in temp
ls -lah /tmp/wordpress_upload/

# Check what's in production
ls -lah /home/glocalconsultants.com/

# If empty, re-run upload commands
```

---

## 📝 QUICK COMMAND SUMMARY

**Copy & paste all commands in order:**

```bash
# 1. Prepare server
mkdir -p /tmp/wordpress_upload

# 2. Upload WordPress (run from local terminal)
tar czf - \
  -C /Users/gouravmanna/Downloads/Temp/glocalconsultant \
  --exclude='DATABASE' \
  --exclude='public_html' \
  --exclude='glocalconsultants.com_BACKUP' \
  --exclude='*.zip' \
  --exclude='*.md' \
  --exclude='.claude' \
  --exclude='.DS_Store' \
  wp-admin wp-includes wp-content index.php wp-*.php .htaccess wp-salt.php license.txt readme.html | \
  ssh -p 22 gloca6781@168.231.120.147 "tar xzf - -C /tmp/wordpress_upload"

# 3. Upload wp-config (run from local terminal)
scp -P 22 /Users/gouravmanna/Downloads/Temp/glocalconsultant/wp-config-production.php gloca6781@168.231.120.147:/tmp/wordpress_upload/wp-config.php

# 4. Move files to production (run on server via SSH)
rm -rf /home/glocalconsultants.com/*
mv /tmp/wordpress_upload/* /home/glocalconsultants.com/

# 5. Set permissions (run on server via SSH)
find /home/glocalconsultants.com -type d -exec chmod 755 {} \;
find /home/glocalconsultants.com -type f -exec chmod 644 {} \;
chmod -R 755 /home/glocalconsultants.com/wp-content

# 6. Test database (run on server via SSH)
mysql -u gloc_glocal -pDeveloper@123 -h localhost gloc_flocal -e "SELECT COUNT(*) FROM wp_posts;"

# 7. Visit site
# Open: https://glocalconsultants.com/
```

---

**STATUS: READY TO UPLOAD**

**Follow steps 1-12 in order. Report results when complete! 🚀**
