DotCms manual setup

  1. Setup Java

Using option 2

One option for installing Java is to use the version packaged with Ubuntu. By default, Ubuntu 22.04 includes Open JDK 11, which is an open-source variant of the JRE and JDK.

To install the OpenJDK version of Java, first update your apt package index:

sudo apt update

Copy

Next, check if Java is already installed:

java -version

Copy

If Java is not currently installed, you’ll get the following output:

OutputCommand 'java' not found, but can be installed with:

sudo apt install default-jre              # version 2:1.11-72build1, or
sudo apt install openjdk-11-jre-headless  # version 11.0.14+9-0ubuntu2
sudo apt install openjdk-17-jre-headless  # version 17.0.2+8-1
sudo apt install openjdk-18-jre-headless  # version 18~36ea-1
sudo apt install openjdk-8-jre-headless   # version 8u312-b07-0ubuntu1

Execute the following command to install the JRE from OpenJDK 11:

sudo apt install default-jre

Copy

The JRE will allow you to run almost all Java software.

Verify the installation with:

java -version

Copy

You’ll receive output similar to the following:

Outputopenjdk version "11.0.14" 2022-01-18
OpenJDK Runtime Environment (build 11.0.14+9-Ubuntu-0ubuntu2)
OpenJDK 64-Bit Server VM (build 11.0.14+9-Ubuntu-0ubuntu2, mixed mode, sharing)

You may need the JDK in addition to the JRE in order to compile and run some specific Java-based software. To install the JDK, execute the following command, which will also install the JRE:

sudo apt install default-jdk

Copy

Verify that the JDK is installed by checking the version of javac, the Java compiler:

javac -version

Copy

You’ll see the following output:

Outputjavac 11.0.14

Next, you’ll learn how to install Oracle’s official JDK and JRE.

Oracle’s licensing agreement for Java doesn’t allow automatic installation through package managers. To install the Oracle JDK, which is the official version distributed by Oracle, you must create an Oracle account and manually download the JDK to add a new package repository for the version you’d like to use. Then you can use apt to install it with help from a third party installation script. Oracle JDK comes with the JRE included, so you don’t need to install that separately.

The version of Oracle’s JDK you’ll need to download must match the version of the installer script. To find out which version you need, visit the oracle-java11-installer page.

Locate the package for Jammy, as shown in the following figure:

In this image, the version of the script is 11.0.13. In this case, you would need Oracle JDK 11.0.13. Your version number may vary depending on when you’re installing the software.

You don’t need to download anything from this page; you’ll download the installation script through apt shortly.

Next, visit the Archive Downloads and locate the version that matches the one you need.

From this list, choose the Linux x64 compressed archive .tar.gz package:

You’ll be presented with a screen asking you to accept the Oracle license agreement. Select the checkbox to accept the license agreement and press the Download button. Your download will begin. You may need to log in to your Oracle account one more time before the download starts.

Once the file has downloaded, you’ll need to transfer it to your server. On your local machine, upload the file to your server. On macOS, Linux, or Windows using the Windows Subsystem for Linux, use the scp command to transfer the file to the home directory of your sammy user. The following command assumes you’ve saved the Oracle JDK file to your local machine’s Downloads folder:

scp Downloads/jdk-11.0.13_linux-x64_bin.tar.gz sammy@your_server_ip:~

Copy

Once the file upload has completed, return to your server and add the third-party repository that will help you install Oracle’s Java.

First, import the signing key used to verify the software you’re about to install:

sudo gpg --homedir /tmp --no-default-keyring --keyring /usr/share/keyrings/oracle-jdk11-installer.gpg --keyserver keyserver.ubuntu.com --recv-keys EA8CACC073C3DB2A

Copy

You’ll see this output:

Outputgpg: keybox '/usr/share/keyrings/oracle-jdk11-installer.gpg' created
gpg: /tmp/trustdb.gpg: trustdb created
gpg: key EA8CACC073C3DB2A: public key "Launchpad PPA for Linux Uprising" imported
gpg: Total number processed: 1
gpg:               imported: 1

Next, add the repository to your list of package sources:

echo "deb [arch=amd64 signed-by=/usr/share/keyrings/oracle-jdk11-installer.gpg] https://ppa.launchpadcontent.net/linuxuprising/java/ubuntu jammy main" | sudo tee /etc/apt/sources.list.d/oracle-jdk11-installer.list > /dev/null

Copy

Update your package list to make the new software available for installation:

sudo apt update

Copy

The installer will look for the Oracle JDK you downloaded in /var/cache/oracle-jdk11-installer-local. Create this directory and move the Oracle JDK archive there:

sudo mkdir -p /var/cache/oracle-jdk11-installer-local/
sudo cp jdk-11.0.13_linux-x64_bin.tar.gz /var/cache/oracle-jdk11-installer-local/

