将プレゼンター的WEB服务器设置为”Apache”的方法

首先

在Presenter中,我们使用了”nginx”作为WEB服务器,但现在有人希望使用”Apache”。根据手册,在下述环境中,我将说明在Presenter的WEB服务器上使用”Apache”的步骤。由于我是Linux初学者,可能会有一些不足之处,请在评论中指出。我将在下面作为”问题点” 向大家介绍我在操作过程中遇到的困难。
操作系统:RHEL9
EC2:Presenter服务器
RDS:PostgreSQL14

操作系统的建立

这次我们将使用60天的试用版,在iso文件上验证RHEL9。

    1. 请访问此处。

 

    1. 下载iso文件(本次下载的是“rhel-baseos-9.1-x86_64-dvd.iso”)。

 

    1. 将下载的iso文件放入机器并启动。

 

    1. 选择安装Red Hat Enterprise Linux并按Enter键。

 

    1. 选择语言(本次选择日语)。

 

    1. 在安装概述屏幕上确认安装位置(本次没有特别更改)。

 

    1. 注册账户信息(用户名:root 密码:XXXX(可选))。

 

    1. 开始安装。

 

    系统重新启动。

将Presenter安装到Red Hat Enterprise Linux操作系统上。

警告

基本上,不建议使用特权用户“root”进行操作!因此,请使用其他普通用户登录,并按照以下两种方法进行操作。

    • それぞれのコマンドの頭に「sudo」をつける。

 

    「su – 」コマンドで「root」ユーザーに切り替える。

以下是根据下面的手册安装”Apache”的步骤从这里开始。
在Red Hat Enterprise Linux上安装预演者。

安装.NET 6.0

安装.NET SDK

请下载 Binaries(本次下载的是 “dotnet-sdk-6.0.406-linux-x64.tar.gz”),并输入以下命令。

# cd
# mkdir -p $HOME/dotnet && tar zxf dotnet-sdk-6.0.406-linux-x64.tar.gz -C $HOME/dotnet
# echo 'export DOTNET_ROOT=$HOME/dotnet' >> .bash_profile
# echo 'export PATH=$PATH:$HOME/dotnet' >> .bash_profile
# sh .bash_profile

绊倒的重点

    • 「dotnet」フォルダがあると「mkdir」コマンド実行後エラーが発生します。

 

    →「dotnet」フォルダを削除することで解決済み。

GDI+的安装

# dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
# dnf install -y libgdiplus

安装PostgreSQL

安装代码仓库

# dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm

安装PostgreSQL

# dnf module -y disable postgresql
# dnf install -y postgresql14-server postgresql14-contrib

数据库初始化

# /usr/pgsql-14/bin/postgresql-14-setup initdb

服务激活

# systemctl enable postgresql-14

設定認證方法

打开 /var/lib/pgsql/14/data/pg_hba.conf 文件,并将 METHOD 列的设置更改如下。

# TYPE  DATABASE        USER            ADDRESS                 METHOD
# "local" is for Unix domain socket connections only
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

日志输出设置

打开/var/lib/pgsql/14/data/postgresql.conf文件,并进行以下设置。

log_destination = 'stderr'
logging_collector = on
log_line_prefix = '[%t]%u %d %p[%l]'

※ 日志文件将保存在 “/var/lib/pgsql/data/log” 中。

重新启动PostgreSQL服务

# systemctl restart postgresql-14

PostgreSQL用户配置

    PostgreSQL管理用のユーザー”postgres”(OSのユーザー)にパスワードを設定します。
# passwd postgres
    ユーザー”postgres”に切り替え、PostgreSQLへ接続します。
# su - postgres
# psql -U postgres
    PostgreSQLの管理ユーザー “postgres” のパスワードを設定します(「new password」には任意のパスワードを入力)。
postgres=# alter role postgres with password '<new password>';

创建用于展示的数据库。

    データベース “Implem.Pleasanter” を作成します。
postgres=# create database "Implem.Pleasanter";
    以下のコマンドで作成したDBの確認を行います。
postgres=# ¥l

安装全文搜索模块(pg_trgm)。

连接到名为”Implem.Pleasanter”的数据库,并安装必要的模块(pg_trgm)来进行全文搜索。

