Install Pleasanter on Ubuntu
## Overview
This manual provides instructions for building a Pleasanter operating environment in the environment shown below.
|Target |Content|
|---|---|
|OS|Ubuntu 22.04|
|DB|PostgreSQL 16|
|Web Server|nginx 1.20.1|
|Platform|.NET 8.0|
|Pleasanter|Pleasanter 1.4|
## Prerequisites
1. It does not describe how to set up the OS. It is assumed that the OS has been set up in advance.
1. Click here for details on the operating environment and specifications.
[FAQ: I want to know the operating environment and recommended specifications for Pleasanter](faq-recommended-specifications)
1. Please decide in advance which user will launch Pleasanter. The **User who launches Pleasanter** mentioned in the procedure refers to this user.
1. This procedure explains the case where .NET is installed in /usr/local/bin. If you need multiple versions of .NET in the same environment, or if you want to install .NET in a different directory, change the directory specified in ExecStart when running CodeDefiner or creating a script for the Pleasanter service to match the installation destination.
## Procedure
The construction procedure is as follows.
1. Setup .NET
1. Setup PostgreSQL
1. Install PostgreSQL
1. Configure PostgreSQL users
1. Configure PostgreSQL log output
1. Restart the PostgreSQL service and make it a service
1. Configure to allow external access to the database
1. Set up Pleasanter
1. Prepare the application
1. Configure the database
1. Run CodeDefiner
1. Check Pleasanter's operating status
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. Install nginx
1. Configure the reverse proxy
1. Allow access to 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 details, please refer to Script Installation on the official page below.
https://learn.microsoft.com/en-us/dotnet/core/install/linux-scripted-manual#scripted-install
Additionally, there are cases where an error regarding a specific file occurs when executing the dotnet command. In that case, please refer to the page below.
https://learn.microsoft.com/en-us/dotnet/core/install/linux-package-mixup?pivots=os-linux-ubuntu
## 2. Setup PostgreSQL
### 1. Install PostgreSQL
Run the following command to install PostgreSQL.
```
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt install -y postgresql postgresql-contrib
```
### 2. Configure PostgreSQL users
1. Execute the following command to set a password for the PostgreSQL management user "postgres" (OS user).
After executing the command, a password entry prompt will appear, so enter your password.
```
sudo passwd postgres
```
2. Execute the following command to log in to PostgreSQL.
```
sudo su - postgres
psql -U postgres
```
3. Execute the following command to set the password for the PostgreSQL administrative user "Postgres".The password you set here will be used in step 3.2, so please make a note of it.
```
postgres=# alter role postgres with password '<new password>';
```
### 3. Configure PostgreSQL log output
Open /etc/postgresql/16/main/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
Execute the following commands to restart the PostgreSQL service and enable automatic service startup.
```
sudo systemctl restart postgresql
sudo systemctl enable postgresql
```
### 5. Configure to allow external access to the DB
1. Uncomment the following two lines in /etc/postgresql/16/main/postgresql.conf and configure as shown below.
```
# - Connection Settings -
listen_addresses = '*' # what IP address(es) to listen on;
port = 5432 # (change requires restart)
```
2. Add the following line to /etc/postgresql/16/main/pg_hba.conf. In the Address field, specify the range of IP addresses to allow access.
```
# TYPE DATABASE USER ADDRESS METHOD
host all all 192.168.1.0/24 scram-sha-256
```
3. After setting, execute the following command to restart the PostgreSQL service.
```
sudo systemctl restart postgresql
```
## 3. Setup Pleasanter
### 1. Prepare the application
1. Execute the following command to create a "web" directory in the root directory ("/").
```
sudo mkdir /web
```
2. Download the latest version of Pleasanter from the [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/jp/).
4. Execute the following command to change the owner of Pleasanter directory to the user who will start Pleasanter.
```
sudo chown -R <User who launches Pleasanter> /web/pleasanter
```
### 2. Configure the 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.3. 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
Execute the following command to run CodeDefiner as the predetermined user who will start the preparer.
```
cd /web/pleasanter/Implem.CodeDefiner
sudo -u <User who launches Pleasanter> /usr/local/bin/dotnet Implem.CodeDefiner.dll _rds
```
### 4. Check Pleasanter's operating status
1. Execute the following command to start Pleasanter as a predetermined user.
```
cd /web/pleasanter/Implem.Pleasanter
sudo -u <User who launches Pleasanter> /usr/local/bin/dotnet Implem.Pleasanter.dll
```
2. Run the following command in another terminal during startup to confirm that the Pleasanter is started. Exit with "Ctrl+C".
* Execution command
```
curl -v http://localhost:5000/
```
* Execution result
```
* Trying 127.0.0.1:5000...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 5000 (#0)
> GET / HTTP/1.1
> Host: localhost:5000
> User-Agent: curl/7.68.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 302 Found
< Date: Tue, 23 Feb 2021 09:04:33 GMT
< Server: Kestrel
< Content-Length: 0
< 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 a script for the Pleasanter service
Create /etc/systemd/system/pleasanter.service with the following content. For **User** below, specify the user who will start 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 launches Pleasanter>
Group = root
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false
[Install]
WantedBy = multi-user.target
```
### 6. Register as a service and start the service
Execute the following command to enable service startup and automatic service startup of Pleasanter.
```
sudo systemctl daemon-reload
sudo systemctl enable pleasanter
sudo systemctl start pleasanter
```
## 4. Setup Reverse Proxy (nginx)
Configure the reverse proxy so that it can be accessed using the same Port80 as a regular web server.
### 1. Install nginx
Run the following command to install nginx.
```
sudo apt install -y nginx
sudo systemctl enable nginx
```
### 2. Configure the reverse proxy
1. Create /etc/nginx/conf.d/pleasanter.conf with the following content. In the server_name line, specify the hostname or IP address of the server you will 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
```
### 3. Allow access to Http(80)
Execute the following command to set access permission to Http (port:80) to allow the client to access the web service.
```
sudo ufw allow 80/tcp
sudo ufw enable
sudo ufw status numbered
```
## 5. Check Pleasanter's Operating Status
1. After launching Pleasanter, enter "Login ID: Administrator" and "Initial Password: pleasanter" on the Pleasanter login screen and click the "Login" button.
![image](https://pleasanter.org/binaries/701aa1fcb8624addb3b7548d784c78a8)
2. After logging in, you will be asked to change the "Administrator" user password. Enter a password of your choice and click the "Change" button.
![image](https://pleasanter.org/binaries/828abdab28da428cb3f9f1bce1c43db0)
### If you are not redirected correctly
Please check whether the nginx settings are correct. The behavior may change depending on small differences such as the presence or absence of "/" in the description.
### If the Pleasanter screen does not open
Even though the steps above have been completed without any errors, if you access a page with your browser that says "Welcome to nginx!" (not an error message), the browser's security settings may prevent you from transitioning to the Pleasanter login screen.
Please check your browser's security settings.
## 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)