CentOS7にPHP74, PostgreSQL12, MariaDB10.4をインストールする

PostgreSQL12

12用のリポをゲットしてインストール。

yum -y install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
yum -y install postgresql12-server postgresql12-contrib
cp /var/lib/pgsql/12/data/pg_hba.conf /var/lib/pgsql/12/data/pg_hba.conf.org
vi /var/lib/pgsql/12/data/pg_hba.conf
diff /var/lib/pgsql/12/data/pg_hba.conf.org /var/lib/pgsql/12/data/pg_hba.conf

編集した差分はこちら。ローカルかつ特定のユーザーからしかアクセスできないように設定。

84c84
< local   all             all                                     peer
---
> local   all             all                                     trust
86c86
< host    all             all             127.0.0.1/32            ident
---
> host    all             <dbusername>       127.0.0.1/32            md5
88c88
< host    all             all             ::1/128                 ident
---
> #host    all             all             ::1/128                 ident
91,93c91,93
< local   replication     all                                     peer
< host    replication     all             127.0.0.1/32            ident
< host    replication     all             ::1/128                 ident
---
> #local   replication     all                                     peer
> #host    replication     all             127.0.0.1/32            ident
> #host    replication     all             ::1/128                 ident

データベースの初期化。

PGSETUP_INITDB_OPTIONS="-E UTF8 --no-locale" /usr/pgsql-12/bin/postgresql-12-setup initdb
su - postgres
psql

ユーザーの追加。権限の変更。ユーザー一覧の確認。

CREATE ROLE <dbusername> CREATEDB LOGIN PASSWORD '<dbpassword>';
ALTER USER kir014912 SUPERUSER;
\du;

rootに戻ってサービスの登録と起動。ファイヤーウォールの設定。

firewall-cmd --state
firewall-cmd --list-all
firewall-cmd --permanent --zone=public --add-service=postgresql
systemctl restart firewalld.service
firewall-cmd --list-all
systemctl enable postgresql-12.service
systemctl start postgresql-12

MariaDB10.4

以下のリポジトリにバージョン指定すればインストール指定したバージョンでインストールが可能。インストール後は初期設定。

curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | bash -s -- --mariadb-server-version=mariadb-10.4
yum install -y MariaDB-server MariaDB-client
mysql_secure_installation

初期設定はrootのパスワード設定以外はだいたいYesで。

cp /etc/my.cnf.d/mariadb-server.cnf /etc/my.cnf.d/mariadb-server.cnf.org
vi /etc/my.cnf.d/mariadb-server.cnf
diff  /etc/my.cnf.d/server.cnf.org  /etc/my.cnf.d/server.cnf

[mysqld] 以下に追記。

12a13,15
> character-set-server = utf8mb4
> [client-mariadb]
> default-character-set = utf8mb4

サービス登録と起動、ファイヤーウォールの設定。

systemctl enable mariadb
systemctl start mariadb
firewall-cmd --permanent --zone=public --add-service=mysql
systemctl restart firewalld.service
firewall-cmd --list-all

PHP74

epelリポジトリからPHP74のインストール。ipaフォントはプロジェクトで使うのでついでに入れてます。

yum install -y epel-release
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
yum install -y --enablerepo=remi-php74 php php-mysql php-pgsql httpd-tools php-curl php-dom php-gd php-pecl-imagick php-zip  php-mbstring php-openssl php-xml unzip ipa-gothic-fonts ipa-pgothic-fonts fontconfig
php -v

composer なしにはPHPで何もできないように思うので初めから入れておく。

cd /usr/local/src/
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '756890a4488ce9024fc62c56153228907f1545c228516cbf63f885e036d37e9a59d27d63f46af1d4d07ee0f76181c7d3') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
mv composer.phar /usr/local/bin/composer