In this section, we are going to make our local system ready to install and develop the demo projects.
If Node.js, NPM, and Java (JRE SE, On Windows, the JDK is required) are already installed on your computer, you can jump directly to installing Magnolia CLI.
|You also need git installed for this tutorial.|
Magnolia needs at least a Java Runtime Environment (JRE) to run. Check if there’s a version of Java already installed on your computer by opening the terminal or command prompt and typing
java -version in a terminal or command prompt. If the system reports a version number, Java is installed on your computer.
|See the Certified stack page to confirm that the version installed is supported.|
If you don’t have Java on your computer, proceed to install it.
On Windows, you need a Java SE Development Kit (JDK). The Java Runtime Environment (JRE) is not enough because the Tomcat application server does not recognize it.
What is the difference?
JRE is for users who run Java programs on their computers.
JDK is for developers who write Java-based applications.
Download and install JDK. By default, JDK is installed at C:\Program Files\Java\jdk-<version>\. You can choose another location.
Check JAVA_HOME environment variable
Open the command prompt.
setand press ENTER.
JAVA_HOMEin the command output and verify that the path points to your JDK installation directory, for example,
JAVA_HOMEis missing or it points to the wrong directory, see Set JAVA_HOME environment variable below.
Set JAVA_HOME environment variable
Right-click My Computer and select Properties.
Go to the Advanced tab.
(In Windows 7+, right-click Computer and select Advanced System Settings, then Environment variables.)
JAVA_HOMEenvironment variable does not exist in User variables or System variables, create it:
User variables apply to the currently signed-in user only. Create
JAVA_HOMEhere if you want it to apply only to the currently logged-in user. These variables take precedence over system variables.
System variables apply to all users. Create
JAVA_HOMEhere if you want it to apply to all users. You must be an administrator to modify a system environment variable.
Set the value of
JAVA_HOMEto the path of your JDK installation directory, for example
Optional step: Add the Magnolia
bindirectory to the
PATHvariable, for example,
C:\Program Files\magnolia\apache-tomcat-x.y\bin. Setting the
PATHallows you to issue the Magnolia
stopcommands from anywhere without navigating to the installation directory first. Separate the path from existing paths with a semicolon ( ; ). If you do this, you also need to add
CATALINA_HOMEto environment variables. Set the value of
CATALINA_HOMEto the Tomcat installation directory, for example,
Go back to Check JAVA_HOME environment variable above and test that the variable is found and has the correct value. You need to open a new command prompt since environment variables are session specific.
Alternatively, you can set JAVA_HOME with a batch file. Add this line to
set JAVA_HOME=C:\Program Files\Java\jdk-<version>>.xx
set command creates the
JAVA_HOME environment variable and sets
its value to the JDK directory. The command is executed when Magnolia
For Mac, you need to download or update to Java 11 or higher. After reviewing and agreeing to the terms of the license agreement, download the file, then double-click it to launch the installation wizard and follow the installation instructions.
The installation directory varies from one Linux system to another. On Debian-based distributions, JREs or JDKs are usually installed in
Magnolia CLI runs on Node.js and npm, the Node.js package manager. Use the following two shell commands to check that you have both of them installed:
node -v npm -v
If you do not have Node.js installed, go to Node.js, download and install the latest LTS version.
For installation instructions of npm, see https://docs.npmjs.com/downloading-and-installing-node-js-and-npm.
Run the following command in a shell to install Magnolia CLI:
|1||Depending on your permissions and the location where you have installed
Node.js, you may have to execute the command above with root
permissions. Without installation permissions you will notice messages
If the installation is successful, you see the following or a similar output in the shell:
/usr/bin/mgnl -> /usr/lib/node_modules/@magnolia/cli/bin/mgnl.js > firstname.lastname@example.org postinstall /usr/lib/node_modules/@magnolia/cli/node_modules/spawn-sync > node postinstall + @email@example.com added 209 packages in 11.40
Once you have installed Magnolia CLI, test the installation by running the following command in the shell:
Usage: mgnl <command> [options] A tool to setup and facilitate light development with Magnolia CMS Options: -v, --version output the version number -h, --help output usage information Commands: jumpstart download and setup a Magnolia CMS instance for development. start start up a Magnolia CMS instance. To stop it, enter CTRL-C add-availability add component availability. build scan a node_modules folder for npm packages with the keyword "magnolia-light-module" (in package.json) and extract them to a directory of choice. create-app create an app. create-block create a block. create-component create a component and optionally add availability for it. create-content-type create a content type. create-light-module create a light module. create-page create a page template. create-virtual-uri create a virtual uri mapping. customize-local-config extract "mgnl-cli-prototypes" folder and "mgnl-cli.json" file to customize CLI configuration. install install a light module from npm to the local Magnolia instance. search search for a light module on npm. tab-completion install tab autocomplete feature for Bash, zsh or PowerShell version display mgnl and node.js versions help [cmd] display help for [cmd] mgnl: 3.1.0 node: v8.10.0 os: linux