# Next Session: Complete Revert to Production Configuration

**Last Modified:** 2026-04-15  
**Purpose:** Step-by-step instructions to cleanly revert all local changes and restore production configuration

---

## CONTEXT SUMMARY

During the local setup session, the following temporary changes were made to enable WordPress to run on localhost:8000:

### What Was Changed:
1. PHP server started on localhost:8000
2. MySQL database and user created
3. Site URLs changed from production domain to localhost
4. Admin password reset with temporary credentials
5. Really Simple SSL plugin disabled
6. Database backup extracted

### Current Local Access:
- **Homepage:** http://localhost:8000
- **Admin Login:** http://localhost:8000/wp-login.php
- **Credentials:** Pankaj / Admin@123Local (TEMPORARY)

### Current Database State:
- Database: gloc_wp
- User: gloc_wp@localhost
- 37 tables with all content intact
- Site URLs: http://localhost:8000

---

## REVERT SEQUENCE (EXACT ORDER IMPORTANT)

### STEP 1: Stop PHP Server
**Purpose:** Disconnect users and stop server gracefully

**Command:**
```bash
kill $(cat /tmp/php_server.pid)
```

**Expected Result:**
- Server stops immediately
- No error messages expected
- Web access to http://localhost:8000 will fail

**Verification:**
```bash
ps aux | grep "php -S localhost:8000" | grep -v grep
# Should show no output (process terminated)
```

---

### STEP 2: Restore Database Option: siteurl
**Purpose:** Change site URL back from localhost to production domain

**Command:**
```bash
mysql -u gloc_wp -p'gloc_wp' gloc_wp -e "UPDATE wp_options SET option_value = 'https://glocalconsultants.com' WHERE option_name = 'siteurl';"
```

**What This Does:**
- Changes wp_options.siteurl from http://localhost:8000 to https://glocalconsultants.com
- This is the primary WordPress site URL setting
- Required for proper WordPress functionality

**Verification:**
```bash
mysql -u gloc_wp -p'gloc_wp' gloc_wp -e "SELECT option_value FROM wp_options WHERE option_name = 'siteurl';"
# Expected output: https://glocalconsultants.com
```

---

### STEP 3: Restore Database Option: home
**Purpose:** Change home URL back from localhost to production domain

**Command:**
```bash
mysql -u gloc_wp -p'gloc_wp' gloc_wp -e "UPDATE wp_options SET option_value = 'https://glocalconsultants.com' WHERE option_name = 'home';"
```

**What This Does:**
- Changes wp_options.home from http://localhost:8000 to https://glocalconsultants.com
- This is the WordPress home/root URL
- Required for proper WordPress functionality

**Verification:**
```bash
mysql -u gloc_wp -p'gloc_wp' gloc_wp -e "SELECT option_value FROM wp_options WHERE option_name = 'home';"
# Expected output: https://glocalconsultants.com
```

---

### STEP 4: Re-enable Really Simple SSL Plugin
**Purpose:** Restore HTTPS protection and enforce SSL redirect

**Command:**
```bash
mysql -u gloc_wp -p'gloc_wp' gloc_wp -e "UPDATE wp_options SET option_value = 'a:11:{i:0;s:34:\"advanced-custom-fields-pro/acf.php\";i:1;s:43:\"custom-post-type-ui/custom-post-type-ui.php\";i:2;s:49:\"easy-table-of-contents/easy-table-of-contents.php\";i:3;s:29:\"gravityforms/gravityforms.php\";i:4;s:35:\"litespeed-cache/litespeed-cache.php\";i:5;s:47:\"really-simple-ssl/rlrsssl-really-simple-ssl.php\";i:6;s:27:\"svg-support/svg-support.php\";i:7;s:25:\"tablepress/tablepress.php\";i:8;s:24:\"wordpress-seo/wp-seo.php\";i:9;s:43:\"wp-cli-login-server/wp-cli-login-server.php\";i:10;s:33:\"wp-mail-smtp-pro/wp_mail_smtp.php\";}' WHERE option_name = 'active_plugins';"
```

**What This Does:**
- Re-adds really-simple-ssl/rlrsssl-really-simple-ssl.php to active plugins list
- Changes plugin count from 10 back to 11
- Restores HTTPS enforcement for production

**Verification:**
```bash
mysql -u gloc_wp -p'gloc_wp' gloc_wp -e "SELECT option_value FROM wp_options WHERE option_name = 'active_plugins';" | grep -c "really-simple-ssl"
# Expected: 1 (found in plugin list)
```

