Ubuntu 20.04にFlarumフォーラムをインストールする方法

Ubuntu/Debian

Flarumは無料のオープンソースの次世代フォーラムアプリケーションで、独自のオンラインディスカッションフォーラムを構築するのに役立ちます。それはPHPで書かれており、シンプルで高速かつ簡単にデプロイできます。柔軟なアーキテクチャ、強力な拡張APT、およびコミュニティを成功させるために必要なすべての機能を提供します。 Flarumの見た目と使い心地は、箱から出してすぐです。ユーザーインターフェイスが合理化されているので、クリックする時間を減らし、話す時間を増やすことができます。

このチュートリアルでは、ApacheおよびLet’s Encrypt SSLを使用してFlarumフォーラムをUbuntu 20.04サーバーにインストールする方法を説明します。

前提条件

  • Ubuntu 20.04を実行しているサーバー。
  • サーバーIPが指す有効なドメイン名。
  • rootパスワードがサーバーに構成されます。

入門

まず、常にシステムパッケージを最新バージョンに更新することをお勧めします。次のコマンドを使用して更新できます。

apt-get update -y

すべてのパッケージが更新されたら、次のステップに進むことができます。

LAMPサーバーをインストールする

FlarumはPHPで記述され、Webサーバー上で実行され、データベースバックエンドとしてMySQL / MariaDBを使用します。したがって、システムにLAMPスタックをインストールする必要があります。次のコマンドでインストールできます。

apt-get install apache2 mariadb-server php7.4 libapache2-mod-php7.4 php7.4-common php7.4-mbstring php7.4-xmlrpc php7.4-soap php7.4-mysql php7.4-gd php7.4-xml php7.4-curl php7.4-cli php7.4-zip php7.4-tokenizer wget unzip curl git -y

すべてのパッケージがインストールされたら、php.iniファイルを編集して、いくつかの設定を調整します。

nano /etc/php/7.4/apache2/php.ini

次の行を変更します。

file_uploads = On
allow_url_fopen = On
memory_limit = 256M
upload_max_file_size = 150M
max_execution_time = 450
date.timezone = Asia/Kolkata

終了したら、ファイルを保存して閉じます。

Flarumデータベースを作成する

次に、Flarumのデータベースとユーザーを作成する必要があります。まず、次のコマンドでMariaDBシェルにログインします。

mysql

ログインしたら、次のコマンドでデータベースとユーザーを作成します。

MariaDB [(none)]> CREATE DATABASE flarum; 
 MariaDB [(none)]> CREATE USER 'flarum'@'localhost' IDENTIFIED BY 'password';

次に、次のコマンドを使用して、flarumデータベースにすべての特権を付与します。

MariaDB [(none)]> GRANT ALL PRIVILEGES ON flarum.* TO 'flarum'@'localhost';

次に、特権をフラッシュし、次のコマンドでMariaDBを終了します。

MariaDB [(none)]> FLUSH PRIVILEGES; 
 MariaDB [(none)]> EXIT;

完了したら、次のステップに進むことができます。

Composerをインストールする

次に、システムにComposerをインストールする必要があります。 Composerは、PHPプロジェクトに必要なすべての依存関係をインストールするために使用されるPHPの依存関係マネージャーです。

次のコマンドでComposerをインストールできます。

curl -s https://getcomposer.org/installer | php

次の出力が表示されます。

All settings correct for using Composer
Downloading...

Composer (version 1.10.10) successfully installed to: /root/composer.phar
Use it: php composer.phar

次に、次のコマンドを使用して、Composerバイナリを/ usr / local / bin /ディレクトリに移動します。

mv composer.phar /usr/local/bin/composer

次に、次のコマンドを使用して、インストールされているComposerのバージョンを確認します。

composer -V

次の出力が表示されます。

Composer version 1.10.10 2020-08-03 11:35:19

Flarumをインストールする

まず、次のコマンドを使用して、Apache Webルートディレクトリ内にFlarumのディレクトリを作成します。

mkdir /var/www/html/flarum

次に、ディレクトリをflarumに変更し、次に示すようにComposerを使用してFlarumの最新バージョンをダウンロードします。

cd /var/www/html/flarum 
 composer create-project flarum/flarum . --stability=beta

次に、次のコマンドを使用してすべてのPHP依存関係をインストールします。

composer install

すべての依存関係がインストールされたら、Flarumの所有権をwww-dataに変更し、次のコマンドで適切な権限を付与します。

chown -R www-data:www-data /var/www/html/flarum/
chmod -R 755 /var/www/html/flarum/

完了したら、次のステップに進むことができます。

Flarum用にApacheを構成する

