This page provides instructions on how to do a basic installation of
Magnolia using the Magnolia CLI. You should do this before starting the
Hello
Magnolia for front-end developers tutorial.
This tutorial is based on version 4 of Magnolia CLI.
Get Java
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.
If the system reports a version number, Java is installed on your computer.
See Certified stack to confirm that the version installed is supported.
Windows
Mac
Linux
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.
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>\.
Instructions
Check for JAVA_HOME
Open the command prompt.
Type set and press ENTER.
Find JAVA_HOME in the command output and verify that the path points to your JDK installation directory, for example,
C:\Program Files\Java\jdk-<version>>.xx.
If JAVA_HOME is missing or it points to the wrong directory, see Set JAVA_HOME.
Set JAVA_HOME
Open the Command Prompt as an administrator.
Set the path for JAVA_HOME.
setx /m JAVA_HOME "path\to\Java\jdk"(1)Copy
1
Where path\to\Java\jdk is where your Java Development Kit is saved.
The set command creates the JAVA_HOME environment variable and sets its value to the JDK directory.
The command is executed when Magnolia starts.
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 /usr/lib/jvm/.
Get node.js
Magnolia CLI is an npm package providing a
command line interface (CLI) tool to set up and facilitate light
development with Magnolia. The Magnolia CLI tool runs on
Node.js. If you do not have Node.js installed, go
to Node.js and download and install the latest LTS
version.
To check the version of your node installation, run the following
command in a shell:
node -vCopy
Get Magnolia CLI
The steps below leverage version 4 of Magnolia CLI.
Run the following command in a shell to install
Magnolia CLI:
You must use CLI version 4.0.12 or later to install Magnolia 6.3.
Mac or Linux
Windows
sudo npm install @magnolia/cli -gCopy
npm install @magnolia/cli -g (1)Copy
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
such as npm ERR! in the shell.
If the installation is successful, you see the following or a similar
output in the shell:
Once you have installed Magnolia CLI, test the installation by running
the following command in the shell:
mgnl helpCopy
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
Copy
Installing Magnolia with CLI only
Use the jumpstart command to install Magnolia. This command downloads,
unpacks and pre-configures a Magnolia bundle of your choice.
The jumpstart command automatically creates a light modules directory for you in the current folder.
If you already have a different directory that you want to use for light modules, use the -p option with the command to specify the path to your existing light modules folder.
For example:
Choose the magnolia-community-demo-webapp containing Magnolia
Community Edition bundled with the
Travel Demo and a Tomcat
server. It creates folders for the Tomcat server and for the light
modules according to the CLI configuration.
Once the setup operation is complete, you should see a message similar
to this one:
info Magnolia has been successfully setup for light development!
info You can now open a new terminal tab or window and start it up with the CLI command 'mgnl start'
info Magnolia will be ready after a few seconds at localhost:8080/magnoliaAuthor. Username and password is superuser