Skip to content

Instantly share code, notes, and snippets.

@wosephjeber
Last active May 9, 2018 15:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wosephjeber/444cedc2bb62a7b3e80e to your computer and use it in GitHub Desktop.
Save wosephjeber/444cedc2bb62a7b3e80e to your computer and use it in GitHub Desktop.
Instructions for setting up a local copy of our MODX installation

Here's an outline of the instructions for creating a local dev copy of our MODX installation:

####1. Package and download files from server You'll want to tar and gzip the files on the server for two reasons. First and foremost, it will be faster when you download the files via FTP. Downloading one 100mb file is significantly faster than downloading one hundred 1mb files. Secondly, we want to avoid the potential of messing with hidden files and permissions/ownership.

Use the tar command with gzip enabled: tar -czvf path_to_target path_to_source. For example, to package up the assets directory, you might run tar -czvf backup/assets.tar.gz assets/. This will package and compress the assets directory and save it as a .tar.gz file in the backup directory. You can then download that file via Transmit or another FTP client.

####2. Dump production database and import to local database Use Sequel Pro to export the production database and import it locally. You can name the local database whatever you'd like, just be sure to update the config files in step #5 with the right name.

####3. Clone MODX git repo If you haven't already, clone the MODX git repo to the local directory you have configured with Apache.

####4. Unzip and copy MODX files Unzip the packaged MODX files that were downloaded from the server into any directory on your local machine that you want. We're going to copy them into the directory containing the git repo.

We'll use the deploy directory in the top level of the repo as the document root for the MODX vhost. The repo should at this point only have one directory under deploy named assets. From the MODX files you just downloaded and unpackaged, copy the following files/directories into the deploy directory:

|- build/
|- connectors/
|- content/
|- core/
|- manager/
|- .htaccess
|- 50x.html
|- config.core.php
|- index.php

Next, compare the assets directory in the repo to the assets directory downloaded from the server. There will be a few subdirectories in the downloaded server files that aren't present in the repo assets directory. Copy those over, but don't overwrite any existing subdirectories in the repo. ####5. Update config files We'll update the config files with the local database credentials as well as the local path to the various directories MODX is expecting.

The following config files need to be updated:

|- config.core.php
|- connectors/config.core.php
|- core/config/config.inc.php
|- manager/config.core.php

The config.core.php files are all identical. All you need to do is update define('MODX_CORE_PATH', '/usr/share/nginx/www/core/'); with the correct path to the core directory on your machine.

The config.inc.php file is the main configuration file, and there a number of lines you'll need to change. Most important is the database credentials at the top. Update the following variables: $database_server, $database_user, $database_password, $dbase, $database_dsn to match the local database. You'll also need to update the various paths that are defined to match the corresponding directories on your machine. Be careful not to delete the trailing / on these paths.

####6. Manually clear the MODX cache Manually clear the cache by deleting all the contents of the core/cache/ directory. At this point you should be able to access the manager.

####7. Modify context settings and context switch plugin Out of the box, you should be able to access the frontend of the 'web' context. To view the other contexts locally, you'll need to update some context settings and the context switch plugin.

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