Copy

Finally, install the package:

sudo apt install oracle-java11-installer-local

Copy

The installer will first ask you to accept the Oracle license agreement. Accept the agreement, then the installer will extract the Java package and install it.

Now you’ll look at how to select the version of Java you want to use.

You can have multiple Java installations on one server. You can configure which version is the default for use on the command line by using the update-alternatives command.

sudo update-alternatives --config java

Copy

This is what the output would look like if you’ve installed both versions of Java in this tutorial:

OutputThere are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                         Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/java-11-openjdk-amd64/bin/java   1111      auto mode
  1            /usr/lib/jvm/java-11-openjdk-amd64/bin/java   1111      manual mode
* 2            /usr/lib/jvm/java-11-oracle/bin/java          1091      manual mode

Press <enter> to keep the current choice[*], or type selection number:

Choose the number associated with the Java version to use it as the default, or press ENTER to leave the current settings in place.

You can do this for other Java commands, such as the compiler (javac):

sudo update-alternatives --config javac

Copy

Other commands for which this command can be run include, but are not limited to: keytool, javadoc, and jarsigner.

Many programs written using Java use the JAVA_HOME environment variable to determine the Java installation location.

To set this environment variable, first determine where Java is installed. Use the update-alternatives command:

sudo update-alternatives --config java

Copy

This command shows each installation of Java along with its installation path:

OutputThere are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                         Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/java-11-openjdk-amd64/bin/java   1111      auto mode
  1            /usr/lib/jvm/java-11-openjdk-amd64/bin/java   1111      manual mode
* 2            /usr/lib/jvm/java-11-oracle/bin/java          1091      manual mode

Press <enter> to keep the current choice[*], or type selection number:

In this case the installation paths are as follows:

  1. OpenJDK 11 is located at /usr/lib/jvm/java-11-openjdk-amd64/bin/java.

  2. Oracle Java is located at /usr/lib/jvm/java-11-oracle/jre/bin/java.

Copy the path from your preferred installation. Then open /etc/environment using nano or your favorite text editor:

sudo nano /etc/environment

Copy

At the end of this file, add the following line, making sure to replace the highlighted path with your own copied path, and to not include the bin/ portion of the path:

/etc/environment

JAVA_HOME="/usr/lib/jvm/java-11-openjdk-amd64"

Modifying this file will set the JAVA_HOME path for all users on your system.

Save the file and exit the editor.

Now reload this file to apply the changes to your current session:

source /etc/environment

Copy

Verify that the environment variable is set:

echo $JAVA_HOME

Copy

You’ll see the path you just set:

Output/usr/lib/jvm/java-11-openjdk-amd64

Other users will need to execute the command source /etc/environment or log out and log back in to apply this setting.

2. Download and build dotCms

2.1 Build dotCms

go to and download taz file: https://github.com/dotCMS/core/releases/tag/v23.05

// run to untar source code
tar -zxvf v23.05.tar.gz
cd core-23.05/dotCMS
./gradlew createDist

After gradle is done, you will find your newly built dotCMS distros (both tar and .zip) under the /core/dist-output folder. This is the complete dotCMS package, including a Tomcat app server needed to run dotCMS.

has two file build:

// untar file to get the source running
tar -zxvf dotcms_X.X.tar.gz

2.2 Install postgresql

follow the page

https://www.digitalocean.com/community/tutorials/how-to-install-postgresql-on-ubuntu-20-04-quickstart#step-4-creating-a-new-database and

sudo -i -u postgres
psql
select * from pg_settings where name='config_file'
// config file: 
//  /etc/postgresql/15/main/postgresql.conf

// Note: change the port if need

Since the default “postgres” user does not have a password, you should set it yourself.

\password postgres

Add or edit the following line in your postgresql.conf :

listen_addresses = '*'

Add the following line as the first line of pg_hba.conf. It allows access to all databases for all users with an encrypted password:

from user login: ssh_remote1

// from user login: ssh_remote1
sudo vi /etc/postgresql/15/main/pg_hba.conf


# TYPE DATABASE USER CIDR-ADDRESS  METHOD
host all postgres 127.0.0.1/32 trust
host  all  all 0.0.0.0/0 md5
host all all      ::1/128      md5
# IPv4 local connections:
host    all             all             127.0.0.1/32            trust


sudo systemctl restart postgresql.service

Restart Postgresql after adding this with service postgresql restart or the equivalent command for your setup. For brew, brew services restart postgresql

Create new user database

Follow the instruction

sudo -i -u postgres
psql
postgres=# ALTER USER sunny PASSWORD 'fooBarEatsBarFoodBareFoot';
ERROR:  role "sunny" does not exist
postgres=# CREATE ROLE sunny LOGIN PASSWORD 'fooBarEatsBarFoodBareFoot12345';
CREATE ROLE
postgres=# \du
                                   List of roles
 Role name |                         Attributes                         | Member of
