Mathematical.jp

よいこの低学年向けすうがくひろば



diff-eq.comスケールアップマイグレーション2


diff-eq.comスケールアップマイグレーション2

前回からの続きになります。この度のマイグレーションは運用を始めてから2か月弱ほどたっていないという異例の速さになりますがその理由は微分方程式いろいろを運用し始めてわかったことですが、たとえVPSであってもCentOS7という古いイメージによることの脆弱性、レイテンシ問題があったからになります。初めからやり直しているのはログの取得や手順の再確認、それ以外にも私はWordPressに関してはほぼ素人なのでその練度の向上なんかを目的にやっています。なのでかなり冗長な内容になっているのでそのへんはご承知おきください。

Apache+PHP+PostgreSQL+MariaDB+VIMのインストール

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
dnf install -y httpd mod_ssl httpd-tools httpd-devel httpd-manual php php-cli php-gd php-pdo php-mbstring mariadb mariadb-server vim
dnf install -y httpd mod_ssl httpd-tools httpd-devel httpd-manual php php-cli php-gd php-pdo php-mbstring mariadb mariadb-server vim
dnf install -y httpd mod_ssl httpd-tools httpd-devel httpd-manual php php-cli php-gd php-pdo php-mbstring mariadb mariadb-server vim

以下のように表示されることを確認します。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
・・・・・
pkgconf-m4-1.7.3-10.el9.noarch
pkgconf-pkg-config-1.7.3-10.el9.x86_64
sscg-3.0.0-7.el9.x86_64
vim-common-2:8.2.2637-20.el9.x86_64
vim-enhanced-2:8.2.2637-20.el9.x86_64
vim-filesystem-2:8.2.2637-20.el9.noarch
xml-common-0.6.3-58.el9.noarch
Complete!
[root@ik1-123-46789 centos]#
・・・・・ pkgconf-m4-1.7.3-10.el9.noarch pkgconf-pkg-config-1.7.3-10.el9.x86_64 sscg-3.0.0-7.el9.x86_64 vim-common-2:8.2.2637-20.el9.x86_64 vim-enhanced-2:8.2.2637-20.el9.x86_64 vim-filesystem-2:8.2.2637-20.el9.noarch xml-common-0.6.3-58.el9.noarch Complete! [root@ik1-123-46789 centos]#
・・・・・
  pkgconf-m4-1.7.3-10.el9.noarch
  pkgconf-pkg-config-1.7.3-10.el9.x86_64
  sscg-3.0.0-7.el9.x86_64
  vim-common-2:8.2.2637-20.el9.x86_64
  vim-enhanced-2:8.2.2637-20.el9.x86_64
  vim-filesystem-2:8.2.2637-20.el9.noarch
  xml-common-0.6.3-58.el9.noarch

Complete!
[root@ik1-123-46789 centos]#

httpdの起動

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
systemctl enable --now httpd
systemctl enable --now httpd
systemctl enable --now httpd

ファイアウォールの起動

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
systemctl start firewalld
systemctl enable firewalld
systemctl start firewalld systemctl enable firewalld
systemctl start firewalld
systemctl enable firewalld

Firewallでhttpとhttpsを許可

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
firewall-cmd --zone=public --add-service=http --permanent
firewall-cmd --zone=public --add-service=https --permanent
firewall-cmd --reload
firewall-cmd --zone=public --add-service=http --permanent firewall-cmd --zone=public --add-service=https --permanent firewall-cmd --reload
firewall-cmd --zone=public --add-service=http --permanent
firewall-cmd --zone=public --add-service=https --permanent
firewall-cmd --reload

ブラウザに入って以下のように表示されるのを確認します。

再起動させます。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
systemctl restart firewalld
systemctl restart firewalld
systemctl restart firewalld

次回サーバ起動時にhttpdも起動させるために次のように入力してEnter。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
systemctl enable httpd
systemctl enable httpd
systemctl enable httpd

設定の確認をするために次のように入力してEnter。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
systemctl list-unit-files -t service
systemctl list-unit-files -t service
systemctl list-unit-files -t service

httpd.serviceがenableになっているのを確認する。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
htcacheclean.service static -
httpd-init.service static -
httpd.service enabled disabled
httpd@.service disabled disabled
initrd-cleanup.service static -
initrd-parse-etc.service static -
initrd-switch-root.service static -
htcacheclean.service static - httpd-init.service static - httpd.service enabled disabled httpd@.service disabled disabled initrd-cleanup.service static - initrd-parse-etc.service static - initrd-switch-root.service static -
htcacheclean.service                       static          -
httpd-init.service                         static          -
httpd.service                              enabled         disabled
httpd@.service                             disabled        disabled
initrd-cleanup.service                     static          -
initrd-parse-etc.service                   static          -
initrd-switch-root.service                 static          -

権限の変更

権限がないとアップロードができないのでその権限の変更を行います。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
[root@ik1-123-45678 centos]# cd /var/www
[root@ik1-123-45678 www]# ls -l
total 8
drwxr-xr-x. 2 root root 4096 Feb 14 21:32 cgi-bin
drwxr-xr-x. 2 root root 4096 Feb 14 21:32 html
[root@ik1-123-45678 www]#
[root@ik1-123-45678 centos]# cd /var/www [root@ik1-123-45678 www]# ls -l total 8 drwxr-xr-x. 2 root root 4096 Feb 14 21:32 cgi-bin drwxr-xr-x. 2 root root 4096 Feb 14 21:32 html [root@ik1-123-45678 www]#
[root@ik1-123-45678 centos]# cd /var/www
[root@ik1-123-45678 www]# ls -l
total 8
drwxr-xr-x. 2 root root 4096 Feb 14 21:32 cgi-bin
drwxr-xr-x. 2 root root 4096 Feb 14 21:32 html
[root@ik1-123-45678 www]#

