Textpatternは、無料のオープンソースPHPコンテンツ管理システムです。テーマとプラグインを介して適切なカスタマイズ性を提供しながら、かなり軽量で高速で使いやすいです。このガイドでは、新しいCentOS8システムにTextpatternをインストールします。
- rootユーザーまたはsudo権限を持つ任意のユーザーにアクセスできる新しいCentOS8システム。
- サーバーを指す登録済みドメイン名。
sudoユーザーとしてログインしている場合は、次の設定でrootに切り替えます。
sudo su -
$VISUAL環境変数を好みのテキストエディタに設定します。たとえば、nanoを使用するには:
echo "export VISUAL=nano" >> ~/.bash_profile . ~/.bash_profile
ステップ1:必要なソフトウェアのインストール
まず、システムを更新します:
dnf update -y
次に、wget、tar、Apache、PHP、必要なPHP拡張機能、MariaDB、およびSELinuxを管理するためのユーティリティをインストールします。
dnf install -y wget tar httpd mariadb-server php php-xml php-mysqli php-json php-mbstring php-zip php-zlib policycoreutils-python-utils
ApacheおよびMariaDBサービスが有効で実行されていることを確認します:
systemctl enable --now httpd.service mariadb.service
CentOS 8リポジトリにはcertbotが含まれていないため、スクリプトcertbot-autoを使用してインストールします。次のようにcertbot-autoをダウンロードしてインストールします。
wget https://dl.eff.org/certbot-auto mv certbot-auto /usr/local/bin/certbot-auto chmod 0755 /usr/local/bin/certbot-auto
次に、次のコマンドを使用してcertbotをインストールします。
certbot-auto --install-only
依存関係をインストールするようにdnfからプロンプトが表示されたら、「y」と入力します。
Apacheサービスを再起動します:
systemctl restart httpd.service
ステップ2:テキストパターンCMSのインストール
Githubのリリースから最新のテキストパターンリリースのダウンロードリンク(.tar.gz形式)をコピーし、次のようにwgetを使用してサーバーにダウンロードします。
wget https://github.com/textpattern/textpattern/releases/download/4.7.3/textpattern-4.7.3.tar.gz
次に、アーカイブを解凍し、その内容をWebルートディレクトリに移動します。
tar -xzf textpattern*.tar.gz rm -f textpattern*.tar.gz mv textpattern* /var/www/html/textpattern
Textpatternが正しく機能するためには、特定のディレクトリへの書き込みアクセスが必要です。そのアクセスを許可するには、Apacheシステムユーザーにディレクトリ全体の所有権を付与します。
chown -R apache:apache /var/www/html/textpattern
また、次のコマンドを使用して、ディレクトリ構造に適切なSELinuxコンテキストのラベルを付けます。
semanage fcontext -a -t httpd_sys_content_t "/var/www/html/textpattern(/.*)?" semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html/textpattern/themes(/.*)?" semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html/textpattern/images(/.*)?" semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html/textpattern/files(/.*)?" restorecon -Rv /var/www/html
ステップ3:データベースのセットアップ
mysql_secure_installationスクリプトを実行して、基本的なセキュリティ強化を実行することから始めます。
mysql_secure_installation
以下に示すように質問に答え、rootユーザーの安全なパスワードを選択してください:
Enter current password for root (enter for none):Set root password? [Y/n] y New password: your_password Re-enter new password: your_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
次に、Textpatternで使用するデータベースとユーザーを作成します。次のコマンドでMySQLシェルにログインします:
mysql -u root -p
ルートパスワードを入力してから、次のステートメントを発行します。 textpattern_user_passwordを適切なパスワードに置き換えてください。
MariaDB [(none)]> CREATE DATABASE textpattern_db; MariaDB [(none)]> CREATE USER textpattern_user IDENTIFIED BY 'textpattern_user_password'; MariaDB [(none)]> GRANT ALL PRIVILEGES ON textpattern_db.* TO textpattern_user; MariaDB [(none)]> \q
ステップ4:Apache構成
まず、ホストファイアウォールを通過するHTTPおよびHTTPSトラフィックを有効にします。
firewall-cmd --add-service http --add-service https --permanent firewall-cmd --reload
次に、Textpatternサイトの新しい仮想ホストを作成します。
$VISUAL /etc/httpd/conf.d/textpattern.conf
そして、次の構成を入力し、your_domainをドメイン名に置き換えます。
<VirtualHost *:80>
DocumentRoot "/var/www/html/textpattern"
ServerName your_domain
<Directory "/">
AllowOverride All
</Directory>
</VirtualHost>
保存して終了し、新しい構成をロードします:
systemctl reload httpd.service
ドメインのSSL証明書を取得し、HTTPSを使用するようにApacheを構成するには、次のコマンドを発行します。
certbot-auto --apache -d "your_domain" -m "[email protected]" --redirect
このコマンドは、いくつかのタスクを実行します。
- ドメインの証明書を取得します(/ etc /letsencrypt / your_domain /の下に保存されます)。
- textpattern-le-ssl.confという名前のApache構成ファイルを作成します。
- textpattern.confを編集して、すべてのHTTPリクエストをHTTPSにリダイレクトします。
ステップ5:テキストパターンCMS構成
これで、Textpatternのインストールにアクセスできるようになりますが、まだ構成されていません。 https:// your_domain / textpattern / setup /にアクセスして、Webインストーラーを開始します。言語を選択したら、データベースの詳細を入力します:
- MySQLユーザー名:textpattern_user
- MySQLパスワード:手順2でtextpattern_userに選択したパスワードを入力します。
- MySQLサーバー:localhost
- MySQLデータベース:textpattern_db
- テーブルプレフィックス:このフィールドは空白のままにします
インストーラーは、対応する構成を生成する前に、入力したデータベース資格情報を確認します。必要なファイルを作成します:
$VISUAL /var/www/html/textpattern/textpattern/config.php
生成された構成を貼り付け、ファイルを保存して終了します。 Webインストーラーの次のステップに進みます。ここで、CMS管理者アカウントとサイト構成の情報を入力するように求められます。それが完了したら、セットアップディレクトリを削除します:
rm -rf /var/www/html/textpattern/textpattern/setup
これで、Textpatternサイトを使用する準備が整いました。
- このガイドでcertbotを使用した証明書の管理について学ぶ