Skip to content

Commit

Permalink
Merge pull request #18 from redbrick/add-update-wp-domain
Browse files Browse the repository at this point in the history
add 'Updating WordPress Domains' page
  • Loading branch information
wizzdom authored Jan 25, 2024
2 parents b2a10fb + 18d79ba commit a99b18f
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/procedures/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Here you can find a list of various procedures useful for the day-to-day running
### [New elected admins](new-admins.md)
### [Post-powercut Todo List](post-powercut.md)
### [NixOS](nixos.md)
### [Updating WordPress Domains](update-wp-domain.md)
### [IRC Ops](irc-ops.md)
### [Committee Handover](handover.md)
### [Redbrick System Administrator Policies](policies.md)
36 changes: 36 additions & 0 deletions docs/procedures/update-wp-domain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

# Update a WordPress Domain - `wizzdom`, `distro`

Redbrick hosts a variety of services and websites for various clubs and societies in DCU. Oftentimes these websites hosted for societies run on WordPress due to it's ease of use.
However, what happens when you no longer have access to the domain? You can change the domain on the webserver however WordPress will redirect you to the old domain. In this case you must update the database to change the domain. This happened with TheCollegeView in 2023, you can read more about that [here](https://github.com/redbrick/open-governance/tree/master/admin/)
## SQL Commands

> [!WARNING] BACKUPS!!!
> Ensure you have a recent backup of the database by checking `/storage/backups`
- First, check what the current value is
```sql
-- validate current setting
select option_name,option_value from wp_2options where( option_name="siteurl" or option_name="home");
```

- Now, update the option with the new value
```sql
-- update to new value
update wp_2options set option_value="http://www.thecollegeview.redbrick.dcu.ie" where( option_name="siteurl" or option_name="home");
```

- Verify that the new value is set correctly
```sql
-- validate new value
select option_name,option_value from wp_2options where( option_name="siteurl" or option_name="home");
```

- Now, the same again but for the post content and guid
```sql
-- update post content with new domain
update wp_2posts set post_content = replace(post_content,"://www.thecollegeview.com/","://thecollegeview.redbrick.dcu.ie/");

-- update the guid with the new domain
update wp_2posts set guid = replace(guid,"://www.thecollegeview.com/","://thecollegeview.redbrick.dcu.ie/");
```

0 comments on commit a99b18f

Please sign in to comment.