CentOS7Minimalインストール, LAMP, Nodejs, Redis and TeX

--------------------------------------------------------------------------------

備考:
  ・Windows上にVirtualBoxでLinux環境を構築します。
  ・npm以外は、インターネットにつながっていない環境にも対応しています。
    npmはNAT環境で。

--------------------------------------------------------------------------------

・前処理

 ・用意するもの(クライアント側のanywhereディレクトリにあるファイル)

    CentOS-7-x86_64-DVD-1810.iso
    mariadb-10.4.6-rhel-7-x86_64-rpms.tar
    nkf-master.zip
    node-v8.14.0-linux-x64.tar.xz
    php-7.3.9.tar.gz
    redis-5.0.5.tar.gz
    texlive2019-20190410.iso

    Ref.
        nkf : https://github.com/nurse/nkf

 ・準備

  ・仮想ドライブとしてマウント: CentOS-7-x86_64-DVD-1810.iso

--------------------------------------------------------------------------------

・Oracle VM VirtualBox マネージャ で 新規作成

 ・名前    c00
 ・タイプ   Linux
 ・バージョン Other Linux (64bit)

 ・メモリサイズ 1024MB
 ・仮想ハードディスクを作成する
 ・ハードディスクのファイルタイプ: VDI(VirtualBox Disk Image)
 ・物理ハードディスクにあるストレージ: 可変サイズ
 ・ファイルの場所とサイズ: c00, 80GB
 ・[作成]

--------------------------------------------------------------------------------

・ネットワーク設定

 ・[設定(S)] - ネットワーク
  ・割り当て(A): ホストオンリーアダプター
  ・[OK]

--------------------------------------------------------------------------------

・インストール

 ・起動(T)
 ・Install CentOS 7
  ・Language: English (United States)
  ・DATE & TIME: Asia Tokyo
  ・KEYBOARD: Japanese
  ・SOFTWARE SELECTION: Minimal Install;
  ・KDUMP: disabled
  ・NETWORK & HOST NAME: Ethernet = ON; Host Name = c00.mydomain;
  ・[Begin Installation]

  ・ROOT PASSWORD
  ・USER CREATION

  ・(処理終了を待つ)

  ・Reboot

  ・(再起動後に仮想ドライブをアンマウント)

  ・LICENSE INFORMATION: I accpt the license agreement.
  ・[FINISH CONFIGURATION]

  ・root Log-in

  ・固定IP
      $ su -
      # cd /etc/sysconfig/network-scripts
      # cp ifcfg-enp0s3 _ifcfg-enp0s3_org
      # vi ifcfg-enp0s3
      # diff _ifcfg-enp0s3_org ifcfg-enp0s3
      15c15
      < ONBOOT=no
      ---
      < ONBOOT=yes
      # cd

  ・make directory
      # mkdir ~/wrk
      # shutdown -r now

--------------------------------------------------------------------------------

・以降、client端末からsshでログインし、処理します。

--------------------------------------------------------------------------------

