# DotCms manual setup

1. ## Setup Java

Using option 2

#### [Option 1 — Installing the Default JRE/JDK](https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-on-ubuntu-22-04#option-1-installing-the-default-jre-jdk)

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.

#### [Option 2 — Installing Oracle JDK 11](https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-on-ubuntu-22-04#option-2-installing-oracle-jdk-11)

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](https://profile.oracle.com/myprofile/account/create-account.jspx) 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](https://launchpad.net/~linuxuprising/+archive/ubuntu/java/+packages). 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`](https://launchpad.net/~linuxuprising/+archive/ubuntu/java/+packages) page.

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

![Installer package for Ubuntu 22.04](https://assets.digitalocean.com/articles/java_apt_2204/javainstaller.png)

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](https://www.oracle.com/java/technologies/javase/jdk11-archive-downloads.html) and locate the version that matches the one you need.

![The Oracle Java archive downloads web page where you can find versions of Java that are not the latest release.](https://deved-images.nyc3.digitaloceanspaces.com/CTM-571/java-11-archive-downloads.PNG)

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

![Linux download](https://assets.digitalocean.com/articles/java_apt_2204/java-download.png)

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](https://docs.microsoft.com/en-us/windows/wsl/install-win10), 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.

### [Step 2 — Managing Java](https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-on-ubuntu-22-04#step-2-managing-java)

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`.

### [Step 3 — Setting the `JAVA_HOME` Environment Variable](https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-on-ubuntu-22-04#step-3-setting-the-java_home-environment-variable)

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`.
3.

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&#x20;

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

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

</code></pre>

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

{% embed url="<https://www.cherryservers.com/blog/how-to-install-and-setup-postgresql-server-on-ubuntu-20-04>" %}

```
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` :

```sql
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**

```sql
// 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`

{% embed url="<https://tableplus.com/blog/2018/04/postgresql-how-to-grant-access-to-users.html>" %}

```
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

{% embed url="<https://www.elastic.co/guide/en/elasticsearch/reference/7.17/rpm.html#install-rpm>" %}

<pre><code>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


<strong>sudo vi /etc/sysconfig/elasticsearch
</strong>// 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
</code></pre>

### 2.3 Setup dotCms

{% embed url="<https://www.dotcms.com/docs/latest/installing-from-release>" %}

2.3.1. create database postgre called **dotcms**&#x20;

```
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**&#x20;

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


```

![](/files/28B38XvIzbKbUCMZQcNf)

```
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
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://tritueviet.gitbook.io/server/linux/dotcms-manual-setup.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
