Ubuntu 24.04.01LTS へ WordPress をインストールする
Ubuntu 24.04LTS へ WordPress をインストールする手順をメモしておきます。
検証環境¶
対象 | バージョン |
---|---|
Ubuntu | 24.04.01 |
nginx | 1.24.0 |
mariadb-server | 10.11.8 |
php | 8.3.6 |
Nginx + PHP + MariaDB のインストール¶
WordPress を動作させる際に必要になる為、下記をインストールします。
sudo apt -y install \
mariadb-server \
nginx \
php8.3 \
php8.3-fpm \
php8.3-mbstring \
php8.3-mysql \
php-pear
Nginx の設定¶
Nginx の設定で PHP を有効化しておきます。 設定ファイルは /etc/nginx/sites-available/default
にあるので、以下のように修正します。
変更後¶
/etc/nginx/sites-available/default | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
|
修正が完了したら nginx と php-fpm を再起動して設定変更を反映します。
sudo systemctl reload php8.3-fpm nginx
MariaDB の初期設定¶
MariaDB に WordPress 用の設定を行います。 mysql
コマンドで MariaDB へ接続し、下記コマンドを実行して行きます。
create database wordpress;
grant all privileges on wordpress.* to wpuser@localhost identified by 'wppass';
flush privileges;
$ sudo mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 38
Server version: 10.11.7-MariaDB-2ubuntu2 Ubuntu 24.04
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> create database wordpress;
Query OK, 1 row affected (0.024 sec)
MariaDB [(none)]> grant all privileges on wordpress.* to wpuser@localhost identified by 'wppass';
Query OK, 0 rows affected (0.042 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.012 sec)
MariaDB [(none)]> exit;
Bye
WordPress のインストール¶
WordPress をインストールしていきます。
Step.1¶
Nginx デフォルトのインデックスファイルは削除しておきます。
rm /var/www/html/index.nginx-debian.html
Step.2¶
最新の WordPress を取得し、展開します。
cd ~/
curl -LO https://ja.wordpress.org/latest-ja.zip
unzip latest-ja.zip
mv wordpress/* /var/www/html/
mv /var/www/html/wp-config-sample.php /var/www/html/wp-config.php
chown -R www-data:www-data /var/www/html/
Step.3¶
ブラウザで WordPress にアクセスします。 今回の場合は Nginx のドキュメントルートに WordPress を配置している為、http://ADDRESS/
へアクセスします。
Step.4¶
さあ、始めましょう!
をクリックします。
Step.5¶
データベース関連のパラメータ入力を促されます。
MariaDB 上にデータベースを作成した際の値を入力し、送信
をクリックします。
Step.6¶
インストール実行
をクリックします。
Step.7¶
WordPress のパラメータ入力を促されます。
任意の値を入力したら WordPress をインストール
をクリックします。
Step.8¶
ログイン
をクリックします。
Step.9¶
インストール中に作成したユーザ名とパスワードを入力し、ログイン
をクリックします。
Step.10¶
WordPress へログイン出来ました。 これでインストールは完了です。
参考¶
デフォルトの /etc/nginx/sites-available/default¶
/etc/nginx/sites-available/default | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
|