所有者をapacheにして所有グループを一般ユーザのvpsuserに変更する。管理者権限でパーミッションを変更します。
次のように入力します。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
chown apache:vpsuser html
chmod 775 html
chown apache:vpsuser html chmod 775 html
chown apache:vpsuser html
chmod 775 html

Snapdのインストール(Let’s Encryptに必要)

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
dnf -y install epel-release
dnf -y install epel-release
dnf -y install epel-release
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Installed:
epel-next-release-9-7.el9.noarch epel-release-9-7.el9.noarch
Complete!
[root@ik1-123-45678 www]#
Installed: epel-next-release-9-7.el9.noarch epel-release-9-7.el9.noarch Complete! [root@ik1-123-45678 www]#
Installed:
  epel-next-release-9-7.el9.noarch          epel-release-9-7.el9.noarch

Complete!
[root@ik1-123-45678 www]#

インストール

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
systemctl enable --now snapd.service snapd.socket
systemctl enable --now snapd.service snapd.socket
systemctl enable --now snapd.service snapd.socket
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
ln -s /var/lib/snapd/snap /snap
ln -s /var/lib/snapd/snap /snap
ln -s /var/lib/snapd/snap /snap
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Warning: /var/lib/snapd/snap/bin was not found in your $PATH. If you've not
restarted your session since you installed snapd, try doing that.
Please see https://forum.snapcraft.io/t/9469 for more details.
core 16-2.61.2 from Canonical✓ installed
[root@ik1-123-45678 www]#
Warning: /var/lib/snapd/snap/bin was not found in your $PATH. If you've not restarted your session since you installed snapd, try doing that. Please see https://forum.snapcraft.io/t/9469 for more details. core 16-2.61.2 from Canonical✓ installed [root@ik1-123-45678 www]#
Warning: /var/lib/snapd/snap/bin was not found in your $PATH. If you've not
         restarted your session since you installed snapd, try doing that.
         Please see https://forum.snapcraft.io/t/9469 for more details.

core 16-2.61.2 from Canonical✓ installed
[root@ik1-123-45678 www]#

証明書インストールcertbot

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
snap install --classic certbot
snap install --classic certbot
snap install --classic certbot
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
ln -s /snap/bin/certbot /usr/bin/certbot
ln -s /snap/bin/certbot /usr/bin/certbot
ln -s /snap/bin/certbot /usr/bin/certbot

PHPのインストール

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
dnf --enablerepo=epel install -y phpMyAdmin
dnf --enablerepo=epel install -y phpMyAdmin
dnf --enablerepo=epel install -y phpMyAdmin

以下のように表示されるのを確認します。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
Installed:
libicu-67.1-9.el9.x86_64 libzip-1.7.3-8.el9.x86_64
php-intl-8.0.30-1.el9.x86_64 php-mysqlnd-8.0.30-1.el9.x86_64
php-pecl-zip-1.19.2-6.el9.x86_64 php-process-8.0.30-1.el9.x86_64
phpMyAdmin-5.2.1-1.el9.noarch
Complete!
[root@ik1-123-45678 www]#
Installed: libicu-67.1-9.el9.x86_64 libzip-1.7.3-8.el9.x86_64 php-intl-8.0.30-1.el9.x86_64 php-mysqlnd-8.0.30-1.el9.x86_64 php-pecl-zip-1.19.2-6.el9.x86_64 php-process-8.0.30-1.el9.x86_64 phpMyAdmin-5.2.1-1.el9.noarch Complete! [root@ik1-123-45678 www]#
Installed:
  libicu-67.1-9.el9.x86_64                libzip-1.7.3-8.el9.x86_64
  php-intl-8.0.30-1.el9.x86_64            php-mysqlnd-8.0.30-1.el9.x86_64
  php-pecl-zip-1.19.2-6.el9.x86_64        php-process-8.0.30-1.el9.x86_64
  phpMyAdmin-5.2.1-1.el9.noarch

Complete!
[root@ik1-123-45678 www]#

phpバージョンの確認

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
php -v
php -v
php -v
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
[root@ik1-123-45678 www]# php -v
PHP 8.0.30 (cli) (built: Aug 3 2023 17:13:08) ( NTS gcc x86_64 )
Copyright (c) The PHP Group
Zend Engine v4.0.30, Copyright (c) Zend Technologies
with Zend OPcache v8.0.30, Copyright (c), by Zend Technologies
[root@ik1-123-45678 www]#
[root@ik1-123-45678 www]# php -v PHP 8.0.30 (cli) (built: Aug 3 2023 17:13:08) ( NTS gcc x86_64 ) Copyright (c) The PHP Group Zend Engine v4.0.30, Copyright (c) Zend Technologies with Zend OPcache v8.0.30, Copyright (c), by Zend Technologies [root@ik1-123-45678 www]#
[root@ik1-123-45678 www]# php -v
PHP 8.0.30 (cli) (built: Aug  3 2023 17:13:08) ( NTS gcc x86_64 )
Copyright (c) The PHP Group
Zend Engine v4.0.30, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.30, Copyright (c), by Zend Technologies
[root@ik1-123-45678 www]#

PHPのファイルアップロード上限サイズの変更

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
cd /etc
vim php.ini
cd /etc vim php.ini
cd /etc
vim php.ini

以下のように128Mに変更します。
なお検索する場合は最初に“/”を入力してuploadなどと入力してEnterを押下すればその場所に移動して編集ができます。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
upload_max_filesize = 128M
upload_max_filesize = 128M
upload_max_filesize = 128M
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
post_max_size = 128M
post_max_size = 128M
post_max_size = 128M

diff-eq.comスケールアップマイグレーション3へ続きます。

PAGE TOP