FAQ: I want to install Pleasanter using Apache as my web server
## Prerequisites
1. We will not cover 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 see here.
[FAQ: I want to know the operating environment and recommended specifications for Pleasanter](faq-recommended-specifications)
## Overview
This explanation shows the steps to build a Pleasanter operating environment in the environment shown below.
|Target|Contents|
|---|---|
|OS|Red Hat Enterprise Linux 9.1|
|DB|PostgreSQL 14|
|Web server|Apache|
|Platform|.NET 6.0|
|Pleasanter|Pleasanter 1.3.37.0|
## Operation Procedure
### 1. Install .NET6.0
#### Install ASP.NET Core Runtime
```bash
sudo dnf install aspnetcore-runtime-6.0
```
#### Install GDI+
```bash
sudo dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
sudo dnf install -y libgdiplus
```
### 2. Set up PostgreSQL
#### Register Package Repository
```bash
sudo dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
```
#### Install PostgreSQL
```bash
sudo dnf module -y disable postgresql
sudo dnf install -y postgresql14-server postgresql14-contrib
```
#### Initialize The Database
```bash
sudo su - postgres -c '/usr/pgsql-14/bin/initdb -E UTF8 -A scram-sha-256 -W'
```
Additional information:
- -A: Specify the authentication method
- -W: Option to display the password prompt
- Specify the password for the Postgres user of the DB at this point
#### Log output settings
Open /var/lib/pgsql/14/data/postgresql.conf and set the following.
```conf
log_destination = 'stderr'
logging_collector = on
log_line_prefix = '[%t]%u %d %p[%l]'
```
*Log files are saved in /var/lib/pgsql/14/data/log.
#### Enable The Service
```bash
sudo systemctl enable postgresql-14
```
#### PostgreSQL User Settings For The OS
Set a password for the PostgreSQL administration user Postgres (OS user).
```bash
sudo passwd postgres
```
#### Install The Full-text Search Module (pg_trgm)
Install the module (pg_trgm) required for full-text search of text.
1. Switch to user Postgres and connect to PostgreSQL.
```bash
su - postgres
psql -U postgres
```
2. Create database Implem.Pleasanter.
```sql
create database "Implem.Pleasanter";
```
3. Switch to database Implem.Pleasanter.
```sql
\c "Implem.Pleasanter";
```
4. Install pg_trgm.
```sql
create extension pg_trgm;
```
#### Settings For Allowing External Access To The DB
1. Uncomment the following two lines in /var/lib/pgsql/14/data/postgresql.conf and set them as follows.
```conf
# - 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/14/data/pg_hba.conf.
In the Address field, specify the range of IP addresses to allow access.
```conf
# TYPE DATABASE USER ADDRESS METHOD
host all all 192.168.1.0/24 scram-sha-256
```
3. After setting, restart the PostgreSQL service.
```bash
sudo systemctl restart postgresql-14
```
### 3. Installing Pleasanter 1.3
#### Preparing The Application
Download [Pleasanter 1.3](https://pleasanter.org/dlcenter).
Create a "/web" folder in the root directory ("/") and put the "pleasanter" folder there.
- /web/pleasanter/Implem.Pleasanter
- /web/pleasanter/Implem.CodeDefiner
- /web/pleasanter/Tools
#### Database Configuration
1. Set /web/pleasanter/Implem.Pleasanter/App_Data/Parameters/Rds.json as follows.
```json
{
"Dbms": "PostgreSQL",
"Provider": "Local",
"TimeZoneInfo": "Asia/Tokyo",
"SaConnectionString":"Server=localhost;Port=5432;Database=postgres;UID=postgres;PWD={The password which you set}",
"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
}
```
1. Run CodeDefiner
```bash
cd /web/pleasanter/Implem.CodeDefiner
dotnet Implem.CodeDefiner.dll _rds
```
1. Start Pleasanter
```bash
cd /web/pleasanter/Implem.Pleasanter
dotnet Implem.Pleasanter.dll
```
1. Access http://localhost:5000/ in another terminal and confirm that a normal response is returned.
```bash
curl -v http://localhost:5000/
```
Response example
```text
* About to connect() to localhost port 5000 (#0)
* Trying ::1...
* Connected to localhost (::1) port 5000 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.29.0
> Host: localhost:5000
> Accept: */*
>
< HTTP/1.1 302 Found
< Date: Mon, 25 May 2020 15:13:08 GMT
< Server: Kestrel
< Content-Length: 0
< Location: http://localhost:5000/users/login?ReturnUrl=%2F
```
Once you have confirmed it, press Ctrl+C to exit.
#### Creating A Script For The Pleasanter Service
Create /etc/systemd/system/pleasanter.service with the following content.
```text
[Unit]
Description = Pleasanter
Documentation =
Wants=network.target
After=network.target
[Service]
ExecStart = /usr/bin/dotnet Implem.Pleasanter.dll (※1)
WorkingDirectory = /web/pleasanter/Implem.Pleasanter
Restart = always
RestartSec = 10
KillSignal=SIGINT
SyslogIdentifier=dotnet-pleasanter
User = root
Group = root
Environment=ASPNETCORE_ENVIRONMENT=Production
Environment=DOTNET_PRINT_TELEMETRY_MESSAGE=false
[Install]
WantedBy = multi-user.target
```
**(*1)**
This example is for Red Hat Enterprise Linux 8. If you are using other versions, check the PATH of the dotnet command and change it to match your environment. You can check the execution path of dotnet by executing the following command.
```bash
whereis -b dotnet
```
For example, if the result of executing the above command is /usr/local/bin/dotnet, the line (*1) must be set as follows.
```text
ExecStart = /usr/local/bin/dotnet Implem.Pleasanter.dll
```
#### Register as a service and start the service
```bash
sudo systemctl daemon-reload
sudo systemctl enable pleasanter
sudo systemctl start pleasanter
```
#### Setting Up A Reverse Proxy (Apache)
Set up the reverse proxy so that it can be accessed via Port 80, the same as a normal web server.
##### Installing Apache
Install Apache with the following command.
```
dnf install -y httpd
systemctl enable httpd
```
##### Reverse Proxy Settings
Add the following to the last line of /etc/httpd/conf/httpd.conf.
```
ProxyRequests Off
ProxyPass / http://localhost:5000/
ProxyPassReverse / http://localhost:5000/
```
After adding the file, restart Apache.
```
systemctl restart httpd
```
##### Access Permission To Port 80
Set access permission to http (port: 80) to allow clients to access the web service.
The settings differ depending on each environment, so please check as appropriate.
### 4. Other settings
#### Initial Account
Login ID: The administrator is created as the initial user.
The initial user password is pleasanter by default. A password change dialog will be displayed when you log in for the first time, so please set a password of your choice.
This password can be specified in /web/pleasanter/Implem.Pleasanter/App_Data/Parameters/Service.json with DefaultPassword.
## プリザンター バージョン 1.3.7.0以降でリマインダー機能を有効化する手順
[BackgroundService.json](/ja/manual/background-service-json)および[Service.json](/ja/manual/service-json)のパラメータ設定値を変更してください。なお、パラメータ変更時はマニュアル[パラメータ変更時の確認事項](/ja/manual/parameter-edit)をご確認ください。
#### BackgroundService.json
マニュアル[パラメータ設定:BackgroundService.json](/ja/manual/background-service-json)を参照し、BackgroundService.jsonファイル内の設定を下記の設定値に変更してください。
|項目|設定例|説明|
|:--|:--|:--|
|Reminder|true|リマインダー機能の有効化|
#### Service.json
マニュアル[パラメータ設定:Service.json](/ja/manual/service-json)を参照し、Service.jsonファイル内の設定を下記の設定値に変更してください。
|項目|設定例|説明|
|:--|:--|:--|
|AbsoluteUri|"http://pleasanter.example.local"|通知やリマインダーに記載されるURLの先頭部分を記入してください。(nullは使えません。)|
#### Database Migration
For instructions on migrating from SQL Server to PostgreSQL, please refer to the following manual.
[Migration Procedure from Pleasanter's DB from SQL Server to PostgreSQL](migrate-sql-server-to-postgresql)