---

### STEP 5: Restore Original Admin Password
**Purpose:** Restore the original (production) admin password hash

**Command:**
```bash
mysql -u gloc_wp -p'gloc_wp' gloc_wp -e "UPDATE wp_users SET user_pass = '\$wp\$2y\$10\$fFXQwuaJ9mYfJ916V9/2EeivEDlyxBdHJrDtQgnjx2DR7q5Whaioa' WHERE ID = 1;"
```

**What This Does:**
- Replaces temporary password hash with original production hash
- User Pankaj will need production password to log in
- Removes temporary local access password

**Verification:**
```bash
mysql -u gloc_wp -p'gloc_wp' gloc_wp -e "SELECT user_pass FROM wp_users WHERE ID = 1;"
# Expected: $wp$2y$10$fFXQwuaJ9mYfJ916V9/2EeivEDlyxBdHJrDtQgnjx2DR7q5Whaioa
```

---

### STEP 6 (OPTIONAL): Delete Extracted SQL File
**Purpose:** Clean up extracted database backup (optional)

**Command:**
```bash
rm /Users/gouravmanna/Downloads/Temp/glocalconsultant/DATABASE/gloc_wp.sql
```

**Important Notes:**
- ⚠️ OPTIONAL - Only delete if you want to save disk space
- Original backup (gloc_wp.sql.gz) will remain
- You can always re-extract from .gz if needed in future
- No negative impact on production if deleted

**Verification:**
```bash
ls -lh /Users/gouravmanna/Downloads/Temp/glocalconsultant/DATABASE/
# Only gloc_wp.sql.gz should remain after deletion
```

---

### STEP 7 (OPTIONAL): Clean Up Temporary Files
**Purpose:** Remove temporary files created during setup

**Commands:**
```bash
# Remove PHP server log
rm /tmp/php_server.log

# Remove PHP server PID file
rm /tmp/php_server.pid

# Remove temporary password generation script
rm /tmp/reset_password.php

# Remove audit file (if it exists)
rm /tmp/current_state_audit.txt
```

**Important Notes:**
- ⚠️ OPTIONAL - These are temporary files with no impact
- Removing them just cleans up /tmp directory
- No WordPress or database impact
- Safe to skip this step

---

## DOCUMENTATION FILES TO KEEP

These files should be **KEPT** after revert (they are for reference only):

```
✅ KEEP: local_setup_log.md
   - Complete setup documentation
   - Future reference for how setup was done
   - Location: /Users/gouravmanna/Downloads/Temp/glocalconsultant/

✅ KEEP: current_local_state.md
   - Snapshot of what was changed
   - For future audits
   - Location: /Users/gouravmanna/Downloads/Temp/glocalconsultant/

✅ KEEP: next_session_revert_prompt.md (this file)
   - Instructions for next revert
   - For future reference
   - Location: /Users/gouravmanna/Downloads/Temp/glocalconsultant/

✅ KEEP: DATABASE/gloc_wp.sql.gz
   - Original backup file
   - Preserve for future use
   - Location: /Users/gouravmanna/Downloads/Temp/glocalconsultant/DATABASE/
```

---

## POST-REVERT VERIFICATION CHECKLIST

After completing all revert steps, verify with this checklist:

### ✅ Database Changes Reverted

```bash
# Verify siteurl reverted to production
mysql -u gloc_wp -p'gloc_wp' gloc_wp -e "SELECT option_value FROM wp_options WHERE option_name = 'siteurl';"
# Must show: https://glocalconsultants.com
[ ] PASS / [ ] FAIL

# Verify home reverted to production
mysql -u gloc_wp -p'gloc_wp' gloc_wp -e "SELECT option_value FROM wp_options WHERE option_name = 'home';"
# Must show: https://glocalconsultants.com
[ ] PASS / [ ] FAIL

# Verify Really Simple SSL re-enabled
mysql -u gloc_wp -p'gloc_wp' gloc_wp -e "SELECT option_value FROM wp_options WHERE option_name = 'active_plugins';" | grep -c "really-simple-ssl"
# Must show: 1
[ ] PASS / [ ] FAIL

# Verify password restored
mysql -u gloc_wp -p'gloc_wp' gloc_wp -e "SELECT user_pass FROM wp_users WHERE ID = 1;"
# Must show: $wp$2y$10$fFXQwuaJ9mYfJ916V9/2EeivEDlyxBdHJrDtQgnjx2DR7q5Whaioa
[ ] PASS / [ ] FAIL
```

