GNU/Linux >> Linux の 問題 >  >> Ubuntu

Ubuntu18.04LTSにNginxを使用してPhorumをインストールする方法

Phorumは、PHPおよびMySQLベースのオープンソースフォーラムソフトウェアです。このガイドでは、Nginxをウェブサーバーとして、MySQLをデータベースとして、acme.shとLet's Encrypt for HTTPSを使用して、Ubuntu18.04LTSオペレーティングシステムにPhorumをインストールするプロセスを段階的に説明します。

> 要件

Phorumを実行するための要件は次のとおりです。

  • Nginx
  • PHPバージョン5.2以降
  • MySQLバージョン5.0以降
前提条件
  • Ubuntu18.04LTSオペレーティングシステム。
  • sudoを使用するroot以外のユーザー 特権。
初期ステップ

Ubuntuのバージョンを確認してください:

lsb_release -ds
# Ubuntu 18.04.1 LTS

タイムゾーンを設定します:

sudo dpkg-reconfigure tzdata

オペレーティングシステムパッケージ(ソフトウェア)を更新します。これは、オペレーティングシステムのデフォルトのソフトウェアパッケージの最新の更新とセキュリティ修正を確実に行うための重要な最初のステップです。

sudo apt update && sudo apt upgrade -y

Ubuntuオペレーティングシステムの基本的な管理に必要ないくつかの重要なパッケージをインストールします。

sudo apt install -y curl wget vim git unzip socat bash-completion apt-transport-https build-essential
ステップ1-PHPをインストールする

PHPと必要なPHP拡張機能をインストールします:

sudo apt install -y php7.2 php7.2-cli php7.2-fpm php7.2-common php7.2-mysql

モジュールにコンパイルされたPHPを表示するには、次のコマンドを実行できます。

php -m

ctype
curl
exif
fileinfo
. . .
. . .

PHPのバージョンを確認してください:

php --version

# PHP 7.2.10-0ubuntu0.18.04.1 (cli) (built: Sep 13 2018 13:45:02) ( NTS )
# Copyright (c) 1997-2018 The PHP Group
# Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
# with Zend OPcache v7.2.10-0ubuntu0.18.04.1, Copyright (c) 1999-2018, by Zend Technologies

PHP-FPMサービスは、Ubuntu 18.04システムで再起動すると自動的に開始されて有効になるため、手動で開始して有効にする必要はありません。次のステップであるデータベースのインストールとセットアップに進むことができます。

ステップ2-MySQLをインストールしてデータベースを作成します

MySQLデータベースサーバーをインストールします:

sudo apt install -y mysql-server

MySQLのバージョンを確認してください:

mysql --version
# mysql  Ver 14.14 Distrib 5.7.25, for Linux (x86_64) using  EditLine wrapper

mysql_secure installationを実行します MySQLのセキュリティを向上させ、MySQLのrootのパスワードを設定するスクリプト ユーザー:

sudo mysql_secure_installation

それぞれの質問に答えてください:

Would you like to setup VALIDATE PASSWORD plugin? N
New password: your_secure_password
Re-enter new password: your_secure_password
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y

rootユーザーとしてMySQLシェルに接続します:

sudo mysql -u root -p
# Enter password

空のMySQLデータベースとCachetのユーザーを作成し、資格情報を覚えておいてください:

mysql> CREATE DATABASE dbname;
mysql> GRANT ALL ON dbname.* TO 'username' IDENTIFIED BY 'password';
mysql> FLUSH PRIVILEGES;

MySQLを終了します:

mysql> exit

dbnameを置き換えます 、username およびpassword 自分の名前で。

ステップ3-acme.shをインストールします クライアントとLet'sEncrypt証明書を取得します(オプション

HTTPSでフォーラムを保護する必要はありませんが、サイトのトラフィックを保護することをお勧めします。 Let's EncryptからTLS証明書を取得するには、acme.shクライアントを使用します。 Acme.shは、依存関係がゼロのLet'sEncryptからTLS証明書を取得するための純粋なUNIXシェルソフトウェアです。

acme.shをダウンロードしてインストールします:

sudo su - root
git clone https://github.com/Neilpang/acme.sh.git
cd acme.sh 
./acme.sh --install --accountemail [email protected]
source ~/.bashrc
cd ~

acme.shのバージョンを確認してください:

acme.sh --version
# v2.8.0

RSAを取得する およびECC/ ECCSA ドメイン/ホスト名の証明書:

# RSA 2048
acme.sh --issue --standalone -d example.com --keylength 2048
# ECDSA
acme.sh --issue --standalone -d example.com --keylength ec-256

テスト用の偽の証明書が必要な場合は、--stagingを追加できます 上記のコマンドにフラグを立てます。

