You can use environment variables to configure Liferay DXP, which is especially useful in cloud-based environments.
Overriding Portal Properties
To override portal properties, follow these operating system (OS) and Liferay environment variable name guidelines:
OS environment variable names:
- Consist of uppercase letters, digits, and
_
(underscore) characters only - Must not start with a digit
Liferay environment variable names:
- Must follow the OS environment variable name guidelines
- Must start with the prefix
LIFERAY_
- Characters that violate the OS guidelines must be encoded using one of the following methods:
Encoding with CharPool Constants
Follow these rules to encode with
CharPool
constants:
- Use upper case (
CharPool
constant names are uppercase). - Remove
_
characters from theCharPool
constant names. - Wrap each constant name in a pair of
_
characters.
Here are some encoding examples.
CharPool Constant Example 1
This example involves encoding the period .
character.
Portal property:
setup.wizard.enabled=false
Encoding steps:
-
Prefix the variable with
LIFERAY_
.LIFERAY_setup.wizard.enabled=false
-
Encode the period characters with the
CharPool
constant namePERIOD
, surrounded by a pair of_
characters.LIFERAY_setup_PERIOD_wizard_PERIOD_enabled=false
-
Convert all letters to uppercase.
Environment variable:
LIFERAY_SETUP_PERIOD_WIZARD_PERIOD_ENABLED=false
CharPool Constant Example 2
This example uses CharPool
constants to encode an environment variable name
for a property that includes periods, brackets, and uppercase characters.
Portal property:
setup.database.driverClassName[mysql]=com.mysql.jdbc.Driver
Encoding steps:
-
Prefix the variable with
LIFERAY_
.LIFERAY_setup.database.driverClassName[mysql]=com.mysql.jdbc.Driver
-
Use
CharPool
constant names surrounded by_
characters:.
→_PERIOD_
C
→_UPPER_CASE_C_
N
→_UPPER_CASE_N_
[
→_OPEN_BRACKET_
]
→_CLOSE_BRACKET_
LIFERAY_setup_PERIOD_database_PERIOD_driver_UPPER_CASE_C_lass_UPPER_CASE_N_ame_OPEN_BRACKET_mysql_CLOSE_BRACKET_=com.mysql.jdbc.Driver
-
Remove underscores from all constant names.
_UPPER_CASE_C_
→_UPPERCASEC_
_UPPER_CASE_N_
→_UPPERCASEN_
_OPEN_BRACKET_
→_OPENBRACKET_
_CLOSE_BRACKET_
→_CLOSEBRACKET_
LIFERAY_setup_PERIOD_database_PERIOD_driver_UPPERCASEC_lass_UPPERCASEN_ame_OPENBRACKET_mysql_CLOSEBRACKET_=com.mysql.jdbc.Driver
-
Convert all letters to uppercase.
Environment variable:
LIFERAY_SETUP_PERIOD_DATABASE_PERIOD_DRIVER_UPPERCASEC_LASS_UPPERCASEN_AME_OPENBRACKET_MYSQL_CLOSEBRACKET_=com.mysql.jdbc.Driver
Encoding with Unicode Code Points
Unicode offers more character encodings than CharPool
and produces shorter
variable names. But Unicode code points are cryptic.
Follow these rules to encode with Unicode:
-
Look up the character code points.
-
Replace each character with a code point wrapped in a pair of
_
characters.
Here’s an encoding example that uses Unicode.
Unicode Example
This example uses code points to encode an environment variable name for a portal property that contains periods, brackets, and uppercase characters.
Portal property:
setup.database.driverClassName[mysql]=com.mysql.jdbc.Driver
Encoding steps:
-
Prefix the variable with
LIFERAY_
.LIFERAY_setup.database.driverClassName[mysql]=com.mysql.jdbc.Driver
-
Use
CharPool
constant names surrounded by_
characters to encode the following characters:.
→_46_
C
→_67_
N
→_78_
[
→_91_
]
→_93_
LIFERAY_setup_46_database_46_driver_67_lass_78_ame_91_mysql_93_=com.mysql.jdbc.Driver
-
Convert all letters to uppercase.
Environment variable:
LIFERAY_SETUP_46_DATABASE_46_DRIVER_67_LASS_78_AME_91_MYSQL_93_=com.mysql.jdbc.Driver
Congratulations! You know how to use environment variables to configure Liferay DXP. It’s easier than ever to configure and deploy Liferay DXP images in virtual machines and cloud containers.