・パッケージの構築

 ・クライアント側から、必要なファイルをサーバにコピー。
    $ cd /anywhere
    $ scp * root@192.168.3.221:wrk

 ・サーバ側はrootで処理。

    mount -o loop -t iso9660 ~/wrk/CentOS-7-x86_64-DVD-1810.iso /mnt
    cd /; mkdir Packages; cd Packages; cp /mnt/Packages/* .
    umount /mnt
    rm -f ~/wrk/CentOS-7-x86_64-DVD-1810.iso

--------------------------------------------------------------------------------

・ソフトウェアのインストール

 ・前準備

    cd ~/wrk
    tar xf mariadb-10.4.6-rhel-7-x86_64-rpms.tar
    cd mariadb-10.4.6-rhel-7-x86_64-rpms
    mv *.rpm /Packages
    cd ..
    rm -Rf mariadb-10.4.6-rhel-7-x86_64-rpms*

 ・gcc

    cd /Packages
    rpm -ivh \
    gcc-4.8.5-36.el7.x86_64.rpm \
    cpp-4.8.5-36.el7.x86_64.rpm \
    glibc-devel-2.17-260.el7.x86_64.rpm \
    glibc-headers-2.17-260.el7.x86_64.rpm \
    kernel-headers-3.10.0-957.el7.x86_64.rpm \
    libmpc-1.0.1-3.el7.x86_64.rpm \
    mpfr-3.1.1-4.el7.x86_64.rpm

 ・Net-tools

    cd /Packages
    rpm -ivh net-tools-2.0-0.24.20131004git.el7.x86_64.rpm

 ・Bind utility

    cd /Packages
    rpm -ivh \
    bind-9.9.4-72.el7.x86_64.rpm \
    bind-chroot-9.9.4-72.el7.x86_64.rpm \
    bind-utils-9.9.4-72.el7.x86_64.rpm \
    bind-libs-9.9.4-72.el7.x86_64.rpm \
    policycoreutils-python-2.5-29.el7.x86_64.rpm \
    python-ply-3.4-11.el7.noarch.rpm \
    audit-libs-python-2.8.4-4.el7.x86_64.rpm \
    checkpolicy-2.5-8.el7.x86_64.rpm \
    setools-libs-3.3.8-4.el7.x86_64.rpm \
    libcgroup-0.41-20.el7.x86_64.rpm \
    libsemanage-python-2.5-14.el7.x86_64.rpm \
    python-IPy-0.75-6.el7.noarch.rpm

    systemctl daemon-reload
    systemctl enable named.service
    systemctl start named.service

 ・ImageMagick

    cd /Packages
    rpm -ivh \
    cups-libs-1.6.3-35.el7.x86_64.rpm  dejavu-fonts-common-2.33-6.el7.noarch.rpm \
    dejavu-sans-fonts-2.33-6.el7.noarch.rpm fontconfig-2.13.0-4.3.el7.x86_64.rpm \
    fontpackages-filesystem-1.44-8.el7.noarch.rpm fribidi-1.0.2-1.el7.x86_64.rpm \
    gdk-pixbuf2-2.36.12-3.el7.x86_64.rpm ghostscript-9.07-31.el7.x86_64.rpm \
    ghostscript-fonts-5.50-32.el7.noarch.rpm graphite2-1.3.10-1.el7_3.x86_64.rpm \
    harfbuzz-1.7.5-2.el7.x86_64.rpm ilmbase-1.0.3-7.el7.x86_64.rpm \
    ImageMagick-6.7.8.9-15.el7_2.x86_64.rpm jasper-libs-1.900.1-33.el7.x86_64.rpm \
    jbigkit-libs-2.0-11.el7.x86_64.rpm lcms2-2.6-3.el7.x86_64.rpm \
    libfontenc-1.1.3-3.el7.x86_64.rpm libgsf-1.14.26-7.el7.x86_64.rpm \
    libICE-1.0.9-9.el7.x86_64.rpm libjpeg-turbo-1.2.90-6.el7.x86_64.rpm \
    librsvg2-2.40.20-1.el7.x86_64.rpm libSM-1.2.2-2.el7.x86_64.rpm \
    libthai-0.1.14-9.el7.x86_64.rpm libtiff-4.0.3-27.el7_3.x86_64.rpm \
    libwmf-lite-0.2.8.4-41.el7_1.x86_64.rpm libX11-1.6.5-2.el7.x86_64.rpm \
    libX11-common-1.6.5-2.el7.noarch.rpm libXau-1.0.8-2.1.el7.x86_64.rpm \
    libxcb-1.13-1.el7.x86_64.rpm libXext-1.3.3-3.el7.x86_64.rpm \
    libXft-2.3.2-2.el7.x86_64.rpm libXrender-0.9.10-1.el7.x86_64.rpm \
    libXt-1.1.5-3.el7.x86_64.rpm OpenEXR-libs-1.7.1-7.el7.x86_64.rpm \
    pango-1.42.4-1.el7.x86_64.rpm poppler-data-0.4.6-3.el7.noarch.rpm \
    urw-fonts-2.4-16.el7.noarch.rpm xorg-x11-font-utils-7.5-21.el7.x86_64.rpm \
    cairo-1.15.12-3.el7.x86_64.rpm libtool-ltdl-2.4.2-22.el7_3.x86_64.rpm \
    libglvnd-egl-1.0.1-0.8.git5baa1e5.el7.x86_64.rpm mesa-libEGL-18.0.5-3.el7.x86_64.rpm \
    mesa-libgbm-18.0.5-3.el7.x86_64.rpm mesa-libglapi-18.0.5-3.el7.x86_64.rpm \
    libwayland-server-1.15.0-1.el7.x86_64.rpm libxshmfence-1.2-1.el7.x86_64.rpm \
    libwayland-client-1.15.0-1.el7.x86_64.rpm libglvnd-1.0.1-0.8.git5baa1e5.el7.x86_64.rpm \
    libglvnd-glx-1.0.1-0.8.git5baa1e5.el7.x86_64.rpm mesa-libGL-18.0.5-3.el7.x86_64.rpm \
    libXdamage-1.1.4-4.1.el7.x86_64.rpm libXfixes-5.0.3-1.el7.x86_64.rpm \
    libXxf86vm-1.1.4-1.el7.x86_64.rpm pixman-0.34.0-1.el7.x86_64.rpm \
    avahi-libs-0.6.31-19.el7.x86_64.rpm

 ・perl

    cd /Packages
    rpm -ivh perl-5.16.3-293.el7.x86_64.rpm perl-macros-5.16.3-293.el7.x86_64.rpm \
    perl-libs-5.16.3-293.el7.x86_64.rpm perl-threads-shared-1.43-6.el7.x86_64.rpm \
    perl-threads-1.87-4.el7.x86_64.rpm perl-Carp-1.26-244.el7.noarch.rpm \
    perl-Exporter-5.68-3.el7.noarch.rpm perl-Scalar-List-Utils-1.27-248.el7.x86_64.rpm \
    perl-constant-1.27-2.el7.noarch.rpm perl-Time-Local-1.2300-2.el7.noarch.rpm \
    perl-Time-HiRes-1.9725-3.el7.x86_64.rpm perl-Storable-2.45-3.el7.x86_64.rpm \
    perl-Socket-2.010-4.el7.x86_64.rpm perl-Pod-Simple-3.28-4.el7.noarch.rpm \
    perl-Pod-Escapes-1.04-293.el7.noarch.rpm perl-Getopt-Long-2.40-3.el7.noarch.rpm \
    perl-Text-ParseWords-3.29-4.el7.noarch.rpm perl-Pod-Usage-1.63-3.el7.noarch.rpm \
    perl-Pod-Perldoc-3.20-4.el7.noarch.rpm perl-parent-0.225-244.el7.noarch.rpm \
    perl-File-Path-2.09-2.el7.noarch.rpm perl-File-Temp-0.23.01-3.el7.noarch.rpm \
    perl-HTTP-Tiny-0.033-3.el7.noarch.rpm perl-Encode-2.51-7.el7.x86_64.rpm \
    perl-PathTools-3.40-5.el7.x86_64.rpm perl-podlators-2.5.1-3.el7.noarch.rpm \
    perl-Filter-1.49-3.el7.x86_64.rpm

 ・emacs

    cd /Packages
    rpm -ivh \
    emacs-24.3-22.el7.x86_64.rpm emacs-common-24.3-22.el7.x86_64.rpm \
    dejavu-sans-mono-fonts-2.33-6.el7.noarch.rpm libXpm-3.5.12-1.el7.x86_64.rpm \
    cairo-gobject-1.15.12-3.el7.x86_64.rpm atk-2.28.1-1.el7.x86_64.rpm \
    GConf2-3.2.6-8.el7.x86_64.rpm psmisc-22.20-15.el7.x86_64.rpm \
    liblockfile-1.08-17.el7.x86_64.rpm libotf-0.9.13-4.el7.x86_64.rpm \
    libXmu-1.1.2-2.el7.x86_64.rpm libXaw-1.0.13-4.el7.x86_64.rpm \
    m17n-lib-1.6.4-14.el7.x86_64.rpm m17n-db-1.6.4-4.el7.noarch.rpm \
    giflib-4.1.6-9.el7.x86_64.rpm gtk3-3.22.30-3.el7.x86_64.rpm \
    adwaita-icon-theme-3.28.0-1.el7.noarch.rpm dconf-0.28.0-4.el7.x86_64.rpm \
    gtk-update-icon-cache-3.22.30-3.el7.x86_64.rpm hicolor-icon-theme-0.12-7.el7.noarch.rpm \
    libXcomposite-0.4.4-4.1.el7.x86_64.rpm libXcursor-1.1.15-1.el7.x86_64.rpm \
    libXi-1.7.9-1.el7.x86_64.rpm libXinerama-1.1.3-2.1.el7.x86_64.rpm \
    libXrandr-1.5.1-2.el7.x86_64.rpm at-spi2-atk-2.26.2-1.el7.x86_64.rpm \
    colord-libs-1.3.4-1.el7.x86_64.rpm libepoxy-1.5.2-1.el7.x86_64.rpm \
    json-glib-1.4.2-2.el7.x86_64.rpm rest-0.8.1-2.el7.x86_64.rpm \
    libwayland-cursor-1.15.0-1.el7.x86_64.rpm libwayland-egl-1.15.0-1.el7.x86_64.rpm \
    libxkbcommon-0.7.1-1.el7.x86_64.rpm adwaita-cursor-theme-3.28.0-1.el7.noarch.rpm \
    at-spi2-core-2.28.0-1.el7.x86_64.rpm libgusb-0.2.9-1.el7.x86_64.rpm \
    libsoup-2.62.2-2.el7.x86_64.rpm xkeyboard-config-2.24-1.el7.noarch.rpm \
    libXtst-1.2.3-1.el7.x86_64.rpm glib-networking-2.56.1-1.el7.x86_64.rpm \
    gsettings-desktop-schemas-3.28.0-2.el7.x86_64.rpm desktop-file-utils-0.23-1.el7.x86_64.rpm \
    libusbx-1.0.21-1.el7.x86_64.rpm gnutls-3.3.29-8.el7.x86_64.rpm \
    emacs-filesystem-24.3-22.el7.noarch.rpm trousers-0.3.14-2.el7.x86_64.rpm \
    nettle-2.7.1-8.el7.x86_64.rpm libproxy-0.4.11-11.el7.x86_64.rpm \
    libmodman-2.0.1-8.el7.x86_64.rpm

 ・lynx, wget

    cd /Packages
    rpm -ivh lynx-2.8.8-0.3.dev15.el7.x86_64.rpm centos-indexhtml-7-9.el7.centos.noarch.rpm
    rpm -ivh wget-1.14-18.el7.x86_64.rpm

 ・zip, unzip

    cd /Packages
    rpm -ivh zip-3.0-11.el7.x86_64.rpm unzip-6.0-19.el7.x86_64.rpm

 ・nkf

    cd ~/wrk
    unzip nkf-master.zip
    cd nkf-master
    make
    cp nkf /usr/local/bin
    cd ..
    rm -Rf nkf-master*

 ・MariaDB

    cd /Packages
    rpm -ev --nodeps mariadb-libs-5.5.60-1.el7_5.x86_64
    rpm -ivh jemalloc-3.6.0-1.el7.x86_64.rpm jemalloc-devel-3.6.0-1.el7.x86_64.rpm
    rpm -ivh \
    galera-4-26.4.2-1.rhel7.el7.centos.x86_64.rpm \
    boost-program-options-1.53.0-27.el7.x86_64.rpm
    rpm -ivh MariaDB-10.4.6-1.el7.centos.src.rpm
    rpm -ivh \
    MariaDB-server-10.4.6-1.el7.centos.x86_64.rpm \
    MariaDB-common-10.4.6-1.el7.centos.x86_64.rpm \
    MariaDB-client-10.4.6-1.el7.centos.x86_64.rpm \
    MariaDB-compat-10.4.6-1.el7.centos.x86_64.rpm \
    rsync-3.1.2-4.el7.x86_64.rpm \
    lsof-4.87-6.el7.x86_64.rpm \
    perl-DBI-1.627-4.el7.x86_64.rpm \
    perl-Data-Dumper-2.145-3.el7.x86_64.rpm \
    perl-PlRPC-0.2020-14.el7.noarch.rpm \
    perl-IO-Compress-2.061-2.el7.noarch.rpm \
    perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64.rpm \
    perl-Compress-Raw-Zlib-2.061-4.el7.x86_64.rpm \
    perl-Net-Daemon-0.48-5.el7.noarch.rpm

  ・PostgreSQL

    cd /Packages
    rpm -ivh \
    postgresql-server-9.2.24-1.el7_5.x86_64.rpm \
    postgresql-9.2.24-1.el7_5.x86_64.rpm \
    postgresql-libs-9.2.24-1.el7_5.x86_64.rpm \
    postgresql-devel-9.2.24-1.el7_5.x86_64.rpm

 ・Apache Web Server : HTTPD

    cd /Packages
    rpm -ivh \
    mailcap-2.1.41-2.el7.noarch.rpm \
    httpd-devel-2.4.6-88.el7.centos.x86_64.rpm \
    httpd-2.4.6-88.el7.centos.x86_64.rpm \
    apr-devel-1.4.8-3.el7_4.1.x86_64.rpm \
    apr-util-devel-1.5.2-6.el7.x86_64.rpm \
    httpd-tools-2.4.6-88.el7.centos.x86_64.rpm \
    expat-devel-2.1.0-10.el7_3.x86_64.rpm \
    libdb-devel-5.3.21-24.el7.x86_64.rpm \
    openldap-devel-2.4.44-20.el7.x86_64.rpm \
    cyrus-sasl-devel-2.1.26-23.el7.x86_64.rpm \
    mod_ssl-2.4.6-88.el7.centos.x86_64.rpm \
    cyrus-sasl-2.1.26-23.el7.x86_64.rpm \
    apr-1.4.8-3.el7_4.1.x86_64.rpm \
    apr-util-1.5.2-6.el7.x86_64.rpm

 ・PHP7

    cd /Packages
    rpm -ivh \
    libxml2-devel-2.9.1-6.el7_2.3.x86_64.rpm \
    zlib-devel-1.2.7-18.el7.x86_64.rpm \
    xz-devel-5.2.2-1.el7.x86_64.rpm \
    openssl-devel-1.0.2k-16.el7.x86_64.rpm \
    krb5-devel-1.15.1-34.el7.x86_64.rpm \
    keyutils-libs-devel-1.5.8-3.el7.x86_64.rpm \
    libverto-devel-0.2.5-4.el7.x86_64.rpm \
    libcom_err-devel-1.42.9-13.el7.x86_64.rpm \
    libkadm5-1.15.1-34.el7.x86_64.rpm \
    libselinux-devel-2.5-14.1.el7.x86_64.rpm \
    libsepol-devel-2.5-10.el7.x86_64.rpm \
    pcre-devel-8.32-17.el7.x86_64.rpm \
    bzip2-devel-1.0.6-13.el7.x86_64.rpm \
    libzip-0.10.1-8.el7.x86_64.rpm \
    libcurl-devel-7.29.0-51.el7.x86_64.rpm

    cd /usr/local/src
    tar xzf ~/wrk/php-7.3.9.tar.gz
    rm -f ~/wrk/php-7.3.9.tar.gz
    cd /usr/local/src/php-7.3.9
    ./configure \
    --enable-mbstring --enable-zip \
    --enable-bcmath --enable-pcntl \
    --enable-ftp --enable-exif \
    --enable-calendar --enable-sysvmsg \
    --enable-sysvsem --enable-sysvshm \
    --enable-wddx --enable-mysqlnd \
    --without-libzip --with-curl \
    --with-iconv --with-openssl \
    --with-gettext --with-zlib \
    --with-bz2 --with-mysqli=mysqlnd \
    --with-pdo-mysql=mysqlnd --with-pgsql=/usr/lib64/pgsql \
    --with-pdo-pgsql --with-apxs2=/usr/bin/apxs
    make && make install

 ・Node.js

    cd /usr/local/src
    tar xf ~/wrk/node-v8.14.0-linux-x64.tar.xz
    rm -f ~/wrk/node-v8.14.0-linux-x64.tar.xz
    cd /usr/local/bin
    ln -s /usr/local/src/node-v8.14.0-linux-x64/bin/node node
    ln -s /usr/local/src/node-v8.14.0-linux-x64/bin/npm npm

 ・Redis

    cd /usr/local/src
    tar xzf ~/wrk/redis-5.0.5.tar.gz
    rm -f ~/wrk/redis-5.0.5.tar.gz
    cd /usr/local/src/redis-5.0.5
    make && make install

 ・yorozuya

    cd /usr/local/src
    tar xzf ~/wrk/yorozuya.tgz
    rm -f ~/wrk/yorozuya.tgz
    cd yorozuya
    make
    cd /usr/local/bin
    ln -s /usr/local/src/yorozuya/yorozuya yorozuya
    ln -s /usr/local/src/yorozuya/yorozuyad yorozuyad

 ・TeX

    cd /Packages
    rpm -ivh perl-Digest-MD5-2.52-3.el7.x86_64.rpm perl-Digest-1.17-245.el7.noarch.rpm
    mount -o loop -t iso9660 ~/wrk/texlive2019-20190410.iso /mnt
    cd /mnt
    ./install-tl

Actions:
 <I> start installation to hard disk

    cd
    umount /mnt
    rm -f ~/wrk/texlive2019-20190410.iso
 
    vi /etc/bashrc
<<< 追加
if [ -z ${PATH} ]; then
    export PATH=/usr/local/texlive/2019/bin/x86_64-linux
else
    export PATH=$PATH:/usr/local/texlive/2019/bin/x86_64-linux
fi

if [ -z ${MANPATH} ]; then
    export MANPATH=/usr/local/texlive/2019/texmf-dist/doc/man
else
    export MANPATH=$MANPATH:/usr/local/texlive/2019/texmf-dist/doc/man
fi

if [ -z ${INFOPATH} ]; then
    export INFOPATH=/usr/local/texlive/2019/texmf-dist/doc/info
else
    export INFOPATH=$INFOPATH:/usr/local/texlive/2019/texmf-dist/doc/info
fi

export PATH=$PATH:/usr/local/src/node-v8.14.0-linux-x64/bin
>>>

  ・Restart

    shutdown -r now

--------------------------------------------------------------------------------

・ミドルウェアの設定

 ・MariaDB # Restart後なのでMariaサーバが立ち上がっている。

    mysql_secure_installation

Set root password only.

    mysql -u root -p

    cp -R /etc/my.cnf.d /etc/_my.cnf.d
    cd /etc/my.cnf.d
    vi server.cnf

    diff server.cnf ../_my.cnf.d/server.cnf
13,16d12
< character-set-server = utf8mb4
<
< [client]
< default-character-set = utf8mb4

    systemctl restart mysqld

 ・Redis

    groupadd redis
    useradd -s /sbin/nologin -M -g redis redis
    mkdir /etc/redis
    mkdir /var/log/redis
    chmod 755 /etc/redis
    chmod 755 /var/log/redis
    chown redis:redis /etc/redis
    chown redis:redis /var/log/redis
    cp /usr/local/src/redis-5.0.5/redis.conf /etc/redis/6379.conf

    vi /etc/redis/6379.conf
    diff /usr/local/src/redis-5.0.5/redis.conf /etc/redis/6379.conf
147c147
< supervised no
---
> supervised systemd
171c171
< logfile ""
---
> logfile "/var/log/redis/6379.log"
253c253
< dbfilename dump.rdb
---
> dbfilename 6379.rdb
263c263
< dir ./
---
> dir /var/log/redis
507c507
< # requirepass foobared
---
> requirepass anyPassword
539c539
< # maxclients 10000
---
> maxclients 1024

    vi /etc/systemd/system/redis_6379.service
    cat /etc/systemd/system/redis_6379.service
[Unit]
Description=Redis

[Service]
Type=notify
ExecStart=/usr/local/bin/redis-server /etc/redis/6379.conf
ExecStop=/usr/local/bin/redis-cli -p 6379 -a anyPassword shutdown
User=redis
Group=redis

[Install]
WantedBy=multi-user.target

    systemctl daemon-reload
    systemctl start redis_6379
    systemctl status redis_6379
    systemctl enable redis_6379

 ・Apache WEB Server

    systemctl daemon-reload
    systemctl start httpd
    systemctl enable httpd

 ・Node

    mkdir -p ~/dev/sample01

    shutdown -h now
<<< npmインストール部分はNAT環境で外部接続可能とします。

    cd ~/dev/sample01

    npm install -g npm               <-- Update
    npm install -g express-generator
    express --css stylus myapp
    cd myapp
    npm install
    npm install socket.io
    npm install socket.io-emitter
    npm install socket.io-redis
    npm install ioredis

    shutdown -h now
>>> 再びhost-only-adapter.

    cd ~/dev/sample01/myapp
    DEBUG=myapp:* npm start
    ^Cで終了可能

他のterminalで
lynx 127.0.0.1:3000

  ・Node デーモン化

    vi /etc/systemd/system/node.service
    cat /etc/systemd/system/node.service

[Unit]
Description=Node.js Server

[Service]
WorkingDirectory=/root/dev/sample01/myapp
Type=simple
ExecStart=/root/dev/sample01/myapp/bin/www
Restart=always
RestartSec=10
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=node-server
Environment=NODE_ENV=production PORT=3000
User=root
Group=root

[Install]
WantedBy=multi-user.target

    systemctl daemon-reload
    systemctl start node
    systemctl status node
    systemctl enable node

  ・Firewallの設定

    ・現在のサービスの公開状態の確認
    firewall-cmd --list-services --zone=public

    vi /etc/firewalld/services/node.xml
    cat /etc/firewalld/services/node.xml

<?xml version="1.0" encoding="utf-8"?>
<service>
  <short>Node.js</short>
  <description>Service for SocketIO</description>
  <port protocol="tcp" port="3000"/>
</service>

    firewall-cmd --add-service=node --zone=public --permanent
    firewall-cmd --reload
    firewall-cmd --list-services --zone=public

 ・HTTPD, PHP

    cd /etc/httpd/conf
    cp httpd.conf _httpd.conf
    vi httpd.conf
    diff _httpd.conf httpd.conf
104c104
<     AllowOverride none
---
>     AllowOverride All
126c126
<     AllowOverride None
---
>     AllowOverride All
152c152
<     AllowOverride None
---
>     AllowOverride FileInfo
165c165
<     DirectoryIndex index.html
---
>     DirectoryIndex index.php index.html
354a355,360
>
> #
> # PHP
> #
> AddType application/x-httpd-php .php
> AddType application/x-httpd-php-source .phps

    cp /usr/local/src/php-7.3.9/php.ini-development /usr/local/lib/php.ini
    vi /usr/local/lib/php.ini
    diff /usr/local/src/php-7.3.9/php.ini-development /usr/local/lib/php.ini
581c581
< ;error_log = syslog
---
> error_log = /var/log/php_error.log
954c954
< ;date.timezone =
---
> date.timezone = Asia/Tokyo
1048c1048
< pdo_mysql.default_socket=
---
> pdo_mysql.default_socket=/var/lib/mysql/mysql.sock
1336c1336
< session.save_handler = files
---
> session.save_handler = redis
1365c1365
< ;session.save_path = "/tmp"
---
> session.save_path = "tcp://127.0.0.1:6379?weight=1"

    touch /var/log/php_error.log
    chmod 666 /var/log/php_error.log
    systemctl restart httpd

--------------------------------------------------------------------------------

・その他の設定

  ・Webサーバー(http, https)のサービス(ポート)を永続的に許可
    間違えて設定してしまった場合は「add」の箇所を「remove」にする。

    firewall-cmd --permanent --add-service=http
    firewall-cmd --permanent --add-service=https
    firewall-cmd --reload

  ・現在有効な機能とゾーンを一覧表示します。

    firewall-cmd --list-all
    firewall-cmd --list-all-zones
    firewall-cmd --list-all --permanent

  ・アクティブゾーンの確認

    firewall-cmd --get-active-zones

  ・設定内容の確認

    less /etc/firewalld/zones/public.xml

  ・設定内容の確認 個別 https

    ls /usr/lib/firewalld/services
    less /usr/lib/firewalld/services/https.xml

  ・emacs

    cd
    vi .emacs
    cat .emacs
(setq-default tab-width 4 indent-tabs-mode nil)

(add-hook 'php-mode-hook
          (lambda ()
            (setq tab-width 4)
            (setq c-basic-offset 4)))

    vi .bashrc
alias ls='ls'
alias ll='ls -la'
alias e='emacs'
alias delb='rm -f *~ .??*~'

--------------------------------------------------------------------------------

  ・Reboot

    shutdown -r now

--------------------------------------------------------------------------------

EOL

--------------------------------------------------------------------------------