LoginSignup
10
11

More than 5 years have passed since last update.

[Raspberry Pi] RaspberryPi 2でCentOS7 ことはじめ

Last updated at Posted at 2016-01-26

RaspberryPiにCentOS7をインストールしましたので

まずはupdate

yum updateで最新の状態にする

つぎにキーマップ

# localectl set-keymap jp106
# cat /vconsole.conf
KEYMAP="jp106"

参考:centos7でキーボードレイアウト変更

パーティション拡張

デフォルトだと2GBしかないので、拡張します。

/root/READMEに従う

(コメントありがとうございます!)
root直下で

# touch /.rootfs-repartition

として再起動!

/root/READMEに従わない

# df
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/root        1998672 1699032    178400  91% /
...
/dev/mmcblk0p1    307016   65064    241952  22% /boot
...

# fdisk /dev/mmcblk0
(p1をいれないように)
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): p

Disk /dev/mmcblk0: 15.8 GB, 15811477504 bytes, 30881792 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xc1356df5

        Device Boot      Start         End      Blocks   Id  System
/dev/mmcblk0p1            2048      616447      307200    c  W95 FAT32 (LBA)
/dev/mmcblk0p2          616448     1665023      524288   82  Linux swap / Solaris
/dev/mmcblk0p3         1665024     5859327     2097152   83  Linux

パーティションの削除

Command (m for help): d
Partition number (1-3, default 3): 3
Partition 3 is deleted

パーティションの作成(プライマリ)

Command (m for help): n
Partition type:
   p   primary (2 primary, 0 extended, 2 free)
   e   extended
Select (default p): p
Partition number (3,4, default 3): 3
First sector (1665024-30881791, default 1665024):
Using default value 1665024
Last sector, +sectors or +size{K,M,G} (1665024-30881791, default 30881791):
Using default value 30881791
Partition 3 of type Linux and of size 14 GiB is set

設定の書き込み

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.

リブート後、サイズの変更をおこなう

# shutdown -r now
# resize2fs /dev/mmcblk0p3
resize2fs 1.42.9 (28-Dec-2013)
Filesystem at /dev/mmcblk0p3 is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 1
The filesystem on /dev/mmcblk0p3 is now 3652096 blocks long.

# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root        14G  1.7G   12G  13% /
devtmpfs        459M     0  459M   0% /dev
tmpfs           463M     0  463M   0% /dev/shm
tmpfs           463M   12M  452M   3% /run
tmpfs           463M     0  463M   0% /sys/fs/cgroup
/dev/mmcblk0p1  300M   64M  237M  22% /boot
tmpfs            93M     0   93M   0% /run/user/0

いろいろインストールされていない

gitとかntpdateとか、いろいろインストールされていないので
必要なものをインストール。

epel-release

対応してませんでした

AMRv7に対応するまで待ちましょう

ntpdate

インストール

ラズパイは電源を落とすと、時刻が初期化されます。
ので、必要あらば正確な時刻を設定してください。

# yum install ntpdate
# ntpdate -s -b ntp.nict.jp

UTCになっていたら、timezoneを変更

# timedatectl set-timezone Asia/Tokyo

サービス登録

システム起動時に、時刻修正ができるようにサービス登録しました。

# cd /etc/systemd/system
# vi ntpdate-update.service
ntpdate-update.service
[Unit]
Description=NTP update on Boot
After=network.service

[Service]
Type=simple
ExecStart=/usr/sbin/ntpdate -s -b ntp.nict.jp

[Install]
WantedBy=default.target
# systemctl enable ntpdate-update.service

nodejs

epelでインストールできたら早かったのですが、それが叶わないので、ソースコンパイルします。

gcc, g++, git, make

いろいろありませんでしたので、インストール

# yum install gcc gcc-c++ git make

nodejs

GitHubからもってきます。
(2016年1月26日現在 masterはv6.0.0)
ここでは4.x系をインストールしたいと思います。

# git clone https://github.com/nodejs/node.git
# cd node
# git branch -b v4.x origin/v4.x
# ./configure --prefix=/usr
(過去の経験上、/usrにインストールしたほうがいい気がします)

# lscpu
(CPUの数を確認して)
# make -j4
(マルチプロセス数を指定する)
# make install
# source ~/.bash_profile
(インストールしたプログラムを認識させるため)

# node -v
v4.2.7-pre

# npm update -g npm
# npm -v
3.5.3

ビルドに1~2時間くらいかかります。まーしかたない。

php

インストール

remi 使えません。
ので、ソースコンパイルしてもいいけど
とりいそぎ、yumでいれちゃいます。

# yum install php php-mysqlnd (etc..)

mariadb

インストール

MySQLのかわりに、Mariadbになってますが、そのまま使います。
設定ファイルは、''/etc/my.cnf``のままです。

# yum install mariadb mariadb-server
# systemctl enable mariadb.service
# systemctl start mariadb.service
# mysql_secure_installation
# mysql -uroot -p

phpから接続

# php -r 'var_dump(new mysqli("localhost","user","password"));'

上記で確認した後は、コマンド履歴を消しておきましょう。

Apache2.4

インストール

yumからインストールできなかったので
ソースからインストールする。

事前準備

nghttp2のインストール

# git clone https://github.com/tatsuhiro-t/nghttp2.git/
# cd nghttp2
# autoreconf -i
# automake
# autoconf
# ./configure --prefix=/usr/local
# make -j4
# make install
# vi /etc/ld.so.conf
include ld.so.conf.d/*.conf
/usr/local/lib
# ldconfig
# ldconfig -p | grep http
        libnghttp2.so.14 (libc6,hard-float) => /usr/local/lib/libnghttp2.so.14
        libnghttp2.so (libc6,hard-float) => /usr/local/lib/libnghttp2.so

APR系のインストール

# yum install apr-devel apr-util-devel

Apache2.4のインストール

# wget http://ftp.meisei-u.ac.jp/mirror/apache/dist//httpd/httpd-2.4.18.tar.bz2
# tar jxvf httpd-2.4.18.tar.bz2
# cd httpd-2.4.18
# ./configure \
  --enable-http \
  --enable-http2 \
  --enable-nghttp2-staticlib-deps \
  --with-nghttp2=/usr/local/lib \
  --with-apr=/usr/bin/apr-1-config \
  --with-apr-util=/usr/bin/apu-1-config
# make install

to be continued ...

10
11
2

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
11