postgres=# ¥c "Implem.Pleasanter";
Implem.Preasanter=# create extension pg_trgm;

如果要允许外部访问数据库时的配置设置。

    /var/lib/pgsql/14/data/postgresql.conf の以下の2行のコメントを解除します。
# - Connection Settings -
listen_addresses = '*'  # what IP address(es) to listen on;
port = 5432             # (change requires restart)

将以下行添加到 /var/lib/pgsql/14/data/pg_hba.conf 文件中。在Address字段中,指定允许访问的IP地址范围。

# TYPE  DATABASE        USER            ADDRESS                 METHOD
host    all             all             192.168.1.0/24          md5

设定完成后,请重新启动PostgreSQL服务。

# systemctl restart postgresql-14

介绍Prezi演示软件

应用程序的准备

请下载演示文稿。

请为根目录(“/”)创建一个名为“/web”的文件夹,并将其放置在那里,然后在其中放置一个名为“pleasanter”的文件夹。
/web/pleasanter/Implem.Pleasanter
/web/pleasanter/Implem.CodeDefiner
/web/pleasanter/Tools

数据库的构成

将 /web/pleasanter/Implem.Pleasanter/App_Data/Parameters/Rds.json 文件进行以下配置。

{
    "Dbms": "PostgreSQL",
    "Provider": "Local",
    "SaConnectionString":"Server=localhost;Port=5432;Database=postgres;UID=postgres;PWD=<設定したパスワード>",
    "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": 0,
    "MinimumTime": 3,
    "DeadlockRetryCount": 4,
    "DeadlockRetryInterval": 1000
}

执行CodeDefiner

# cd /web/pleasanter/Implem.CodeDefiner
# dotnet Implem.CodeDefiner.dll _rds

绊脚点

    • 「dotnet」は「.NET SDKのインストール」項目でhomeディレクトリ配下のdotnetフォルダを設定しているため、フォルダ構成が異なる場合は絶対パスで入力します。

 

    →「/home/implem/dotnet/dotnet Implem.Pleasanter.dll _rds」にて実行することで解決済み。

Pleasnter的启动确认

# cd ../Implem.Pleasanter
# dotnet Implem.Pleasanter.dll

绊倒点

    • 「dotnet」のパスには「.NET SDKのインストール」項目でhomeディレクトリ配下のdotnetフォルダを設定しているため、フォルダ構成が異なる場合は絶対パスで入力します。

 

    →「/home/implem/dotnet/dotnet Implem.Pleasanter.dll _rds」にて実行することで解決済み。

在另一个终端中访问”http://localhost:5000/”,确认是否返回了正常的响应。

# 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: Mon, 25 May 2020 15:13:08 GMT
< Server: Kestrel
< Content-Length: 0
< Location: http://localhost:5000/users/login?ReturnUrl=%2F

如果确认完成,请按Ctrl+C结束。

制作更愉快的服务脚本

请根据以下内容创建 /etc/systemd/system/pleasanter.service 的文件。

[Unit]
Description = Pleasanter
Documentation =
Wants=network.target
After=network.target

[Service]
ExecStart = /home/implem/dotnet/dotnet Implem.Pleasanter.dll
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

注册和启动服务

# systemctl daemon-reload
# systemctl enable pleasanter
# systemctl start pleasanter

修改逆向代理(Apache)的設置

我們將對反向代理進行設定,以便可以在通常的Web服務器上使用Port 80進行訪問。

安装Apache

用以下的命令来安装Apache。

# dnf install -y httpd
# systemctl enable httpd

反向代理服务器的配置

我們將以下內容新增到 `/etc/httpd/conf/httpd.conf` 的最後一行。

ProxyRequests Off
ProxyPass / http://localhost:5000/
ProxyPassReverse / http://localhost:5000/

追加记录文件后,重新启动Apache。

# systemctl restart httpd

可以访问HTTP

请配置许可给客户端访问 Web 服务的设置,允许访问 Http(端口:80)。

# firewall-cmd --permanent --add-service=http

最后

我已经在上述设置中安装了演示文稿,并确认可以访问。这是我第一次接触Linux,我学会了使用命令行操作以及用户权限等各种操作。虽然对于Linux和互联网的知识仍然不足,但我将继续不断学习。

请用中文进行转述,只需要一个选项:

操作手册

 

bannerAds