AlmaLinux 8にNginxでWordPressをインストールする方法
AlmaLinux 8にNginxでWordPressをインストールする方法
このページで
- 前提条件
- LAMPサーバーをインストールする
- MariaDBデータベースを設定する
- WordPressをダウンロード
- WordPressのためにApacheを設定する
- Let's Encrypt SSLでWordPressを安全にする
- ファイアウォールを設定する
- WordPressダッシュボードにアクセスする
- 結論
WordPressは無料でオープンソースの、世界で最も人気のあるCMSで、完全にPHPで構築されています。世界中の何千人もの人々がブログ、ビジネスウェブサイト、ECストアを運営するために使用しています。シンプルで使いやすい管理パネル、数千のプラグイン、巨大なコミュニティ、詳細なテーマ設定、カスタマイズなど、素晴らしい機能が備わっています。
このガイドでは、AlmaLinux 8にApacheとLet's Encrypt SSLを使用してWordPressをインストールする方法を説明します。
前提条件
- AlmaLinux 8を実行しているサーバー。
- サーバーIPにポイントされた有効なドメイン名。
- サーバーにはルートパスワードが設定されています。
LAMPサーバーをインストールする
WordPressを使用するには、サーバーにLAMPサーバーがインストールされている必要があります。以下のコマンドを使用してインストールできます:
dnf install httpd mariadb-server php php-mysqlnd php-dom php-simplexml php-xml php-xmlreader php-curl php-exif php-ftp php-gd php-iconv php-json php-mbstring php-posix php-sockets php-tokenizer unzip -yLAMPサーバーをインストールした後、ApacheとMariaDBサービスを起動し、システム再起動時に自動的に起動するように設定します。
systemctl start mariadb
systemctl start httpd
systemctl enable mariadb
systemctl enable httpd完了したら、次のステップに進むことができます。
MariaDBデータベースを設定する
まず、MariaDBのルートパスワードを設定し、MariaDBのインストールをセキュアにする必要があります。次のコマンドを使用して実行できます:
mysql_secure_installation以下のようにすべての質問に答えてください:
Enter current password for root (enter for none):
Set root password? [Y/n] Y
New password:
Re-enter new 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
完了したら、次のコマンドを使用してMariaDBにログインしてください:
mysql -u root -pログインしたら、WordPress用のデータベースとユーザーを作成します:
MariaDB [(none)]> CREATE DATABASE wordpress;
MariaDB [(none)]> CREATE USER `wordpress`@`localhost` IDENTIFIED BY 'password';次に、以下のコマンドを使用してWordPressデータベースにすべての権限を付与します:
MariaDB [(none)]> GRANT ALL ON wordpress.* TO `wordpress`@`localhost`;次に、次のコマンドを使用して権限をフラッシュし、MariaDBシェルから退出します:
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> EXIT;完了したら、次のステップに進むことができます。
WordPressをダウンロード
次に、ディレクトリをApacheのウェブルートに変更し、次のコマンドを使用して最新のWordPressをダウンロードします:
cd /var/www/html
wget https://wordpress.org/latest.tar.gzダウンロードが完了したら、以下のコマンドでダウンロードしたファイルを展開します:
tar -xvzf latest.tar.gz次に、ディレクトリをwordpressに変更し、サンプル設定ファイルの名前を変更します:
cd wordpress
mv wp-config-sample.php wp-config.php
次に、以下のコマンドで設定ファイルを編集します:
nano wp-config.phpデータベース構成を以下のように定義してください。
/** The name of the database for WordPress */
define( 'DB_NAME', 'wordpress' );
/** MySQL database username */
define( 'DB_USER', 'wordpress' );
/** MySQL database password */
define( 'DB_PASSWORD', 'password' );
/** MySQL hostname */
define( 'DB_HOST', 'localhost' );
作業が完了したらファイルを保存して閉じ、その後WordPressディレクトリに適切な権限を設定してください。
chown -R apache:apache /var/www/html/wordpress完了したら、次のステップに進むことができます。
WordPressのためのApacheの設定
次に、WordPress用のApache仮想ホスト設定ファイルを作成する必要があります。以下のコマンドで作成できます:
nano /etc/httpd/conf.d/wordpress.conf次の行を追加してください:
<VirtualHost *:80>
ServerAdmin [email
DocumentRoot "/var/www/html/wordpress"
ServerName wordpress.example.com
ErrorLog "/var/log/httpd/example.com-error_log"
CustomLog "/var/log/httpd/example.com-access_log" combined
<Directory "/var/www/html/wordpress">
DirectoryIndex index.html index.php
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
ファイルを保存して閉じ、その後Apacheサービスを再起動して変更を適用します。
systemctl restart httpd次のコマンドでApacheの状態を確認できます:
systemctl status httpd次の出力を得るべきです:
? httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
Active: active (running) since Fri 2021-07-09 03:30:47 EDT; 3s ago
Docs: man:httpd.service(8)
Main PID: 4153 (httpd)
Status: "Started, listening on: port 80"
Tasks: 213 (limit: 12524)
Memory: 24.5M
CGroup: /system.slice/httpd.service
??4153 /usr/sbin/httpd -DFOREGROUND
??4155 /usr/sbin/httpd -DFOREGROUND
??4156 /usr/sbin/httpd -DFOREGROUND
??4157 /usr/sbin/httpd -DFOREGROUND
??4158 /usr/sbin/httpd -DFOREGROUND
Jul 09 03:30:47 AlmaLinux systemd[1]: Stopped The Apache HTTP Server.
Jul 09 03:30:47 AlmaLinux systemd[1]: Starting The Apache HTTP Server...
完了したら、次のステップに進むことができます。
Let's Encrypt SSLでWordPressを安全にする
次に、WordPressのためにLet's Encrypt SSLをインストールするために、Certbotクライアントをインストールする必要があります。以下のコマンドを使ってインストールできます:
dnf install epel-release -y dnf install certbot python3-certbot-apache 次に、次のコマンドを使用して、あなたのletsドメインにSSL証明書を取得してインストールします。
certbot --apache -d wordpress.example.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): [email
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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. Do you agree?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing, once your first certificate is successfully issued, 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
Account registered.
Requesting a certificate for wordpress.example.com
Performing the following challenges:
http-01 challenge for wordpress.example.com
Waiting for verification...
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/httpd/conf.d/wordpress.conf
Redirecting all traffic on port 80 to ssl in /etc/httpd/conf.d/wordpress.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://wordpress.example.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Subscribe to the EFF mailing list (email: [email ).
IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/wordpress.example.com/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/wordpress.example.com/privkey.pem
Your certificate will expire on 2022-02-09. 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"
- 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ファイアウォールを設定する
次に、firewalldを通してポート80と443を許可する必要があります。以下のコマンドで許可できます:
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https次に、変更を適用するためにfirewalldをリロードします:
firewall-cmd --reload完了したら、次のステップに進むことができます。
WordPressダッシュボードにアクセスする
次に、ウェブブラウザを開き、URL https://wordpress.example.com を使用してWordPress管理パネルにアクセスしてください。次のページにリダイレクトされます:
言語を選択し、続行をクリックしてください。WordPressサイトの設定ページが表示されるはずです:
サイト情報を入力し、WordPressをインストールボタンをクリックしてください。インストールが完了すると、次のページが表示されます:
ログインボタンをクリックしてください。WordPressのログインページにリダイレクトされます:
管理者のユーザー名とパスワードを入力し、ログインボタンをクリックしてください。次のページでWordPressのダッシュボードが表示されるはずです。
結論
おめでとうございます!あなたはAlmaLinux 8にApacheとLet's Encrypt SSLを使用してWordPressを正常にインストールしました。これで、WordPressを使って簡単に自分のウェブサイトを作成できます。質問があればお気軽にお尋ねください。




