10
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

CentOS 7にMaria DBとPHP 7.0を入れる

Posted at

環境

  • CentOS 7

MariaDB

yumのリポジトリを追加

/etc/yum.repos.d/MariaDB.repo
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

インストール

$ sudo yum install MariaDB-server MariaDB-client

サービスを有効化&起動

$ sudo systemctl enable mariadb
$ sudo systemctl start mariadb

最小構成の設定ファイルをコピーして、文字コードを設定

$ sudo cp -p /usr/share/mysql/my-small.cnf /etc/my.cnf.d/server.cnf
/etc/my.cnf.d/server.cnf
[client]
default-character-set = utf8

[mysqld]
character-set-server = utf8

初期設定

$ sudo /usr/bin/mysql_secure_installation

PHP 7.0

yumのリポジトリにepelとremiを追加

epel
$ sudo yum -y install epel-release
remi
$ wget http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
$ sudo rpm -ivh ./remi-release-7.rpm

インストール

$ sudo yum install --enablerepo=remi,remi-php70 php php-devel php-mbstring php-pdo php-gd

MariaDBと接続するドライバのインストール

$ sudo yum install --enablerepo=remi,remi-php70 php-mysqlnd

ドライバを認識してるか確認

$ php -r "phpinfo();" | grep -i PDO
/etc/php.d/20-pdo.ini,
/etc/php.d/30-pdo_mysql.ini,
/etc/php.d/30-pdo_sqlite.ini
API Extensions => mysqli,pdo_mysql
PDO
PDO support => enabled
PDO drivers => mysql, sqlite
pdo_mysql
PDO Driver for MySQL => enabled
pdo_mysql.default_socket => /var/lib/mysql/mysql.sock => /var/lib/mysql/mysql.sock
pdo_sqlite
PDO Driver for SQLite 3.x => enabled
10
13
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?