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 | server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.php index.html index.htm index.nginx-debian.html;
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.3-fpm.sock;
}
}
|
修正が完了したら 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 | ##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# https://www.nginx.com/resources/wiki/start/
# https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/
# https://wiki.debian.org/Nginx/DirectoryStructure
#
# In most cases, administrators will remove this file from sites-enabled/ and
# leave it as reference inside of sites-available where it will continue to be
# updated by the nginx packaging team.
#
# This file will automatically load configuration files provided by other
# applications, such as Drupal or Wordpress. These applications will be made
# available underneath a path with that package name, such as /drupal8.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##
# Default server configuration
#
server {
listen 80 default_server;
listen [::]:80 default_server;
# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
# pass PHP scripts to FastCGI server
#
#location ~ \.php$ {
# include snippets/fastcgi-php.conf;
#
# # With php-fpm (or other unix sockets):
# fastcgi_pass unix:/run/php/php7.4-fpm.sock;
# # With php-cgi (or other tcp sockets):
# fastcgi_pass 127.0.0.1:9000;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# Virtual Host configuration for example.com
#
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#
#server {
# listen 80;
# listen [::]:80;
#
# server_name example.com;
#
# root /var/www/example.com;
# index index.html;
#
# location / {
# try_files $uri $uri/ =404;
# }
#}
|