Install Pleasanter on Red Hat Enterprise Linux 8
## Overview
This manual shows the steps for establishing an operating environment for the Pleasanter in the following environment.
|Target|Content|
|---|---|
|OS|Red Hat Enterprise Linux 8|
|DB|PostgreSQL 16|
|Web server|nginx 1.24|
|Platform|.NET 8.0|
|Pleasanter|Pleasanter 1.4|
## Prerequisite
1. This manual does not describe how to set up the OS. The OS is assumed to have been set up in advance.
1. For more information on the operating environment and specifications, please click here.
[FAQ: I want to know the operating environment and recommended specifications for Pleasanter](faq-recommended-specifications)
1. Decide on a user to launch the Pleasanter in advance. The **user who launches the Pleasanter** mentioned in the procedure refers to this user.
## Process
The construction procedure is as follows.
1. Setup .NET
1. Setup PostgreSQL
1. Install PostgreSQL
1. Format database
1. Setup PostgreSQL's log output
1. Restart PostgreSQL service and enable i
1. Setup for allowing external access to the DB
1. Setup Pleasanter
1. Prepare application
1. Configure database
1. Run CodeDefiner
1. Check Pleasanter's launching status
1. Create scripts for Pleasanter service
1. Launch service and register as a service
1. Setup reverse proxy (nginx)
1. Install nginx
1. Setup reverse proxy
1. Permit to access Http(80)
1. Check Pleasanter's operating status
## 1. Setup .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 more details, please refer to **script installation** section of the following page.
https://learn.microsoft.com/en-us/dotnet/core/install/linux-scripted-manual#scripted-install
In some cases, errors related to specific files occur when dotnet commands are run. 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. Setup PostgreSQL
### 1. Install PostgreSQL
Run the following command to install PostgreSQL.
```
sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
sudo dnf install -y postgresql16-server postgresql16-contrib
```
### 2. Format database
Run the following command to format the database. * -A: Specify authentication method, -W: Option to display password prompt.
After running the program, you will be asked to enter a password at the password prompt. The password set here will be used in step 3.2, so be sure to keep it in mind.
```
sudo su - postgres -c '/usr/pgsql-16/bin/initdb -E UTF8 -A scram-sha-256 -W'
```
### 3. Setup PostgreSQL's 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 PostgreSQL service and enable it
Run the following commands to enable PostgreSQL service restart and service auto-start.
```
sudo systemctl restart postgresql-16.service
sudo systemctl enable postgresql-16.service
```
### 5. Setup for allowing external access to the DB
1. Uncomment the following two lines in /var/lib/pgsql/16/data/postgresql.conf and setup as follows.
```
# - Connection Settings -
listen_addresses = '*' # what IP address(es) to listen on;
port = 5432 # (change requires restart)
```
2. Add the following lines to /var/lib/pgsql/16/data/pg_hba.conf. The Address field specifies the range of IP addresses to which access is allowed.
```
# TYPE DATABASE USER ADDRESS METHOD
host all all 192.168.1.0/24 scram-sha-256
```
3. After setting, restart the PostgreSQL service by executing the following command.
```
sudo systemctl restart postgresql-16
```
## 3. Setup Pleasanter
### 1. Prepare application
1. Run the following command to create a "web" directory in the root directory ("/").
```
sudo mkdir /web
```
2. Download the latest version of Pleasanter from [GitHub release notes](https://github.com/Implem/Implem.Pleasanter/releases).
3. Unzip the downloaded zip file and place each of the extracted "pleasanter" folders in the "/web" directory on the server using a file transfer application such as [WinSCP](https://winscp.net/eng/docs/introduction).
4. Run the following command to change the owner of the pleasanter directory to the user who will launch Pleasanter.
```
sudo chown -R <user who launches Pleasanter> /web/pleasanter
```
### 2. Configure database
Set /web/pleasanter/Implem.Pleasanter/App_Data/Parameters/Rds.json as follows.
```
{
"Dbms": "PostgreSQL",
"Provider": "Local",
"SaConnectionString": "Server=localhost;Port=5432;Database=postgres;UID=postgres;PWD=<2.2. Password set in>",
"OwnerConnectionString": "Server=localhost;Port=5432;Database=#ServiceName#;UID=#ServiceName#_Owner;PWD=SetAdminsPWD",
"UserConnectionString": "Server=localhost;Port=5432;Database=#ServiceName#;UID=#ServiceName#_User;PWD=SetUsersPWD",
"SqlCommandTimeOut": 600,
"MinimumTime": 3,
"DeadlockRetryCount": 4,
"DeadlockRetryInterval": 1000,
"DisableIndexChangeDetection": true,
"SysLogsSchemaVersion": 1
}
```
### 3. Run CodeDefiner
Run the following command to run CodeDifiner as the user who launches the pre-determined Pleasanter.
```
cd /web/pleasanter/Implem.CodeDefiner
sudo -u <user who launches Pleasanter> /usr/local/bin/dotnet Implem.CodeDefiner.dll _rds
```
### 4. Check Pleasanter's launching status
1. Run the following command to launch the Pleasanter as a predetermined user.
```
cd /web/pleasanter/Implem.Pleasanter
sudo -u <user who launches Pleasanter> /usr/local/bin/dotnet Implem.Pleasanter.dll
```
2. Confirm that the Pleasanter is running by executing the following commands in another terminal while it is running. Press "Ctrl+C" to exit.
* 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
```
### 5. Create scripts for Pleasanter service
Create /etc/systemd/system/pleasanter.service with the following contents. Specify the user who will launch Pleasanter in the **User** field below.
```
[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 launches Pleasanter>
Group = root
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false
[Install]
WantedBy = multi-user.target
```
### 6. Launch service and register as a service
Run the following commands to enable service launching and service auto launching for Pleasanter.
```
sudo systemctl daemon-reload
sudo systemctl enable pleasanter
sudo systemctl start pleasanter
```
## 4. Setup Reverse Proxy (nginx)
Setup the reverse proxy to allow access via Port 80, the same port as the normal web server.
### 1. Install nginx
Run the following command to install nginx.
```
sudo dnf install -y nginx
sudo systemctl enable nginx
```
### 2. Setup reverse proxy
1. Create /etc/nginx/conf.d/pleasanter.conf with the following contents. The server_name line specifies the hostname or IP address of the server to be actually accessed.
```
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
```
## 5. Check Pleasanter's Operating Status
1. After starting Pleasanter, enter "Login ID: Administrator" and "Initial Password: pleasanter" on the Pleasanter login screen, and click the "Login" button.
![image](https://pleasanter.org/binaries/5d215b66c15346ab8a9655ab8a6f42a4)
2. After logging in, you will be asked to change the "Administrator" user password. Enter your password and click the "Change" button.
![image](https://pleasanter.org/binaries/c93641ca74d542f38373b8dabc99ef9e)
### If the redirection is not correct
Please make sure that the nginx configuration is correct. Minor differences such as the presence or absence of "/" in the description may change the result.
### If the Pleasanter screen does not open
If you have completed the above steps without any errors, but when you access the site with your browser, you see a page that says "Welcome to nginx!" (not an error message), the security settings of the browser may be preventing you from proceeding 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)