上記のコマンドを実行した後、証明書 およびキー になります:

  • RSAの場合 :/home/username/example.com ディレクトリ。
  • ECC / ECCSAの場合 :/home/username/example.com_ecc ディレクトリ。

発行された証明書を一覧表示するには、次のコマンドを実行できます:

acme.sh --list

証明書を保存するディレクトリを作成します。 /etc/letsencryptを使用します ディレクトリ。

mkdir -p /etc/letsecnrypt/example.com
sudo mkdir -p /etc/letsencrypt/example.com_ecc

証明書を/etc/letsencryptディレクトリにインストール/コピーします。

# RSA
acme.sh --install-cert -d example.com --cert-file /etc/letsencrypt/example.com/cert.pem --key-file /etc/letsencrypt/example.com/private.key --fullchain-file /etc/letsencrypt/example.com/fullchain.pem --reloadcmd "sudo systemctl reload nginx.service"
# ECC/ECDSA
acme.sh --install-cert -d example.com --ecc --cert-file /etc/letsencrypt/example.com_ecc/cert.pem --key-file /etc/letsencrypt/example.com_ecc/private.key --fullchain-file /etc/letsencrypt/example.com_ecc/fullchain.pem --reloadcmd "sudo systemctl reload nginx.service"

すべての証明書は60日ごとに自動的に更新されます。

証明書を取得したら、rootユーザーを終了し、通常のsudoユーザーに戻ります。

exit
ステップ4-NGINXをインストールして構成する

NGINXをインストールします:

sudo apt install -y nginx

NGINXのバージョンを確認してください:

sudo nginx -v
# nginx version: nginx/1.14.0 (Ubuntu)

Phorum用にNGINXを構成します。 sudo vim /etc/nginx/sites-available/phorum.confを実行します 次の構成を追加します。

server {
  listen 80;
  listen 443 ssl;
  server_name example.com;
  root /var/www/phorum;
ssl_certificate /etc/letsencrypt/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/example.com/private.key;
ssl_certificate /etc/letsencrypt/example.com_ecc/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/example.com_ecc/private.key;
index index.php index.html; location / { try_files $uri $uri/ /index.php?$query_string; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; } }

新しいphorum.confを有効にします ファイルをsites-enabledにリンクして構成します ディレクトリ:

sudo ln -s /etc/nginx/sites-available/phorum.conf /etc/nginx/sites-enabled

構文エラーがないかNGINX構成を確認してください:

sudo nginx -t

NGINXサービスをリロードします:

sudo systemctl reload nginx.service
ステップ4-Phorumをインストールする

Phorumのドキュメントルートディレクトリを作成します:

sudo mkdir -p /var/www/phorum

/var/www/phorumの所有権を変更します [jour_user] :へのディレクトリ

sudo chown -R [your_user]:[your_user] /var/www/phorum

ドキュメントのルートディレクトリに移動します:

cd /var/www/phorum

公式ウェブサイトから最新の安定したPhorumディストリビューションをダウンロードします:

wget https://www.phorum.org/downloads/phorum-5.2.23.tar.gz

ダウンロードしたアーカイブを解凍し、ファイルをドキュメントルートに移動します:

tar xvzf phorum-5.2.23.tar.gz
rm phorum-5.2.23.tar.gz
mv Core-phorum_5_2_23/* . && mv Core-phorum_5_2_23/.* .
rmdir Core-phorum_5_2_23

データベースアクセスを構成します:

cp include/db/config.php.sample include/db/config.php

include/db/config.phpを編集して、データベース設定を構成します ファイル:

vim include/db/config.php

/var/www/phorumの所有権を変更します www-data:へのディレクトリ

sudo chown -R www-data:www-data /var/www/phorum

インストールを完了するには、http://forum.example.com/admin.phpにアクセスしてウェブベースのインストーラーを実行します Webブラウザで。


Ubuntu
  1. Ubuntu16.04LTSにPHP5.6をインストールする方法

  2. Ubuntu20.04LTSにPHP7.4をインストールする方法

  3. Ubuntu20.04にNginxを使用してPHP7.4をインストールする方法

  1. Ubuntu18.04にNginxでWordPressをインストールする方法

  2. Ubuntu20.04LTSにNginxを使用してSeafileをインストールする方法

  3. Ubuntu11.10にPHP5とMySQLを使用してNginxをインストールする方法

  1. Ubuntu18.04LTSにNginxを使用してSeafileをインストールする方法

  2. Ubuntu16.04LTSにNginxを使用してLaravel5PHPフレームワークをインストールする方法

  3. Ubuntu 18.04にPHPとMySQL(LEMPスタック)を使用してNginxをインストールする方法