# バージョンを確認
$ sudo cat /etc/lsb-release
// DISTRIB_ID=Ubuntu
// DISTRIB_RELEASE=20.04
// DISTRIB_CODENAME=focal
// DISTRIB_DESCRIPTION="Ubuntu 20.04.1 LTS"
# アーキテクチャを確認
$ sudo arch
// x86_64
apt update
:リポジトリから有効で更新可能なパッケージ一覧を取得apt upgrade
:パッケージをアップデートapt update
しただけではパッケージのアップデートしない。
$ sudo apt update -y && apt upgrade -y
$ cat /etc/apt/sources.list
$ apt list --installed
$ apt install apache2
$ apt install php
以下のパッケージがインストール
$ apt list --installed | grep php
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
libapache2-mod-php7.4/focal-updates,focal-security,now 7.4.3-4ubuntu2.4 amd64 [installed,automatic]
php-common/focal,now 2:75 all [installed,automatic]
php7.4-cli/focal-updates,focal-security,now 7.4.3-4ubuntu2.4 amd64 [installed,automatic]
php7.4-common/focal-updates,focal-security,now 7.4.3-4ubuntu2.4 amd64 [installed,automatic]
php7.4-json/focal-updates,focal-security,now 7.4.3-4ubuntu2.4 amd64 [installed,automatic]
php7.4-opcache/focal-updates,focal-security,now 7.4.3-4ubuntu2.4 amd64 [installed,automatic]
php7.4-readline/focal-updates,focal-security,now 7.4.3-4ubuntu2.4 amd64 [installed,automatic]
php7.4/focal-updates,focal-security,now 7.4.3-4ubuntu2.4 all [installed,automatic]
php/focal,now 2:7.4+75 all [installed]
現在インストールされている拡張はを調べる
$ php -m
calendar
Core
ctype
date
exif
FFI
fileinfo
filter
ftp
gettext
hash
iconv
json
libxml
openssl
pcntl
pcre
PDO
Phar
posix
readline
Reflection
session
shmop
sockets
sodium
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
Zend OPcache
zlib
[Zend Modules]
Zend OPcache
WordPressに必要なモジュール以下リンクを参照。 https://make.wordpress.org/hosting/handbook/handbook/server-environment/#php-extensions
足りないモジュールをインストール
$ apt install php7.4-curl php7.4-dom php7.4-mbstring php7.4-mysqli php7.4-imagick php7.4-xml php7.4-zip
$ apachectl graceful
以下メッセージが表示されたら/etc/apache2.conf
にServerName xxx.xxx.xxx.xxxx
を追記。
(/etc/apache2/sites-availables/000-default.conf
に追加してもエラーは解消されない)
apachectl graceful
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using xxx.xxx.xxx.xxxx. Set the 'ServerName' directive globally to suppress this message
UbuntuのリポジトリにはMySQL 5.7はないが、以下を参考にインストール https://computingforgeeks.com/how-to-install-mysql-on-ubuntu-focal/
$ wget https://ja.wordpress.org/latest-ja.tar.gz
$ tar -xzvf latest-ja.tar.gz
WordPress用データベース作成
mysql > CREATE DATABASE <database> DEFAULT CHARACTER SET utf8mb4;
/var/www/html
の所有者変更
$ chown -R www-data:www-data /var/www/html
www-data
はUbuntuにインストールしたApacheのユーザー:ブループ。
/etc/apache2/apache2.conf
に下記記載がある。
# These need to be set in /etc/apache2/envvars
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
/etc/apache2/envvars
に記載。
export APACHE_RUN_USER=www-data
export APACHE_RUN_GROUP=www-data
Bad
$ apt remove php
Good
$ apt remove php-common
deb(ディーイービー)は、Debianなどで利用されるソフトウェア・パッケージのフォーマット。
拡張子 ".deb" のファイルは、Debian、Ubuntuなど多くのLinuxディストリビューションで利用されるバイナリのパッケージである。これらのパッケージはgzipやbzip2、LZMAで圧縮された2つのアーカイブで構成される。そのうち1つはコントロールの情報、もう1つはデータを含む。
dpkg、aptまたはaptitudeでコントロールすることができる。