Skip to content

Instantly share code, notes, and snippets.

@matdave
Last active August 31, 2015 20:38
Show Gist options
  • Save matdave/b2afbdc5f4fe5c1472ea to your computer and use it in GitHub Desktop.
Save matdave/b2afbdc5f4fe5c1472ea to your computer and use it in GitHub Desktop.
MODX Upgrade on cPanel

The key to upgrading MODX is backup & testing. It is imperative test all features after a major system upgrade, because some packages can break. Before upgrading packages or systems, look for upgrade notes within the website's wiki page or client's job notes if no wiki exists. Also, before upgrading ensure there is enough room on the server for at least double the current file size.

Lock Down the Manager

Either using the Manager or SSH update / create an .htaccess file behind the manager folder with the following command:

order deny,allow
deny from all
allow from YOUR-IP-ADDRESS

Review the Packages

Before we upgrade the MODX install review the packages associated with the current install. Login to the website's admin area and go to "Extras -> Installer." Review the Packages for any that say Update. Before updating packages make sure they do not require a MODX install higher than the current version. If they do, just save them until after the site upgrade.

Backup Everything

Go into the site's cPanel and click on "Backups". Download a backup of the home directory and the latest SQL file. Save these backups to the site's "Technical" folder on the server.

SSH into the site, create a tar of the core folder with the version number and create a tar of the index connector and manager folders:

~: tar -cvf core240.tar core
~: cd public_html/
public_html: tar -cvf public.tar index.php connectors/ manager/ 

Upgrading

Create a new database table with the MODX version number on it, and assign the database user all privileges. Using PHPMyAdmin go into the original database table, and select "Operations". Enter the new database table name under "Copy database to:" and uncheck "CREATE DATABASE before copying"

Unzip the MODX upgrade behind the document root, and give the internal files the proper permissions:

~: cd MODX-2.4.X-pl/
MODX-2.4.X-pl: find . -type d -exec chmod 755 {} \;
MODX-2.4.X-pl: find . -type f -exec chmod 644 {} \;

Copy the contents of the upgraded core folder into the old core folder, and copy the setup folder into the public html folder:

MODX-2.4.X-pl: cp -r setup/ ~/public_html/
MODX-2.4.X-pl: cd core/
core: cp -r * ~/core/

Update the database table references in the old config

~: vi core/config/config.inc.php
:%s,240,24X
:wq

Completely log out of the manager, and open the setup in a private browser window to avoid session issues. Run the upgrade choosing the standard upgrade method. Ensure the setup folder gets deleted after the upgrade has been initiated (especially if it fails).

Log in and clear the site's cache. Test the frontend and backend to verify no issues are present. If all is fine comment out the .htaccess file in the manager:

#order deny,allow
#deny from all
#allow from YOUR-IP-ADDRESS

If the upgrade fails, delete core/, index.php, connectors/, manager/ and setup/ folders and restore them from your previously created tar backups. Empty the contents of your new database table, and re-run the Operations to copy the old data back to it. Attempt the upgrade again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment