前提条件
OS: CentOS7.8(7.8.2003)
Minimalインストール、SELinuxは無効
必要なパッケージのインストール
sudo yum -y install wget unzip python36
Gitのインストール
sudo yum -y install git
.Net Coreのインストール
sudo rpm -Uvh https://packages.microsoft.com/config/rhel/7/packages-microsoft-prod.rpm sudo yum -y update sudo yum -y install dotnet-sdk-3.1
GDI+のインストール
sudo yum install -y epel-release sudo yum install -y libgdiplus
PostgreSQLの設定
PostgreSQLのインストールとデータベースの初期化
sudo yum -y localinstall https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm sudo yum -y install postgresql12-server postgresql12-contrib /usr/pgsql-12/bin/postgresql-12-setup initdb
PostgreSQLへのアクセス設定
PostgreSQLへアクセスできるホストの設定と認証方式を設定します。以下の設定では同じネットワーク内からMD5でアクセスができるようにしてあります。
vi /var/lib/pgsql/12/data/pg_hba.conf
# "local" is for Unix domain socket connections only # local all all peer local all all peer # IPv4 local connections: host all all 127.0.0.1/32 md5 # IPv6 local connections: host all all ::1/128 md5 # Allow replication connections from localhost, by a user with the # replication privilege. local replication all peer host replication all 127.0.0.1/32 md5 host replication all ::1/128 md5 host all all <許可するネットワークアドレス>/24 md5
PosegreSQLログファイルの設定
/var/log/postgresにログファイルを出力するように設定します。
mkdir -p /var/log/postgres chown postgres.postgres /var/log/postgres vi /var/lib/pgsql/12/data/postgresql.conf
listen_addresses = '*' port = 5432 log_destination = 'stderr' log_directory = '/var/log/postgres' log_filename = 'postgresql-%Y%m%d.log' log_truncate_on_rotation = on log_rotation_age = 1d log_line_prefix = '[%t]%u %d %p[%l]'
自動起動の設定
sudo systemctl enable postgresql-12
PostgreSQLの起動
sudo systemctl start postgresql-12
postgresユーザのパスワード設定
passwd postgres ユーザー postgres のパスワードを変更。 新しいパスワード:<パスワード> 新しいパスワードを再入力してください:<パスワード> passwd: すべての認証トークンが正しく更新できました。
データベースへの接続
postgresユーザでログインし、データベースに接続します。
su - postgres psql
パスワード設定と、データベースならびに全文検索用モジュールの作成
postgres=# alter role postgres with password '<postgresユーザのパスワード>'; ALTER ROLE postgres=# create database "Implem.Pleasanter"; CREATE DATABASE postgres=# \c "Implem.Pleasanter"; データベース"Implem.Pleasanter"にユーザ"postgres"として接続しました。 Implem.Pleasanter=# CREATE EXTENSION pg_trgm; CREATE EXTENSION Implem.Pleasanter=# \q
exit
Pleasanterのインストール
Pleasanterのダウンロード
以下のURLへアクセスし、.Net Core版のファイルをダウンロードし、ダウンロードしたファイルをサーバへアップロードします。(以下の説明では/tmpにアップロードされていることとしています。)
ダウンロードしたファイルの展開と配置
/opt/pleasanterにファイルを展開します。
cd /tmp unzip Pleasanter.NetCore_1.1.6.0.zip mv pleasanter /opt
Pleasanterのデータベース接続設定
vi /opt/pleasanter/Implem.Pleasanter/App_Data/Parameters/Rds.json
{ "Dbms": "PostgreSQL", "Provider": "Local", "TimeZoneInfo": "Tokyo Standard Time", "SaConnectionString": "Server=localhost;Port=5432;Database=postgres;UID=postgres;PWD=<postgresユーザのパスワード>", "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 }
CodeDefinerの実行
新規構築の場合
新しくサーバを構築する場合には以下の手順を実行してください。
cd /opt/pleasanter/Implem.CodeDefiner dotnet Implem.CodeDefiner.NetCore.dll _rds
以下のようなメッセージが出力されることを確認してください。
Starter.ConfigureDatabase: Database configuration has been completed. Starter.Main: All of the processes have been completed.
Windows版のSQLServerからマイグレーションを行う場合
SQLServerからマイグレーションを行うために以下の手順を実行してください。
vi /opt/pleasanter/Implem.Pleasanter/App_Data/Parameters/Migration.json
{ "SourceConnectionString": "Server=<SQLサーバのIPアドレス>;Database=Implem.Pleasanter;UID=sa;PWD=<saユーザのパスワード>;", "ExcludeTables": [ "SysLogs" ] }
cd /opt/pleasanter/Implem.CodeDefiner dotnet Implem.CodeDefiner.NetCore.dll migrate
起動確認
cd ../Implem.Pleasanter dotnet Implem.Pleasanter.NetCore.dll warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35] No XML encryptor configured. Key {7abf6f84-b144-4a70-9b76-b88ef4bbc7f0} may be persisted to storage in unencrypted form.
別のターミナルを起動し、以下のコマンドを実行します。
curl -v http://localhost:5000/
以下のようなレスポンスが帰ってくることを確認します。
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: Fri, 09 Oct 2020 05:31:21 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
dotnet Implem.Pleasanter.NetCore.dllを実行したターミナルに移動し、Ctrl+Cで終了させます。
サービス用スクリプトの作成
vi /etc/systemd/system/pleasanter.service
[unit] Description = Pleasanter Documentation = Wants=network.target After=network.target [Service] ExecStart = /usr/bin/dotnet Implem.Pleasanter.NetCore.dll WorkingDirectory = /opt/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
サービスの登録と自動起動の設定
sudo systemctl daemon-reload sudo systemctl enable pleasanter sudo systemctl start pleasanter
リバースプロキシ(Nginx)の設定
リポジトリの作成
vi /etc/yum.repos.d/nginx.repo
[nginx] name=nginx repo baseurl=http://nginx.org/packages/mainline/centos/7/$basearch/ gpgcheck=0 enabled=1
Nginxのインストール
sudo yum -y install nginx sudo yum -y update
リバースプロキシ設定ファイルの作成
vi /etc/nginx/conf.d/pleasanter.conf
server { listen 80; server_name <ホスト名>; 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; } }
自動起動の設定とNginxの起動
systemctl enable nginx Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service. systemctl start nginx
Firewallの設定
sudo firewall-cmd --permanent --zone=public --add-service=http sudo firewall-cmd --reload
SELinuxのポリシー設定
sudo setsebool httpd_can_network_connect on -P
リマインダの設定
設定ファイルの変更
vi /opt/pleasanter/Tools/Reminder.py
!/usr/bin/env python3 import urllib.request import ssl import time from datetime import datetime while True: try: urllib.request.urlopen( urllib.request.Request("http://<ホスト名>/pleasanter/reminderschedules/remind?NoLog=1") , context=None) #If you must use TLS, change 'None' to 'ssl.SSLContext(ssl.PROTOCOL_TLS)'. print(str(datetime.now()) + ": success") except Exception as e: print(str(datetime.now()) + ": " + str(e)) time.sleep(5)
cronの設定
sudo crontab -e
以下の内容を記入しファイルを保存します。
@reboot python3 /opt/pleasanter/Tools/Reminder.py
サーバの再起動
サーバを再起動します。
reboot
動作確認
ブラウザで、http://<ホスト名> にアクセスを行います。以下の画面が表示されることを確認します。

ログインユーザ:Administrator、パスワード: plesanterを入力しログインボタンをクリックします。ログインに成功すると以下のようなパスワードの変更画面が表示されます。

新しいパスワードを入力して[変更]ボタンをクリックします。以下のような画面が表示されることを確認します。
