エントリー

新Webサーバ(ソフトウェア)

新しいWebサーバのソフトウェアの設定

OS準備

WS_20220612_000.png

armbianの最新版「Armbian_22.05.1_Nanopineo2_bullseye_current_5.15.43.img」をDLし,32GBマイクロSDカード(バックアップにも利用する予定なので最大の32GB)に書き込み

WS_20220612_001.png

PowerON

初回ログイン:root/1234

※)ここまででマイクロSDカード32GB全体が使用されている

管理者用ユーザの設定(UID=1000になる),nanopi/xxxxxx に設定

※)当ネット内ではUID=1001を管理者用にしているのでUID=1000は予備の管理ユーザにしている

最新版にする(後でも良い)

# apt update
# apt safe-upgrade

UID=1001の管理者用ユーザを作成

# addgroup --gid 1001 myhome
# adduser --uid 1001 --gid 1001 xxxx

sudoグループに登録

# adduser xxxx sudo
ネットワーク設定
# nmtui

address 192.168.xxx.xxx/24
gayeway 192.168.xxx.xxx
dns1 192.168.xxx.xxx
dns2 192.168.xxx.xxx
search domeins inoshita.jp
再起動
# shutdown -r now
SSDにパーティション設定

ファイルシステム異常時に対応しやすいようにOSとWebデータを別パーティションにする

スワップはSSDなので特に個別パーティションにする必要はない

# fdisk /dev/sda

Welcome to fdisk (util-linux 2.36.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x0992abb1.

Command (m for help): p
Disk /dev/sda: 931.51 GiB, 1000204886016 bytes, 1953525168 sectors
Disk model: Tech
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x0992abb1

Command (m for help):

Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 268437503 268435456 128G 83 Linux
/dev/sda2 268437504 1953525167 1685087664 803.5G 83 Linux

Command (m for help):

# fdisk /dev/sda -l
Disk /dev/sda: 931.51 GiB, 1000204886016 bytes, 1953525168 sectors
Disk model: Tech
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x801feee3

Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 268437503 268435456 128G 83 Linux
/dev/sda2 268437504 1953525167 1685087664 803.5G 83 Linux
#
ルートディレクトリの変更
# nand-sata-install

WS_20220612_003.png

WS_20220612_004.png

WS_20220612_005.png

WS_20220612_006.png

WS_20220612_008.png

WS_20220612_009.png

最後にリブート → SSDから起動

スワップ設定

2GBのファイルを作製

# dd if=/dev/zero of=/var/swapfile bs=2048 count=1M
1048576+0 records in
1048576+0 records out
2147483648 bytes (2.1 GB, 2.0 GiB) copied, 66.0937 s, 32.5 MB/s
# chmod 0600 /var/swapfile
# mkswap /var/swapfile
Setting up swapspace version 1, size = 2 GiB (2147479552 bytes)
no label, UUID=59c14259-636d-4902-95c4-b65a92418cb3

# free
total used free shared buff/cache available
Mem: 494436 104756 8264 596 381416 377964
Swap: 247216 256 246960
# swapon /var/swapfile
# free
total used free shared buff/cache available
Mem: 494436 106340 6588 596 381508 376408
Swap: 2344364 256 2344108
#

/etc/fstabにswap設定を追加

/var/swapfile swap swap defaults 0 0
sda2をマウント
# mkfs /dev/sda2
mke2fs 1.46.2 (28-Feb-2021)
Creating filesystem with 210635958 4k blocks and 52666368 inodes
Filesystem UUID: dff20d14-e20c-4e0b-8e4d-719af222d55f
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000

Allocating group tables: done
Writing inode tables: done
Writing superblocks and filesystem accounting information: done
#

/etc/fstabにswap設定を追加

UUID=dff20d14-e20c-4e0b-8e4d-719af222d55f /srv ext4 defaults,noatime,commit=600,errors=remount-ro,x-gvfs-hide 0 0
OR
/dev/sda2 /srv ext4 defaults,noatime,commit=600,errors=remount-ro,x-gvfs-hide 0 1

① デバイスファイル名 デバイスファイル名もしうはLABEL、UUIDを指定
② マウントポイント ファイルシステムのマウント先のディレクトリ
③ ファイルシステムの種類 ファイルシステムの種類を指定
④ マウントオプション マウントする際のオプションを指定します
⑤ dumpフラグ 1であればdumpコマンドによるバックアップの対象になる。etx2/3は1を指定し、その他は0を指定
⑥ fsckがチェック linuxが起動時にfsckがチェックする順序を指定

マウントオプション
noatime ファイルシステムでの atime 更新を無効にする

ここで再起動したら起動しなくなった

コンソールに接続して原因を探る(接続は115200bpsのN81)

IMG_20220611_203320_1.jpg

...
[ OK ] Finished File System Check…6-af99-4867-a839-f8025658c6e5.
Mounting /media/mmcboot...
[FAILED] Failed to mount /srv.
See 'systemctl status srv.mount' for details.
[DEPEND] Dependency failed for Local File Systems.
[ OK ] Mounted /media/mmcboot.
...

どうやらマウントオプションのミスらしい

UUID=dff20d14-e20c-4e0b-8e4d-719af222d55f /srv ext4 defaults,noatime 0 2

に修正して解決(commit=600,errors=remount-ro,x-gvfs-hide を外した)

apache
# apt install apache2

(追加)freoを動作させるための設定

①ディレクトリの定義

<Directory /xxx/www/freo>
     RewriteEngine On
     RewriteCond %{REQUEST_FILENAME} !-f
     RewriteCond %{REQUEST_FILENAME} !-d
     RewriteRule (.*)$ /freo/index.php/$1 [L]
</Directory>

②mod_rewriteの有効化(debian系はaptのセットアップでは有効になっていないようだ)

# cat /etc/apache2/mods-available/rewrite.load
LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so
# a2enmod rewrite
Enabling module rewrite.
To activate the new configuration, you need to run:
systemctl restart apache2
# systemctl restart apache2.service
mysql(mariadbに変更)
# apt install mariadb-server
$ mysql -u root -p

(ユーザ一覧)MariaDB [(none)]> select host, user from mysql.user;
(ユーザ登録)MariaDB [(none)]> create user 'user-name'@'localhost' identified by 'user-password';
(パスワード変更)MariaDB [(none)]> alter user 'user-name'@'localhost' identified by '(new-password)';
php
# apt install php

(追加)php関連ファイルのインストール

# apt install php-common php-cli php-fpm php-mysql php-dev php-mbstring php-zip
phpmyadmin

Debian10(buster)以降,aptではセットアップできないので以下の手順でセットアップ

https://phoenixnap.com/kb/how-to-install-phpmyadmin-on-debian-10

(追加)

DBのインポートはSQLファイルの制限(2048k bytes)があるのでfreoのDBはmysqlコマンドでインポートする

$ mysql -u freo -p freo < freo.sql
Enter password: (password)

$
nfs
# apt install nfs-client
# apt install autofs
# systemctl restart autofs

(前回と同じ)

samba
# apt install samba
# vi /etc/samba/smb.conf

# systemctl restart smbd
残件

残りはBlog設定とDBデータの移行

UPSが完成していないのでサーバの移行は後日

ページ移動

コメント

  • コメントはまだありません。

コメント登録

  • コメントを入力してください。
登録フォーム
名前
メールアドレス
URL
コメント
閲覧制限
投稿キー(スパム対策に、投稿キー を半角で入力してください。)

ユーティリティ

検索

エントリー検索フォーム
キーワード

過去ログ

Feed