Jump to main content Jump to doc navigation

CLI Installation is available only for MODX Revolution versions 2.2 and later.

Installing MODX via the PHP Command Line

MODX allows you to do upgrades and installations via the command line (CLI) while using a config XML file. (More info on this file can be found here.) This allows users to create simple batch scripts to update their MODX installations.

When running upgrades, it is always recommended to backup your files before upgrading.

New CLI Installations

First off, download MODX and extract the files to your server. In the setup/ directory, copy the file config.dist.new.xml and rename it to config.xml. MODX will automatically look for the setup/config.xml file during installation. You can move it outside of the setup/ directory (and the MODX webroot, if you choose), and specify its location with the "--config=/path/to/config.xml" argument.

Next, edit the XML file and set the appropriate database information, MODX paths, and other configuration parameters, and then in your command line prompt, browse to the MODX setup/ directory, and type:

php ./index.php --installmode=new

MODX will proceed to install, and when finished will display the time it took to run the installation, as well as any errors that occurred (which will also be logged in an install log file in core/cache/logs/).

Note : if your core folder is in a "non-standard" location, you might want to use :

--core_path=/path/to/core/

Doing a Basic Upgrade MODX via CLI

Follow the same steps as new installations, but this time in your XML file you need only specify the following attributes:

  • inplace
  • unpacked
  • language
  • remove_setup_directory

And any other attributes you would like to change during the upgrade. There is an example upgrade xml file named "config.dist.upgrade.xml". Then, once you are ready, browse to the MODX setup directory, and type:

php ./index.php --installmode=upgrade

This will upgrade your MODX installation, and when finished will display the time it took to run the installation, as well as any errors that occurred (which will also be logged in an install log file in core/cache/logs/).

Doing an Advanced Upgrade MODX via CLI

Follow the same steps as basic upgrade, but this time in your XML file you need all the attributes included in the config.dist.upgrade-advanced.xml file, as all can be changed in an advanced upgrade.

Then, once you are ready, browse to the MODX setup directory, and type:

php ./index.php --installmode=upgrade-advanced

This will upgrade your MODX installation, and when finished will display the time it took to run the installation, as well as any errors that occurred (which will also be logged in an install log file in core/cache/logs/).

Using a Helper Script

There is a helper script installmodx.php available on Github: https://github.com/craftsmancoding/modx_utils/blob/master/installmodx.php

It provides command line options for this process.

See Also

  1. Basic Installation
  2. Lighttpd Guide
  3. Installation on a server running ModSecurity
  4. Nginx Server Config
  5. Advanced Installation
  6. Git Installation
  7. Command Line Installation
  8. The Setup Config Xml File
  9. Troubleshooting Installation
  10. Successful Installation, Now What Do I Do?

Support the team building MODX with a monthly donation.

The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.

Backers

  • modmore
  • STERC
  • Digital Penguin
  • Jens Wittmann – Gestaltung & Entwicklung
  • Fabian Christen
  • Dannevang Digital
  • Sepia River Studios
  • CrewMark
  • Chris Fickling
  • deJaya
  • Lefthandmedia
  • Murray Wood
  • eydolan
  • Following Sea
  • Anton Tarasov
  • Stéphane Jäggi
  • Raffy
  • Snow Creative
  • A. Moreno
  • Nick Clark
  • JT Skaggs
  • Helen
  • YJ
  • krisznet
  • Richard
  • Yanni

Budget

$301 per month—let's make that $500!

Learn more