-----------+------------------------------------------------------------+-----------
 postgres  | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
 sunny     |                                                            | {}

postgres=# GRANT ALL PRIVILEGES ON DATABASE dotcms TO sunny;
GRANT
postgres=# \du
                                   List of roles
 Role name |                         Attributes                         | Member of
-----------+------------------------------------------------------------+-----------
 postgres  | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
 sunny     |                                                            | {}

postgres=# ALTER USER sunny WITH SUPERUSER;
ALTER ROLE
postgres=# \du
                                   List of roles
 Role name |                         Attributes                         | Member of
-----------+------------------------------------------------------------+-----------
 postgres  | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
 sunny     | Superuser                                                  | {}

postgres=#

2.2 ElasticSearch

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.17.10-x86_64.rpm
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.17.10-x86_64.rpm.sha512
shasum -a 512 -c elasticsearch-7.17.10-x86_64.rpm.sha512 
sudo rpm -ihv --nodeps elasticsearch-7.17.10-x86_64.rpm


sudo vi /etc/elasticsearch/elasticsearch.yml
// add the line to first of setting
xpack.security.enabled: true


sudo vi /etc/sysconfig/elasticsearch
// set es home
ES_JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64


cd /usr/share/elasticsearch/bin
./elasticsearch-setup-passwords interactive
//and type the password

systemctl restart elasticsearch
systemctl enable elasticsearch

2.3 Setup dotCms

2.3.1. create database postgre called dotcms

create database dotcms
    with owner postgres ENCODING 'UTF8';
    

Edit the database connection properties in the db.properties file $DOTCMS_HOME/dotserver/tomcat_X.X/webapps/ROOT/WEB-INF/classes/db.properties

DOTCMS_HOME = /home/ssh_remote1/dotcms/run

the full path:

/home/ssh_remote1/dotcms/run/dotserver/tomcat-9.0.60/webapps/ROOT/WEB-INF/classes/db.properties

driverClassName=org.postgresql.Driver
jdbcUrl=jdbc:postgresql://localhost:9001/dotcms
username=dotcms
password=dotcms

2.3.2. Config ElasticSearch

vi /home/ssh_remote1/dotcms/run/dotserver/tomcat-9.0.60/webapps/ROOT/WEB-INF/classes/dotcms-config-cluster.properties


ES_ENDPOINTS=http://localhost:9200
ES_AUTH_TYPE=BASIC
ES_AUTH_BASIC_USER=elastic
ES_AUTH_BASIC_PASSWORD={password config}

2.3.3 run the dotCMS

edit server.xml

vi /home/ssh_remote1/dotcms/run/dotserver/tomcat-9.0.60/conf/server.xml

cd /home/ssh_remote1/dotcms/run

chmod 755 ./bin/*.sh
chmod 755 dotserver/tomcat-9.0.60/bin/*.sh

ssh_remote1@myjibra:~/dotcms/run$ ./bin/startup.sh
Using DOTCMS_HOME = /home/ssh_remote1/dotcms/run/dotserver/tomcat-9.0.60/webapps/ROOT
Using DOTSERVER = run
Using CATALINA_PID = /tmp/run.pid
Using JAVA_OPTS =  -Djava.awt.headless=true -Xverify:none -Dfile.encoding=UTF8 -server -XX:+DisableExplicitGC -XX:MaxMetaspaceSize=512m -Xmx1G -XX:+UseG1GC -Dsun.jnu.encoding=UTF-8 -Ddotserver=run
Using CATALINA_BASE:   /home/ssh_remote1/dotcms/run/dotserver/tomcat-9.0.60
Using CATALINA_HOME:   /home/ssh_remote1/dotcms/run/dotserver/tomcat-9.0.60
Using CATALINA_TMPDIR: /home/ssh_remote1/dotcms/run/dotserver/tomcat-9.0.60/temp
Using JRE_HOME:        /usr/lib/jvm/java-11-openjdk-amd64
Using CLASSPATH:       /home/ssh_remote1/dotcms/run/dotserver/tomcat-9.0.60/bin/bootstrap.jar:/home/ssh_remote1/dotcms/run/dotserver/tomcat-9.0.60/bin/tomcat-juli.jar
Using CATALINA_OPTS:
Using CATALINA_PID:    /tmp/run.pid
Existing PID file found during start.
Removing/clearing stale PID file.
Tomcat started.


// run to check port working:

netstat -tunlp


// see the log

tail -n 1000 -f /home/ssh_remote1/dotcms/run/dotserver/tomcat-9.0.60/logs/catalina.out

Last updated