### ✅ Services Status

```bash
# Verify PHP server is stopped
ps aux | grep "php -S localhost:8000" | grep -v grep
# Must show: nothing (process killed)
[ ] PASS / [ ] FAIL

# Verify MySQL is still running
brew services list | grep mysql
# Must show: mysql   started
[ ] PASS / [ ] FAIL

# Verify database still exists
mysql -u root -e "SHOW DATABASES LIKE 'gloc_wp';"
# Must show: gloc_wp
[ ] PASS / [ ] FAIL

# Verify all tables still present
mysql -u gloc_wp -p'gloc_wp' gloc_wp -e "SELECT COUNT(*) as table_count FROM information_schema.tables WHERE table_schema='gloc_wp';"
# Must show: 37
[ ] PASS / [ ] FAIL
```

### ✅ Data Integrity

```bash
# Verify posts still present
mysql -u gloc_wp -p'gloc_wp' gloc_wp -e "SELECT COUNT(*) as post_count FROM wp_posts;"
# Must show: 320 (or similar - original count)
[ ] PASS / [ ] FAIL

# Verify pages still present
mysql -u gloc_wp -p'gloc_wp' gloc_wp -e "SELECT COUNT(*) as page_count FROM wp_posts WHERE post_type='page';"
# Must show: 11
[ ] PASS / [ ] FAIL

# Verify users still present
mysql -u gloc_wp -p'gloc_wp' gloc_wp -e "SELECT COUNT(*) as user_count FROM wp_users;"
# Must show: 1
[ ] PASS / [ ] FAIL
```

### ✅ Files Status

```bash
# Verify WordPress files unchanged
ls -la /Users/gouravmanna/Downloads/Temp/glocalconsultant/wp-config.php
# Must exist
[ ] PASS / [ ] FAIL

# Verify backup file still present
ls -lh /Users/gouravmanna/Downloads/Temp/glocalconsultant/DATABASE/gloc_wp.sql.gz
# Must exist (1.2 MB)
[ ] PASS / [ ] FAIL

# Verify documentation files present
ls /Users/gouravmanna/Downloads/Temp/glocalconsultant/{local_setup_log.md,current_local_state.md,next_session_revert_prompt.md}
# All three must exist
[ ] PASS / [ ] FAIL
```

---

## TROUBLESHOOTING

### If siteurl/home won't update:
**Symptom:** MySQL command returns "0 rows affected"
**Solution:**
1. Verify spelling: must be exactly 'siteurl' and 'home' (lowercase)
2. Verify database: `mysql -u gloc_wp -p'gloc_wp' gloc_wp` connects
3. Check current value: `SELECT * FROM wp_options WHERE option_name='siteurl';`
4. Try without WHERE clause to find actual name

### If password won't update:
**Symptom:** Password doesn't change or MySQL error
**Solution:**
1. Copy exact hash: `$wp$2y$10$fFXQwuaJ9mYfJ916V9/2EeivEDlyxBdHJrDtQgnjx2DR7q5Whaioa`
2. Use double-escaped version in command: `\$wp\$2y\$...`
3. Verify update with SELECT query
4. If still fails, use MySQL GUI tool to update directly

### If plugin list gets corrupted:
**Symptom:** PHP error or plugins don't load correctly
**Solution:**
1. Verify exact plugin list (see STEP 4 command)
2. Count colons and quotes carefully
3. Consider re-extracting current state from database
4. Backup: database is safe, can always update again

---

## FINAL NOTES

✅ **All changes made are reversible**  
✅ **No WordPress files have been modified**  
✅ **Database integrity fully preserved**  
✅ **All reversal commands are idempotent** (safe to run multiple times)  
✅ **No additional cleanup needed beyond steps above**  

**After completing this revert, your WordPress installation will be:**
- ✅ Configured for production at https://glocalconsultants.com
- ✅ With original admin password restored
- ✅ With Really Simple SSL re-enabled for HTTPS
- ✅ With all 11 plugins enabled
- ✅ With all 320 posts, 11 pages, and all data intact
- ✅ Ready to be deployed or accessed via production domain

---

**Created:** 2026-04-15  
**Purpose:** Enable clean revert of local development setup in next session  
**Status:** Ready to use