次に、FlarumをホストするためのApache仮想ホスト構成ファイルを作成する必要があります。次のコマンドで作成できます。 広告

nano /etc/apache2/sites-available/flarum.conf

次の行を追加します。

<VirtualHost *:80>
 ServerAdmin admin@linuxbuz.com
 DocumentRoot /var/www/html/flarum/public
 ServerName flarum.linuxbuz.com
 DirectoryIndex index.php
 <Directory /var/www/html/flarum/public/>
Options +FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
 </Directory>
 ErrorLog /var/log/apache2/flarum-error_log
 CustomLog /var/log/apache2/flarum-access_log common
</VirtualHost>

終了したら、ファイルを保存して閉じます。次に、次のコマンドでFlarum仮想ホストとApache書き換えモジュールを有効にします。

a2ensite flarum 
 a2enmod rewrite

最後に、Apacheサービスを再起動して変更を適用します。

systemctl restart apache2

次のコマンドを使用して、Apacheのステータスを確認することもできます。

systemctl status apache2

次の出力が表示されます。

? apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running) since Sun 2020-08-23 09:57:11 UTC; 2min 44s ago
       Docs: https://httpd.apache.org/docs/2.4/
   Main PID: 27164 (apache2)
      Tasks: 6 (limit: 2353)
     Memory: 12.3M
     CGroup: /system.slice/apache2.service
             ??27164 /usr/sbin/apache2 -k start
             ??27165 /usr/sbin/apache2 -k start
             ??27166 /usr/sbin/apache2 -k start
             ??27167 /usr/sbin/apache2 -k start
             ??27168 /usr/sbin/apache2 -k start
             ??27169 /usr/sbin/apache2 -k start

Aug 23 09:57:11 ubuntu2004 systemd[1]: Starting The Apache HTTP Server...

Let’s Encrypt SSLでFlarumを保護

Let’s Encryptの無料SSLを使用してWebサイトを保護することを常にお勧めします。最初に、次のコマンドでCertbot Let’s Encryptクライアントをインストールします。

apt-get install python3-certbot-apache -y

インストールしたら、次のコマンドを実行してFlarum WebサイトにLet’s Encrypt SSLをインストールします。

certbot --apache -d flarum.linuxbuz.com

以下に示すように、有効なメールアドレスを入力し、利用規約に同意するよう求められます。

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): hitjethva@gmail.com

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for flarum.linuxbuz.com
Waiting for verification...
Cleaning up challenges
Created an SSL vhost at /etc/apache2/sites-available/flarum-le-ssl.conf
Enabled Apache socache_shmcb module
Enabled Apache ssl module
Deploying Certificate to VirtualHost /etc/apache2/sites-available/flarum-le-ssl.conf
Enabling available site: /etc/apache2/sites-available/flarum-le-ssl.conf

次に、以下に示すように、HTTPトラフィックをHTTPSにリダイレクトするかどうかを選択します。

Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2

2と入力してEnterキーを押し、WebサイトのSSL証明書をインストールします。インストールが完了すると、次の出力が表示されます。 広告

Redirecting vhost in /etc/apache2/sites-enabled/flarum.conf to ssl vhost in /etc/apache2/sites-available/flarum-le-ssl.conf

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://flarum.linuxbuz.com

You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=flarum.linuxbuz.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/flarum.linuxbuz.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/flarum.linuxbuz.com/privkey.pem
   Your cert will expire on 2020-11-21. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot again
   with the "certonly" option. To non-interactively renew *all* of
   your certificates, run "certbot renew"
 - Your account credentials have been saved in your Certbot
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Certbot so
   making regular backups of this folder is ideal.
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

 - We were unable to subscribe you the EFF mailing list because your
   e-mail address appears to be invalid. You can try again later by
   visiting https://act.eff.org.

Flarumフォーラムにアクセス

この時点で、Flarumがインストールされ、構成され、Let’s Encrypt SSLで保護されています。次に、Webブラウザーを開き、URL https://flarum.linuxbuz.comを使用してFlarumにアクセスします 。次のページにリダイレクトされます。

フォーラム名、データベース名、ユーザー名、パスワード、管理者ユーザー名、パスワード、電子メールアドレスを入力し、 [ Flarumインストール ]ボタンをクリックします。インストールが完了すると、以下に示すようにFlarumダッシュボードにリダイレクトされます。

結論

おめでとう! Ubuntu 20.04サーバーにApacheとLet’s Encrypt SSLを使用してFlarumフォーラムを正常にインストールしました。 Flarumを使用して、独自のコミュニティフォーラムを簡単にホストできるようになりました。ご不明な点がございましたら、お気軽にお問い合わせください。

Source

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です