Install Pleasanter on Red Hat Enterprise Linux 9 Using the Installer
## Overview
This procedure is for building a Pleasanter operating environment using the "Installer". You can also install it using the previous procedure of manually placing modules and setting parameters. Please refer to the following for manual installation procedures.
[Install Pleasanter on Red Hat Enterprise Linux 9](getting-started-pleasanter-rhel)
|Target|Body|
|---|---|
|OS|Red Hat Enterprise Linux 9.2|
|DB|PostgreSQL 16.1|
|Web Server|nginx 1.24.0|
|Platform|.NET 8.0|
|Pleasanter|Pleasanter 1.4|
## Limitations
Installation using the "Installer" is for version 1.4.0.0 and later. Please refer to the manual installation procedures when installing version 1.3.50.2 or earlier.
[Install Pleasanter on Red Hat Enterprise Linux 9](getting-started-pleasanter-rhel)
## Prerequisites
1. We will not describe how to set up the OS. We assume that the OS has already been set up.
1. For details on the operating environment and specifications, please check here.
[FAQ: I want to know the operating environment and recommended specifications for Pleasanter](faq-recommended-specifications)
1. Decide in advance the user who will execute Pleasanter. The **<User who will execute Pleasanter>** mentioned in the procedure refers to this user.
## Procedure
The construction procedure is as follows.
1. Set up .NET
1. Set up PostgreSQL
1. Install PostgreSQL
1. Initialize the database
1. Set up PostgreSQL log output
1. Restart the PostgreSQL service and enable it as a service
1. Set for allowing external access to the database
1. Install the installer
1. Set up Pleasanter
1. Prepare the application
1. Check that Pleasanter is running
1. Create a script for the Pleasanter service
1. Register as a service and start the service
1. Set up a reverse proxy (nginx)
1. Change SELinux settings
1. Install nginx
1. Set up the reverse proxy
1. Allow access to Http(80)
1. Check that Pleasanter is running
## 1. Set up .NET
Run the following command to install .NET.
```
sudo wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh
sudo chmod +x ./dotnet-install.sh
sudo ./dotnet-install.sh -c 8.0 -i /usr/local/bin
dotnet --version
```
For details, please refer to the official page below, **Installation by script**.
https://learn.microsoft.com/en-us/dotnet/core/install/linux-scripted-manual#scripted-install
Also, there are cases where an error occurs regarding a specific file when executing the dotnet command. In that case, please refer to the following page.
https://learn.microsoft.com/en-us/dotnet/core/install/linux-package-mixup?pivots=os-linux-redhat
## 2. Set up PostgreSQL
### 1. Install PostgreSQL
Execute the following command to install PostgreSQL.
```
sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-x86_64/pgdg-redhat-repo-latest.noarch.rpm
sudo dnf install -y postgresql16-server postgresql16-contrib
```
### 2. Initialize the database
Execute the following command to initialize the database. * -A: Specify authentication method, -W: Option to display password input prompt
After execution, a password input prompt will be displayed, so enter your password. The password set here will be used in step 3.2, so please make a note of it so you do not forget it.
```
sudo su - postgres -c '/usr/pgsql-16/bin/initdb -E UTF8 -A scram-sha-256 -W'
```
### 3. Set up PostgreSQL log output
Open /var/lib/pgsql/16/data/postgresql.conf and edit the following settings.
```
log_destination = 'stderr'
logging_collector = on
log_line_prefix = '[%t]%u %d %p[%l]'
```
### 4. Restart the PostgreSQL service and enable it as a service
Execute the following commands to restart the PostgreSQL service and enable automatic service startup.
```
sudo systemctl restart postgresql-16
sudo systemctl enable postgresql-16
```
### 5. Set for allowing external access to the database
1. Uncomment the following two lines in /var/lib/pgsql/16/data/postgresql.conf and set them as follows:
```
# - Connection Settings -
listen_addresses = '*' # what IP address(es) to listen on;
port = 5432 # (change requires restart)
```
2. Add the following line to /var/lib/pgsql/16/data/pg_hba.conf. In the Address field, specify the range of IP addresses that are allowed access.
```
# TYPE DATABASE USER ADDRESS METHOD
host all all 192.168.1.0/24 scram-sha-256
```
3. After the settings are complete, run the following command to restart the PostgreSQL service.
```
sudo systemctl restart postgresql-16
```
## 3. Install the Installer
Execute the following command to install the installer.
```
dotnet tool install -g Implem.PleasanterSetup
echo 'export PATH="$PATH:~/.dotnet/tools"' >> ~/.bashrc
echo 'export DOTNET_ROOT=/usr/local/bin' >> ~/.bashrc
echo 'export PATH=$PATH:$DOTNET_ROOT' >> ~/.bashrc
source ~/.bashrc
```
### If you are not connected to a network environment, please install using the following procedure.
<details>
<summary>(Click here to open/close the details) </summary>
1. Open the Nuget Gallery for Implem.PleasanterSetup from [here](https://www.nuget.org/packages/Implem.PleasanterSetup/) and download the .nupkg file from "Download package".

1. Execute the following command to create a folder of your choice to place the .nupkg file.
※This procedure explains how to create /dotnet-tools.
```
sudo mkdir /dotnet-tools
```
1. Place the .nupkg file downloaded in 3.1 in /dotnet-tools.
1. Run the following command to install the installer.
```
dotnet tool install -g --add-source /dotnet-tools Implem.PleasanterSetup
echo 'export PATH="$PATH:~/.dotnet/tools"' >> ~/.bashrc
echo 'export DOTNET_ROOT=/usr/local/bin' >> ~/.bashrc
echo 'export PATH=$PATH:$DOTNET_ROOT' >> ~/.bashrc
source ~/.bashrc
```
</details>
## 4. Set up Pleasanter
*Using the installer will automatically download the latest version resources and automatically set the values in Service.json and Rds.json based on the values you enter.
1. Run the installer by executing the following command.
```
pleasanter-setup
```
**If you are not connected to a network environment, please follow the steps below**
<details>
<summary>(Click here to open/close the details) </summary>
1. Download the latest version of Pleasanter from the [Download Center](https://pleasanter.org/dlcenter) and place it in "/web/".
1. Execute the following command.
**/web/** Make sure that the directory structure is as follows:
/web/Pleasanter_1.4.x.x.zip
```
pleasanter-setup -r /web/Pleasanter_1.4.x.x.zip
```
</details>
2. Enter the directory where you want to install Pleasanter.
If you want to install it in "/web/pleasanter", leave it blank and press the Enter key.

3. Enter **<User who will execute Pleasanter>**.

4. Enter the service name.
If you want to install it in "Implem.Pleasanter", leave it blank and press the Enter key.

5. Enter the number corresponding to the DBMS you want to use.
Here, enter "2" and press the Enter key.

6. Enter the port number to be used.
If it is the default port number for the DBMS, leave it blank and press the Enter key.

7. Enter the value to be set in Server in the connection string.
If it is "localhost", leave it blank and press the Enter key.

8. Enter the value to be set in UID of SaConnectionString.
If it is "postgres", leave it blank and press the Enter key.

9. Enter the value to be set in PWD of SaConnectionString.
※The password will be displayed in a masked state.

10. Enter the value to be set in PWD of OwnerConnectionString.
※The password will be displayed in a masked state.

11. Enter the value to be set in PWD of UserConnectionString.
※The password will be displayed in a masked state.

12. Enter the "Default language".
Enter the number of the corresponding language.

13. Enter the time zone for "Default time zone".
Enter the number of the corresponding time zone.
※If you entered "3", enter the time zone available on the OS you are using.

14. The summary screen will be displayed.
If the values you entered are correct, enter **y** after "Shall I install Pleasanter with this content? Please enter 'y(yes)' or 'n(no)'. : " and press Enter.
※The password is masked.

15. When you see the message "Type "y" (yes) if the license is correct, otherwise type "n" (no)," enter **y** and proceed.
When the following log is displayed, the setup is complete.
```
<SUCCESS> Starter.ConfigureDatabase: Database configuration has been completed.
<SUCCESS> Starter.Main: All of the processes have been completed.
Setup is complete.
```
16. When setup is complete, a web browser will launch and display the [Enterprise Edition trial information page](https://pleasanter.org/pleasanter-extensions-trial/?utm_source=installer&utm_medium=app&utm_campaign=extension-trial&utm_content=route01).

### 2. Check that Pleasanter is running
1. Run the following command to start Pleasanter with the specified user.
```
cd /web/pleasanter/Implem.Pleasanter
sudo -u <User who will execute Pleasanter> /usr/local/bin/dotnet Implem.Pleasanter.dll
```
2. While it is running, execute the following command in another terminal to confirm that Pleasanter is running. Exit with "Ctrl+C".
* Execution command
```
curl -v http://localhost:5000/
```
* Execution result
```
* Trying ::1:5000...
* Connected to localhost (::1) port 5000 (#0)
> GET / HTTP/1.1
> Host: localhost:5000
> User-Agent: curl/7.76.1
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 302 Found
< Content-Length: 0
< Date: Tue, 25 Jul 2023 02:42:19 GMT
< Server: Kestrel
< Location: http://localhost:5000/users/login?ReturnUrl=%2F
< X-Frame-Options: SAMEORIGIN
< X-XSS-Protection: 1; mode=block
< X-Content-Type-Options: nosniff
<
* Connection #0 to host localhost left intact
```
### 3. Create a script for the Pleasanter service
Create /etc/systemd/system/pleasanter.service with the following content. For **User** below, specify the user who will execute Pleasanter.
```
[Unit]
Description = Pleasanter
Documentation =
Wants=network.target
After=network.target
[Service]
ExecStart = /usr/local/bin/dotnet Implem.Pleasanter.dll
WorkingDirectory = /web/pleasanter/Implem.Pleasanter
Restart = always
RestartSec = 10
KillSignal=SIGINT
SyslogIdentifier=dotnet-pleasanter
User = <User who will execute Pleasanter>
Group = root
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false
[Install]
WantedBy = multi-user.target
```
### 4. Register as a service and start the service
Execute the following command to enable Pleasanter service startup and automatic service startup.
```
sudo systemctl daemon-reload
sudo systemctl enable pleasanter
sudo systemctl start pleasanter
```
## 5. Set Up a Reverse Proxy (nginx)
Configure the reverse proxy so that it can be accessed via Port 80, the same as a normal web server.
### 1. Change SELinux settings
Execute the following command.
```
getenforce
```
#### a. If "Command 'getenforce' not found.", "Permissive" or "Disabled" is displayed
Proceed to "2. Install nginx".
#### b. If "Enforcing" is displayed
Execute the following command.
```
sudo setsebool -P httpd_can_network_connect on
```
*Changing the above SELinux Boolean values will allow all network connections via scripts and modules on the server.
### 2. Install nginx
Execute the following command to install nginx.
```
sudo dnf install -y nginx
sudo systemctl enable nginx
```
### 3. Set up the reverse proxy
1. Create /etc/nginx/conf.d/pleasanter.conf with the following contents. In the server_name line, specify the host name or IP address of the server you want to access.
```
server {
listen 80;
server_name 192.168.1.100;
client_max_body_size 100M;
location / {
proxy_pass http://localhost:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
```
2. After creating the file, run the following command to restart the service.
```
sudo systemctl restart nginx
```
## 6. Check the Operation of Pleasanter
1. After starting Pleasanter, enter "Login ID: Administrator" and "Initial password: pleasanter" on the Pleasanter login screen and click the "Login" button.

2. After logging in, you will be asked to change the password for the "Administrator" user, so enter a password of your choice and click the "Change" button.

### If redirection is not correct
Please check that the nginx settings are correct. Operation may change depending on small differences such as the presence or absence of/in the description.
### If the Pleasanter screen does not open
If the above steps were completed without any errors, but a page such as "Welcome to nginx!" (not an error message) is displayed when you access it in a browser, the security settings of the browser may be preventing you from transitioning to the Pleasanter login screen.
Please check the security settings of your browser.
## Related Information
[FAQ: I want to install Pleasanter 1.3.43.0 or earlier in a Linux environment with PostgreSQL version 14 or earlier.](faq-postgresql-14-intall-pleasanter-for-linux)