Command Line Installation
Last edited by Jason Coward on May 24, 2013.
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.
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. Here's a video of it in action:
See Also
- Basic Installation
- Advanced Installation
- Git Installation
- Command Line Installation
- Troubleshooting Installation
- Successful Installation, Now What Do I Do?
- Using MODx Revolution from SVN
Suggest an edit to this page on GitHub (Requires GitHub account. Opens a new window/tab).