www.smiyasaka.com は、 2022 年 11月から Oracle LInux 8.X にOSを変更しました。

●   CentOS 7.9.2009 と httpd-2.4.53 の
インストールと自宅サーバ構築   ●

アクセス数 昨日 1 今日 2
  累計 32,956   


CentOS-7-x86_64-DVD-2009.iso使 yum 

20225 Linux 3.10.0-1160.66.1.el7.x86_64 

openssl + nghttp2 + Brotli + httpd-2.4.53 

SELinux 
 (  )

 vsftpd Tera Term 使 windows PC 
vsftpd    ffftp  Windows PC ( Tera Term 使 ) web 

      2024630
※ 注 意 事 項 ※ を見る[ここをクリック]

目    次
[○○○○]のクリックで、その内容が目次の下に表示、再度クリックで非表示になります。

  ※ [ 総てを表示する ] ※ [ 総てを表示する 非表示 ] ※

   0. [ 現在稼働中のサーバ機のスペック ] [ 現在稼働中のサーバ機のスペック 非表示 ]

   1. [ CentOS 7-x86_64 のインストール ] [ CentOS 7-x86_64 のインストール 非表示 ]

   2. [ CentOS 7 再起動後のコンソールからの各種設定(SELinux を含む) ] [ CentOS 7 再起動後のコンソールからの各種設定(SELinux を含む) 非表示 ]

   3. [ 事前にダウンロードするファイル一覧と探し方 ] [ 事前にダウンロードするファイル一覧と探し方 非表示 ]

   4. [ セキュリティ対策のため停止したサービス ] [ セキュリティ対策のため停止したサービス 非表示 ]

   5. [ ファイアウォール( firewalld )と Systemd ] [ ファイアウォール( firewalld )と Systemd 非表示 ]

   6. [ Tera Termでvsftpd( FTPサーバ )を転送しインストール ] [ Tera Termでvsftpd( FTPサーバ )を転送しインストール 非表示 ]

   7. [ ファイルの転送プログラムの作成 ] [ ファイルの転送プログラムの作成 非表示 ]

   8. [ サーバの時刻を日本標準時に同期させる ] [ サーバの時刻を日本標準時に同期させる 非表示 ]

   9. [ リポジトリを導入する ] [ リポジトリを導入する 非表示 ]

10-1. [ apache2( httpd-2.4.53 )のインストールと設定 ] [ apache2( httpd-2.4.53 )のインストールと設定 非表示 ]

10-2. [ SELinux を有効にした時の apache2 のポリシー設定 ] [ SELinux を有効にした時の apache2 のポリシー設定 非表示 ]

10-3. [ apache2 の SSL 化の手順と httpd.conf、httpd_ssl.conf の設定 ] [ apache2 の SSL 化の手順と httpd.conf、httpd_ssl.conf の設定 非表示 ]

10-4. [ nghttp2 を使用して SSL プロトコル HTTP/1.1, HTTP/2 対応の設定 ] [ nghttp2 を使用して SSL プロトコル HTTP/1.1, HTTP/2 対応の設定 非表示 ]

10-5. [ 圧縮パッケージ Brotli を使用しての圧縮処理の追加 ] [ 圧縮パッケージ Brotli を使用しての圧縮処理の追加 非表示 ]

  11. [ fswebcom-20200725.tar.gz のインストールと定点カメラの設定 ] [ fswebcom-20200725.tar.gz のインストールと定点カメラの設定 非表示 ]

  12. [ clamav( アンチウィルスソフト )のインストール ] [ clamav( アンチウィルスソフト )のインストール 非表示 ]

  13. [ chkrootkitの導入 ] [ chkrootkitの導入 非表示 ]

  14. [ sendmail のインストール ] [ sendmail のインストール 非表示 ]

  15. [ Logwatch のインストールと毎日のメールを簡単にチェックする方法 ] [ Logwatch のインストールと毎日のメールを簡単にチェックする方法 非表示 ]

  16. [ 漢字コード変換用に nkf のインストール ] [ 漢字コード変換用に nkf のインストール 非表示 ]

  17. [ 自前プログラムでダイナミック DNS を定期更新させる。 ] [ 自前プログラムでダイナミック DNS を定期更新させる。 非表示 ]

  18. [ 自宅サーバの管理・運用監視等 ] [ 自宅サーバの管理・運用監視等 非表示 ]


0. 現在稼働中のサーバ機のスペック


このウェブサイトは、
下記のシステム仕様で小型パソコンを使用して私の自宅から発信しています。


サーバ機の OS は、 Oracle Linux 8.10  64bit
  Web サーバは、 httpd-2.4.62  を使用して運用しています。
SELinux mode : Enforcing ( 有効 )
SSL 認証鍵の証明書 = Let's Encrypt を使用・SSL プロトコル HTTP/2 に対応
( Let's Encrypt は、一か月毎更新しています。 )
カーネルのバージョンは、2024.07.17 に更新された
  Kernel 5.15.0-208.159.3.2.el8uek.x86_64 です。

[ サーバ機 連続稼働時間 21 時間 27 分 SSD 機器温度 30 ]
[ SSD 稼動時間 15,007 時間 ( 625 7 時間 ) ]
[ CPU 利用率 1.29 % CPU 温度 +40 ]

稼 働 中 サ ー バ 機 の ス ペ ッ ク
-------------------------------------------------------------------------
私の自宅サーバ機のスペック
型   式 :
Mouse Pro-M591F-WA CPU : Intel i3-7100U 2コア/4スレッド 2.40GHz
消費電力 : 約 10W   メ モ リ : 8GBSSD : 128GB
インターネット回線 : STNet 光回線(ギガビット対応)
USBカメラ : Logicool UVC対応 C270sCW 120万画素(固定焦点)
-------------------------------------------------------------------------

1. CentOS 7-x86_64 のインストール


CentOS-7-x86_64-DVD-2009.iso
20201104 CentOS 7.9.2009 

CentOS 7  2024 630

[ CentOS 7.9.2009 ] 


httpd  2.4.6   2.4.52 
 10-1. apache2( httpd-2.4.53 ) 
  
(
) iso  使



 onkyo PC  CentOS 7.5 


(2)[Tab]


vmlinuz initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 rd.live.check quiet_

quiet_  [] + resolution=1024x768  [Enter]

[=][^]使  XGA 

[ CentOS-7.X DVD  ] 
            []


2. CentOS 7 再起動後のコンソールからの各種設定( SELinux を含む )ル


GNOME()

  [ root ][ root  ]

   ( tara Term  )
 
echo $LANG

 ( locale )
vi /etc/locale.conf

  言語  国 文字コード
  ↓ ↓  ↓
  ja_JP.UTF-8 ---> ja_JP.eucJP

    または、localectl set-locale LANG="ja_JP.eucJP" で変更する。

  SELinux  
  SELinux  

  SELinux 

[ CentOS 7 SELinux  ] 
            []

  WindowsTera Term 

  sshd 
    vi /etc/ssh/sshd_config

 #Port 22 #  Port 2222 

 22SELinux  Tera Term   

 -1 Port 2222 (  )

 ( --permanent )
      firewall-cmd --zone=public --add-port=2222/tcp --permanent

 success OK

 firewall  --zone=public  zone public    zone=public 

 -2 
      firewall-cmd --reload

 success OK

   

  2222 (22) Tera Term 
  SELinux  Tera Term   
  2222 

  sshd

 sshd 

  SELinux 

  Tera Term 
   vi /etc/sysconfig/selinux

  SELINUX=enforcing  ----> SELINUX=disabled に変更する。

   
SELinux  permissive enforcing 
 SELinux 

SELinux enforcing 

  
  groupinstall 
 +: 797
 (    yum -y update  Base   
 )
    yum -y groupinstall "Base" "Additional Development"

 groupinstall  update 

 yum -y groupinstall "Base" "Additional Development" && yum -y update && poweroff

   Minimal "Development" 

  ( firewalld )

 

 systemctl status firewalld  

 firewalld.service - firewalld - dynamic firewall daemon
    Loaded: loaded (/usr/l……/system/firewalld.service; enabled)
    Active: active (running) si……ago
  Main PID: 567 (firewalld)

    

  

  update 

 yum -y update && reboot poweroff

 poweroff 
  sshd 

 ( TCP Wrapper  SSH  )

 
 PC

 hosts.allowhosts.deny(IP )

 hosts.allow hosts.allow IP

 -1 /etc/hosts.deny  sshd:ALL (  )
     vi /etc/hosts.deny で sshd:ALL  または、

     echo "sshd:ALL" >> /etc/hosts.deny

 -2 /etc/hosts.allow IP

 vi /etc/hosts.allow  sshd:192.168.0. 
     echo "sshd:192.168.0." >> /etc/hosts.allow

 192.168.0. IP

Tera Term  EUC 
 TCP2222 

windowsTera Term 使
Tera Term -EUC 使

Tera Term使 Tera Term 
Tera Term 


※※ Tera Term で接続エラーになる時の解決策 ※※

コマンド netstat でアクティブなポート番号を確認します。

使用コマンド
netstat -plant

Tera Term で接続したいポート番号が無い時には、sshd をリスタートします。

使用コマンド
systemctl restart sshd

ここで再度ポート番号の確認をします。使用するポート番号がアクティブになっていれば接続できるはずです。


3. 事前にダウンロードするファイル一覧と探し方


rpm [ RPM Search ]



( )

    CentOS 7  rpm el7.x86_64.rpm 
    ( tar )32bit64bit 

---------------------------------------------------------------
ftp
 proftpd-1.3.6.tar.gz
 vsftpd-3.0.2-25.el7.x86_64.rpm
 ftp-0.17-67.el7.x86_64.rpm
---------------------------------------------------------------
RPMforge
 yum-plugin-priorities-1.1.31-42.el7.noarch.rpmm
 rpmforge-release-0.5.3-1.el7.rf.x86_64.rpm
---------------------------------------------------------------
httpd
 httpd-2.4.XX.tar.gz
 (httpd-2.4.53) httpd 
 apr-1.7.0.tar.gz 
apr-util-1.6.1.tar.gz
 openssl-1.1.1X.tar.gz
 nghttp2-1.XX.X.tar.gz
 brotli-1.0.X.tar.gz
---------------------------------------------------------------
fswebcam
 fswebcam-20100622.tar.gz
 gd-progs-2.0.35-26.el7.x86_64.rpm
 gd-devel-2.0.35-26.el7.x86_64.rpm
---------------------------------------------------------------
sendmail
 hesiod-3.2.1-3.el76.x86_64.rpm
 procmail-3.22-36.el7.x86_64.rpm
 sendmail-8.14.7-5.el7.x86_64.rpm
---------------------------------------------------------------
logwatch
 logwatch-7.5.4-1.noarch.rpm
---------------------------------------------------------------
clamav 
libprelude-5.2.0-2.el7.x86_64.rpm
 pcre2-10.23-2.el7.x86_64.rpm
 clamav-filesystem-0.103.2-1.el7.noarch.rpm
 clamav-data-0.103.2-1.el7.noarch.rpm
 clamav-lib-0.103.2-12.el7.x86_64.rpm
 clamav-update-0.103.2-1.el7.x86_64.rpm
 clamav-0.103.2-1.el7.x86_64.rpm
---------------------------------------------------------------
chkrootkit
 chkrootkit.tar.gz
 glibc-static-2.17-55.el7_0.1.x86_64.rpm
---------------------------------------------------------------
 nkf-2.1.5.tar.gz
 Jcode-2.07.tar.gz
---------------------------------------------------------------
sensors
 lm_sensors-3.4.0-8.20160601gitf9185e5.el7.x86_64.rpm

4. セキュリティ対策のため停止したサービス

暫定的に停止したサービスは、下記のとおりです。
( 試しに、不要と思われるサービスを停止 及び 再起動後も停止にしています。)


#!/bin/sh
systemctl stop atd.service
systemctl disable atd.service
systemctl stop auditd.service
systemctl disable auditd.service
systemctl stop dmraid-activation.service
systemctl disable dmraid-activation.service
systemctl stop kdump.service
systemctl disable kdump.service
systemctl stop lvm2-monitor.service
systemctl disable lvm2-monitor.service
systemctl stop mdmonitor.service
systemctl disable mdmonitor.service
systemctl stop microcode.service
systemctl disable microcode.service
systemctl stop postfix.service
systemctl disable postfix.service
systemctl stop rngd.service
systemctl disable rngd.service
systemctl stop smartd.service
systemctl disable smartd.service
systemctl stop tuned.service
systemctl disable tuned.service
systemctl stop dm-event.socket
systemctl disable dm-event.socket
systemctl stop lvm2-lvmetad.socket
echo "サービス_STOP 完了"

属性を変更して、実行します。

chmod 755 service_stop.sh;sh service_stop.sh

 サービス名
atd
auditd。
dmraid-activation
kdump
 
lvm2-monitor
mdmonitor
microcode
postfix
rngd
smartd
tuned
lvm2-lvmetad


  
#   
# 
# ???
# dump
 
# (LVM) 
# RAID 
# CPU
# 
#  
# S.M.A.R.T.
# CPUCPU
# ???

  
IEEE802.1X/WPALAN ( wpa_supplicant )  wpa_supplicant disable 


wpa_supplicant  systemd
ONKYO PC mousePC 

 wpa_supplicant 

 vi /usr/local/src/wpa_supplicant_stop.sh
  #!/bin/bash
  # wpa_supplicant を停止するコマンド実行

  systemctl stop wpa_supplicant
 wpa_supplicant_stop.sh に実行権限を付加します。

 chmod 755 /usr/local/src/wpa_supplicant_stop.sh

② wpa_supplicant_stop.service という名のサービスを追加します。

 vi /usr/lib/systemd/system/wpa_supplicant_stop.service
 で下記をコピペする。
  [Unit]
  Description= wpa_supplicant_stop 
  After=network.target  <-- 先に起動しておいてほしいサービスを
                                 定義してます。
  [Service]
  Type=simple      <-- プロセスを起動するだけの指定。
  ExecStart=/usr/local/src/wpa_supplicant_stop.sh  <-- 起動する。
                           プロセスの指定。
  [Install]
  WantedBy=multi-user.target

UnitセクションのAfterで先に起動しておいてほしいサービスを定義してます。
Type=simpleは、コマンドを実行したタイミングで起動完了となります。

③ サーバー起動時に実行する様に設定する

  systemctl enable wpa_supplicant_stop


5. ファイアウォール( firewalld )と Systemd


 ( firewalld ) 

( firewalld )
SSL   443 
CentOS 7.X CentOS 6.X  iptables 

firewall-cmd --add-service=http --permanent
firewall-cmd --add-service=https --permanentine
firewall-cmd --add-service=ftp --permanent
firewall-cmd --add-service=ntp --permanent
firewall-cmd --remove-service=dhcpv6-client
--permanent
firewall-cmd --remove-service=ssh --permanent
firewall-cmd --add-port=2222/tcp --permanent
firewall-cmd --reload

<---- 80/tcp の有効化
<---- SSL 化の時 443/tcp の有効化
<---- 21/tcp の有効化
<---- 123/tcp の有効化
<---- 不要なので削除

<---- 22/tcp は、不要なので削除
<---- 2222/tcp の追加
<---- 設定を有効にする


   
   .service 
   --permanent 
   --zone=public  zone=public 

( firewalld )
  firewall-cmd --list-all

 
----------------------------------------------------------
public (default, active)
     interfaces: enp2s0
     sources: 
     services: ftp http ntp https
     ports: 2222/tcp
     protocols:
     masquerade: no
     forward-ports:
     source-ports:
     icmp-blocks:
     rich rules:

CentOS 7.X ( firewalld ) iptables 
 iptables-save 

    上 部 省 略

-A IN_public -p icmp -j ACCEPT
-A IN_public_allow -p tcp -m tcp --dport   80 -m…… NEW -j ACCEPT
-A IN_public_allow -p udp -m udp --dport  123 -m…… NEW -j ACCEPT
-A IN_public_allow -p tcp -m tcp --dport   21 -m…… NEW -j ACCEPT
-A IN_public_allow -p tcp -m tcp --dport  443 -m…… NEW -j ACCEPT
-A IN_public_allow -p tcp -m tcp --dport 2222 -m…… NEW -j ACCEPT
COMMIT

※※ ここからは、参考情報です。 ※※

 zone public ( public.xml ) のファイアウォール設定項目を直接編集する


zone public ( public.xml ) 


( ( public.xml )--add-service, --add-port  --permanent 
 )

public /etc/firewalld/zones/public.xml 

 dhcpv6-client, ssh  ntp, http, ftp 

 
public.xml 
 
  vi /etc/firewalld/zones/public.xml

<?xml version="1.0" encoding="utf-8"?>
<zone>
<short>Public</short>
<description>For use in public areas. You do not trust the other
computers on networks to not harm your computer. Only selected incoming
connections are accepted.</description>
<service name="ssh"/>       
<----- ここを修正
<service name="dhcpv6-client"/>  
<----- ここを修正
<port protocol="tcp" port="2222"/>   
<----- 追加したポート
</zone>


 
 
<service name="ssh"/>
 <service name="dhcpv6-client"/>
  
 <service name="ntp"/>  <---- 123/tcp 
 <service name="http"/>  <---- 80/tcp 
 <service name="ftp"/>    <---- 21/tcp 
 <service name="https"/>  <---- 443/tcp 

  sed 

  sed -i -e"s/ssh/ntp/g
  s/<service name=\"dhcpv6-client\"\/>/<service\
  name=\"http\"\/>\n\
  <service name=\"ftp\"\/>\n\<service name=\"https\"\/>/g"\
 /etc/firewalld/zones/public.xml

    編集保存したら、firewall-cmd --reload で設定を反映します。

 public 
  firewall-cmd --list-all
    -------------------------------------------------------------
      public (default, active)
      interfaces: enp2s0
      sources:
      services: ftp http ntp https    <-- 追加されたサービス
      ports: 2222/tcp
      protocols:
      masquerade: no
      forward-ports:
      source-ports:
      icmp-blocks:
      rich rules:

 Systemd でのサービスの管理と設定コマンド

CentOS 7.X ではサービスの管理は一部のサービスを除き systemd で行うといった仕様に変更と
なりました。


  
   systemctl stop firewalld.service

  # 

  
    systemctl disable firewalld.service   <---- 再起動後も無効にする。

  
    systemctl enable firewalld.service   <---- 再起動後も有効にする。

  OK
  ln -s '/usr/lib/systemd/system/firewalld.service' .......
  ln -s '/usr/lib/systemd/system/firewalld.service' .......

  
     systemctl start firewall.service

  # OK

  (  )

 proftpdvsftpdhttpd( apache ) 

 -1 proftpdvsftpd  21

  --permanent 
 --zone=public  zone=public 
        firewall-cmd --add-service=ftp --zone=public --permanent
firewall-cmd --reload

 firewall-cmd --reload 

  success  

 -2 httpd( apache )  80
       firewall-cmd --add-service=http --zone=public --permanent
firewall-cmd --reload

  success  

 -3 
        firewall-cmd --list-services --zone=public

 

  dhcpv6-client ftp http ssh

 -5 

  --add  --remove 

    systemctl enable disable 

  

 -1  Port 2222
 ( --permanent )
      firewall-cmd --zone=public --add-port=2222/tcp --permanent

  success OK

デフォルトで設定されている サービス ssh を編集してポートを変更する方法を下記に紹介します。

[ ssh のデフォルトポート(TCPの22番)の修正 ] の詳細は、

            [ここをクリック]してください。

⑥-2 設定を読込みこませて、有効にします。

      firewall-cmd --reload

  success が表示すれば OK

⑥-3 public ゾーンで許可されているポートの一覧確認コマンド

      firewall-cmd --zone=public --list-ports

  表示例 2222/tcp

⑥-4 public ゾーンで許可されているポート(例 2222 )の削除コマンド

      firewall-cmd --zone=public --remove-port=2222/tcp

  success が表示すれば OK

⑦ 有効なサービス( enable ) の一覧を表示する。

     systemctl list-unit-files | grep enable

  有効なサービス( enable ) 一覧の表示例

abrt-ccpp.service
abrt-oops.service 
abrt-vmcore.service
abrt-xorg.service 
abrtd.service  
avahi-daemon.service
chronyd.service
crond.service 
dbus-org.fedoraproject.FirewallD1.service
dbus-org.freedesktop.Avahi.service
dbus-org.freedesktop.NetworkManager.service
dbus-org.freedesktop.nm-dispatcher.service
firewalld.service
getty@.service 
irqbalance.service
libstoragemgmt.service
lm_sensors.service 
NetworkManager-dispatcher.service
NetworkManager.service
rsyslog.service
sendmail.service
sm-client.service 
sshd.service  
sysstat.service  

enabled
enabled
enabled
enabled
enabled
enabled
enabled
enabled
enabled
enabled
enabled
enabled
enabled
enabled
enabled
enabled
enabled
enabled
enabled
enabled
enabled
enabled
enabled
enabled


  ( service )

  ( TCP/UDP 
  firewall-cmd --add-service= --permanent) )

  firewall-cmd --get-services

  ( service )

amanda-client bacula bacula-client dhcp dhcpv6 dhcpv6-client dns ftp high-availability
http https imaps ipp ipp-client ipsec kerberos kpasswd ldap ldaps libvirt libvirt-tls mdns 
mountd ms-wbt mysql nfs ntp openvpn pmcd pmproxy pmwebapi pmwebapis pop3s postgresql 
proxy-dhcp radius rpc-bind samba samba-client smtp ssh telnet tftp tftp-client 
transmission-client vnc-server wbem-https

   service 

  

   service 

  systemctl .service /usr/lib/systemd/system/.service
  ( )

 -1 httpd-2.4.46  apache2.service 

  systemctl apache2  start, stop, enable, disable, status 
80  -2 

 vi /usr/lib/systemd/system/apache2.service )

[Unit]
Description=httpd-2.4.46 daemon  
<---- サービス名を書込みます。( コメント欄です。)

[Service]
Type=forking            
<---- 起動するプロセスをデーモン動作として起動する。
ExecStart=/usr/local/apache2/bin/apachectl start   
<---- サービス起動
ExecReload=/usr/local/apache2/bin/apachectl gracefu 
<---- httpデーモンを安全に再起動
ExecStopt=/usr/local/apache2/bin/apachectl stop   
<---- サービス停止

[Install]
WantedBy=multi-user.target     
<---- 旧来のrunlevel 3に相当する設定)

⑨-2 「起動」と「システム再起動時の自動起動」の設定

 
systemctl start apache2  <---- 起動
 
systemctl reload apache2 <---- 安全な再起動
 
systemctl enable apache2 <---- 自動起動の設定

以下の様な表示が出ます。( 本来は、一行表示です。 ))

ln -s '/usr/lib/systemd/system/apache2.service' '/etc/systemd/system/multi-
user.target.wants/apache2.service')

⑨-3 サービスとして追加されたかの確認

下記コマンドで有効なサービス( enable ) の一覧を表示します。
systemctl list-unit-files | grep enable)

          ( 省略 )
abrtd.service
apache2.service
avahi-daemon.service
chronyd.service
clamd.service
crond.service
dbus-org.fedoraproject.FirewallD1.service
dbus-org.freedesktop.NetworkManager.service
dbus-org.freedesktop.nm-dispatcher.service
DiCE.service
firewalld.service
           ( 省略 )


enabled
enabled<--- 追加

enabled
enabled
enabled
enabled
enabled
enabled
enabled
enabled
enabled

⑨-4 本ヘージでは、proftpd, apache, DiCE, clamd の ○○○○.service を作成しています。


6-1. Tera Termでproftpd( FTPサーバ )を転送しインストール

proftpd( FTPサーバ )をインストールするまでは、ffftpが、使用できないのでTera Termの転送
機能で、proftpd( FTPサーバ
proftpd-1.3.6.tar.gz )をホームディレクトリへ転送しインスト
ールします。

( Tera Termの転送機能は、ホームディレクトにしか書込みが出来ません。)


 Tera Term proftpd   

 [  ]
  1. Tera Term  []   <---  
  2.  SSH SCP...     <---  
  3.   [] <---  
写真 ①A 写真 ②B 写真 ③C

  4. 写真 ④ の様にファイルを選択するダイヤログ画面が開くので、
   proftpd-1.3.6.tar.gzを選択する(ダブルクリックする。)  
<--- 写真 ④
  5. 
写真 ⑤ の矢印で示す[Send]ボタンをクリックする。   <--- 写真 ⑤
  6. ユーザのホームデレクトリィにファイルが転送される。

写真 ④
A
写真 ⑤B

 proftpd 

  1.  proftpd-1.3.6.tar.gz  /usr/loacl/src/ 
    cp /home/miyasaka/proftpd-1.3.6.tar.gz /usr/loacl/src/
  2. proftpd-1.3.6.tar.gz  
    cd /usr/loacl/src/ ;tar zxvf proftpd-1.3.6.tar.gz
  3.  configure 
    cd proftpd-1.3.6; \
    ./configure --prefix=/usr/local/proftpd

  13

  cp /home/miyasaka/proftpd-1.3.6.tar.gz /usr/loacl/src/; \
  cd /usr/loacl/src/; \
  tar zxvf proftpd-1.3.6.tar.gz; \
  cd proftpd-1.3.6; \
  ./configure --prefix=/usr/local/proftpd

  4. make 
    make && make install

  > 
  make 

 In file included from pr_fnmatch.c:256:0:
 pr_fnmatch_loop.c:  'internal_fnmatch' :
 pr_fnmatch_loop.c:75:7: :  'is_seqval' 使

 proftpd.conf

 vi /usr/local/proftpd/etc/proftpd.conf"# Bar use of SITE CHMOD by default"
 

   

 "# Bar use of SITE CHMOD by default" ()dd 

 #
 # Bar use of SITE CHMOD by default
 # 
 #
 <Limit SITE_CHMOD>
 #DenyAll
 AllowAll 
</Limit>
 #()
 ListOptions "-a"
 #
 #(DNSIdent)
 UseReverseDNS off
 IdentLookups off
 #
 #  GMT-->JST
 TimesGMT off
 # LAN
 <Limit LOGIN>
 Allow from 192.168.0.0/24 <---  192.168.0. IP
 
 </Limit> 
  1sed 
 ( sed -i -e  -i )
 ( 39a 39a\n )
 ( s/// )
 ( \ [ $,/, .  ])

cp /usr/local/proftpd/etc/proftpd.conf /home/miyasaka/proftpd.conf.bak;\
sed -i -e "40,65d
39a# \n\
<Limit SITE_CHMOD>\n\
 #DenyAll\n\
 AllowAll\n\
<\/Limit>\n\
#\n\
ListOptions \"-a\"\n\
\n\
#\(DNSIdent\)\n\
UseReverseDNS off\n\
IdentLookups off\n\
\n\
#  GMT-->JST\n\
TimesGMT off\n\
\n\
# LAN\n\
<Limit LOGIN>\n\
 Allow from 192\.168\.0\.0\/24\n\
<\/Limit>\n" /usr/local/proftpd/etc/proftpd.conf

 proftpd

  proftpd.init.d  /etc/rc.d/init.d/proftpd 

  cp /usr/local/src/proftpd-1.3.6/contrib/dist/rpm/proftpd.init.d \
  /etc/rc.d/init.d/proftpd

 proftpd3246

  vi /etc/rc.d/init.d/proftpd

32(  PATH  /usr/local/proftpd/sbin  )
 proftpd /usr/local/proftpd 
 (  proftpd    proftpd 
 )

 export PATH="$PATH:/usr/local/proftpd/sbin"

46

 # Make sure the binary is present.
 [ -x /usr/sbin/proftpd ] || exit 5
  
 [ -x /usr/local/proftpd/sbin/proftpd ] || exit 5

cp /usr/local/src/proftpd-1.3.6/contrib/dist/rpm/proftpd.init.d;\
sed -i -e "31aexport PATH=\$PATH\:\/usr\/local\/proftpd\/sbin
s/-x \/usr\/sbin\/proftpd/-x \/usr\/local\/proftpd\/sbin\/proftpd/g"\
 /etc/rc.d/init.d/proftpd

 proftpd.conf  
30 User nobody
31 Group nogroup
  nogroup ( groupadd nogroup )
31 Group nobody 

 groupadd nogroup 

 proftpd

 chmod 755 /etc/rc.d/init.d/proftpd

 proftpd 

 -1 proftpd.service 

 vi /usr/lib/systemd/system/proftpd.service )

 [Unit]
 Description=proftpd-1.3.6 daemon   
<---- サービス名を書込みます。
                      ( コメント欄です。)
  [Service]
 Type=forking            
<---- サービスプロセスの起動完了の判定方法
 ExecStart=/etc/rc.d/init.d/proftpd start 
<---- サービス起動コマンドを書込みます。

 [Install]
 WantedBy=multi-user.target     
<---- 旧来のrunlevel 3に相当する設定


   
 systemctl enable proftpd start 
start 
[Ctrl]+[c] 

 -2 

  systemctl enable proftpd

 (2)

ln -s '/usr/lib/systemd/system/proftpd.service'
'/etc/systemd/system/multi-user.target.wants/proftpd.service'

⑧-3 起動・停止

  systemctl start proftpd  <---- 起動

  systemctl stop proftpd   <---- 停止

⑧-4 自動起動の解除

  systemctl disable proftpd

  以下の様な表示が出ます。

rm '/etc/systemd/system/multi-user.target.wants/proftpd.service'

⑧-5 ステータスの表示

  systemctl status proftpd

  以下は、私の環境下の表示例です

 * proftpd.service - ProFTPD FTP Server
  Loaded: loaded (/usr/lib/systemd/system/proftpd.service; enabled; vendor ……
  Active: active (running) since 金 2018-09-21 08:22:27 JST; 1min 59s ago
  Process: 1091 ExecStart=/usr/sbin/proftpd $PROFTPD_OPTIONS (code=exited, ……
 Main PID: 1125 (proftpd)
  CGroup: /system.slice/proftpd.service
      `-1125 proftpd: (accepting connections)

 9月 21 08:22:27 LeoMiya systemd[1]: Starting ProFTPD FTP Server...
      ( 以下省略


  ftp( proftpd ) 

 -1 

   firewall-cmd --list-services

   (  )

   dhcpv6-client ssh

 -2 ftp( proftpd ) 

   firewall-cmd --add-service=ftp --permanent

   success OK

 -3 

   firewall-cmd --reload

   success OK

 -4 

   firewall-cmd --list-services

    ftp 

   dhcpv6-client ftp ssh

 windows  ffftp 

  FFFTP  ftp(21)

   firewall-cmd --add-service=ftp --permanent
   firewall-cmd --reload

   

   
 ffftp 
 ()(N)   ---->  CentOS 7 IP
 (U)       ---->  CentOS 7 
 /(N) ---->  CentOS 7 
    ---->  
   ---->  
 

 windowsffftp
 

 ffftpffftp
 windowsFFTPGMT+9:00
  

 ffftp[]
 便
 ffftp [(O)][(S)]
 [3][(A)]

  
   *.pl *.cgi *.sh ---> 755
   *.txt *.cnt    ---> 666
   *.html 
   linuxmaster.jp


6. Tera Termでvsftpd( FTPサーバ )を転送しインストール


 Tera Term vsftpd   

 [  ]
  1. Tera Term  []   <---  
  2.  SSH SCP...     <---  
  3.   [] <---  
写真 ①A 写真 ②B 写真 ③C

  4. 写真 ④ の様にファイルを選択するダイヤログ画面が開くので、
   vsftpd-3.0.2-22.el7.x86_64.rpm を選択する(ダブルクリックする。)  
<--- 写真 ④
  5. 
写真 ⑤ の矢印で示す[Send]ボタンをクリックする。   <--- 写真 ⑤
  6. ユーザのホームデレクトリィにファイルが転送される。

写真 ④
A
写真 ⑤B

① vsftpd のインストールと設定

  cd /usr/local/src/; \
  rpm -ivh vsftpd-3.0.2-22.el7.x86_64.rpm

  yum でのインストールは、下記の通りです。

  yum -y install vsftpd

② vsftpd の設定

  編集前の vsftpd.conf を .bak を付けて保存しておきます。

  cp /etc/vsftpd/vsftpd.conf /home/miyasaka/vsftpd.conf.bak

編集済の vsftpd.conf が有る場合には、Tera Term の転送機能を利用してホームディレクトリ に読込み cp コマンドで上書きします。

  cp /home/miyasaka/vsftpd.conf /etc/vsftpd/


  sed 
( sed -i //s/^#//  # \$a\  [\$][a] \ \ \n   \n\  \ )
cp /etc/vsftpd/vsftpd.conf /home/miyasaka/vsftpd.conf.bak; \
sed -i -e/anonymous_enable=/s/YES/NO/
/xferlog_enable=/s/YES/NO/
#  # 
/#ascii_upload_enable/s/^#//
/#ascii_download_enable/s/^#//
/#chroot_local_user/s/^#//
/#chroot_list_enable/s/^#//
/#chroot_list_file/s/^#//
/#ls_recurse_enable/s/^#//
/listen=/s/NO/YES/
/listen_ipv6=/s/YES/NO/
##### 
\$a\local_root=public_html\n\
use_localtime=YES\n\
text_userdb_names=Yes\n\
force_dot_files=YES/etc/vsftpd/vsftpd.conf

  vi /etc/vsftpd/vsftpd.conf

12 

  anonymous_enable=NO

40

  xferlog_enable=NO

 82,83  (  )

  ascii_upload_enable=YES
  ascii_download_enable=YES

 100,101 ( chroot )

  chroot_local_user=YES
  chroot_list_enable=YES

 103  ( chroot  )

  chroot_list_file=/etc/vsftpd/chroot_list

 109  (  )

  ls_recurse_enable=YES

 114  ( IPv4 )

  listen=YES

 123  ( IPv6  )

 listen_ipv6=NO

 ###  ###

 # PAM ( )

  pam_service_name=vsftpd

 # 使
 # NO  /etc/vsftpd/user_list

  userlist_enable=NO

 # tcp_wrappers(IP )使

  tcp_wrappers=YES

 #  ()

  local_root=public_html

 # 使

  use_localtime=YES

 # Windows( ffftp )

  text_userdb_names=Yes

 # Windows( ffftp ) . 

  force_dot_files=YES

編集済の vsftpd.conf は、再構築時使用すると便利なので windows PC へ保存します。
なお、ファイルの属性・所有者を変更しないと windows PC へ保存できないので変更します。
( ディレクトリ・ユーザ名は、私のサーバ機の場合の設定です。)


  cp /etc/vsftpd/vsftpd.conf /home/miyasaka/; \
  chown -R miyasaka:miyasaka /home/miyasaka/vsftpd.conf; \
  chmod 644 /home/miyasaka/vsftpd.conf


  

  vi /etc/vsftpd/chroot_list 

  echo "miyasaka" >> /etc/vsftpd/chroot_list

   miyasaka 

 hosts.allowhosts.deny(IP )

 hosts.allow hosts.allow  
IP

 -1 /etc/hosts.deny  vsftpd:ALL (  )

  vi /etc/hosts.deny

  vsftpd:ALL

  

  echo "vsftpd:ALL" >> /etc/hosts.deny

 -2 /etc/hosts.allow IP

  vi /etc/hosts.allow

  vsftpd:192.168.0.

  

  echo "vsftpd:192.168.0." >> /etc/hosts.allow

  192.168.0.0/24 IP

 vsftpd 

  systemctl start vsftpd

 # OK

 vsftpd 

  systemctl enable vsftpd

 # OK

  ftp( vsftpd ) 

 -1 

   firewall-cmd --list-services

   (  )

   dhcpv6-client ssh

 -2 ftp( vsftpd ) 

   firewall-cmd --add-service=ftp --permanent

   success OK

 -3 

   firewall-cmd --reload

 success OK

 -4 

   firewall-cmd --list-services

    ftp 

   dhcpv6-client ftp ssh

   

   firewall-cmd --zone=public --list-ports

   

   2222/tcp

 -5    

   echo "miyasaka" >> /etc/vsftpd/chroot_list; \
   echo "vsftpd:ALL" >> /etc/hosts.deny; \
   echo "vsftpd:192.168.0." >> /etc/hosts.allow; \
   systemctl start vsftpd; \
   systemctl enable vsftpd

 windows  ffftp 

  FFFTP  ftp(21)

 firewall-cmd --add-service=ftp --permanent
 firewall-cmd --reload

 

   
 ffftp 
 ()(N)   ----> CentOS 7 IP
 (U)       ----> CentOS 7 
 /(N) ----> CentOS 7 
    ----> 
   ----> 
 


 windowsffftp
  

 ffftpffftp
 windowsFFTPGMT+9:00
 

 ffftp[]
 便
 ffftp [(O)][(S)]
  [3][(A)]

 
 *.pl  *.cgi  *.sh  --->  755
 *.txt *.cnt --->  666
 *.html  



7. ファイルの転送プログラムの作成


windowswindows  src2 ffftp /home/miyasaka/



[  ] 
            []

8. サーバの時刻を日本標準時に同期させる


CentOS 7.0 NTP Chrony 

()

 vi /etc/chrony.conf 

3
  server 0.centos.pool.ntp.org iburst
  server 1.centos.pool.ntp.org iburst
  server 2.centos.pool.ntp.org iburst
  server 3.centos.pool.ntp.org iburst

  ( )
  server ntp.nict.jp
  server ntp1.jst.mfeed.ad.jp
  server ntp2.jst.mfeed.ad.jp

  1sed 
sed -i -e『s/server 0\.centos\.pool\.ntp\.org iburst/server\
 ntp\.nict.\jp/g
s/server 1\.centos\.pool\.ntp\.org iburst/server\
 ntp1\.jst\.mfeed\.ad\.jp/g
s/server 2\.centos\.pool\.ntp\.org iburst/server\
 ntp2\.jst\.mfeed\.ad\.jp/g
s/server 3\.centos\.pool\.ntp\.org iburst//g』\
/etc/chrony.conf

 chrony  ( chrony chronyd )
  systemctl restart chronyd.service

 # 

  chrony 
  systemctl enable chronyd.service

 # 

 chronyd (  )
  chronyc sources

 

 MS Name/IP address Stratum Poll Reach LastRx Last sample
 ==========================================
 ^* ntp-a3.nict.go.jp 1 6 377 9 -430us[ -627us] +/- 8332us
 ^+ ntp1.jst.mfeed.ad.jp 2 6 377 8 +551us[ +551us] +/- 16ms
 ^- ntp2.jst.mfeed.ad.jp   2 6 377 7 -307us[ -307us] +/- 35ms

 *
 10

 (,,)

 date 

 

 2013107  13:21:17 JST

 date MMDDhhmmYYYY  

[MM0112 DD 0131 hhmm 24 YYYY (西) ]

 ex. 20131007 09:05 --> date 100709052013

 ntp  123 

   
 web ntpd123chronyd
 使 123 
   firewall-cmd --add-service=ntp --zone=public --permanent
firewall-cmd --reload

  success  



9. RPMforgeリポジトリを導入する


 yum-priorities

  cd /usr/local/src/; \
  rpm -ivh yum-plugin-priorities-1.1.31-42.el7.noarch.rpm

  yum 

  cd /usr/local/src/; \
  yum -y install yum-plugin-priorities

 

   
1sed 
 
 ( 27i 27i )
cp /etc/yum.repos.d/CentOS-Base.repo /home/miyasaka/CentOS-Base.repo.bak; \
sed -i -e19ipriority=1
27ipriority=1
35ipriority=1/etc/yum.repos.d/CentOS-Base.repo

  vi /etc/yum.repos.d/CentOS-Base.repo

 [base]
 name=CentOS-$releasever - Base
 mirrorlist=http://mirrorlist.centos.org/?release=$releas...
 #baseurl=http://mirror.centos.org/centos/$releasever/os/...
 gpgcheck=1
 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
 priority=1  
 #released updates
 [updates]
 name=CentOS-$releasever - Updates
 mirrorlist=http://mirrorlist.centos.org/?release=$release...
 #baseurl=http://mirror.centos.org/centos/$releasever/upda...
 gpgcheck=1
 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
 priority=1  
 #additional packages that may be useful
 [extras]
 name=CentOS-$releasever - Extras
 mirrorlist=http://mirrorlist.centos.org/?release=$release...
 #baseurl=http://mirror.centos.org/centos/$releasever/extr...
 gpgcheck=1
 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
 priority=1  
 #additional packages that extend functionality of existin...
 [centosplus]
 name=CentOS-$releasever - Plus
 mirrorlist=http://mirrorlist.centos.org/?release=$releasev...
 #baseurl=http://mirror.centos.org/centos/$releasever/cento...
 gpgcheck=1
 enabled=0
 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

 RPMforge

  rpm -ivh rpmforge-release-0.5.3-1.el7.rf.x86_64.rpm

 RPMforge
   yum 使

  yum -y update rpmforge-release

  
  11 packages excluded due to repository priority protections
  No packages marked for update

 

  rm -f rpmforge-release-*

 CentOS-Base.repo 

  cp /etc/yum.repos.d/CentOS-Base.repo /home/miyasaka/CentOS-Base.repo.bak

   RPMforge(RPMforge)


10-1. apache2( httpd-2.4.53 )のインストールと設定

「 ベーシック Web サーバー 」を選択 による httpd-2.4.6 の httpd.conf 設定・起動 は、

[httpd-2.4.6 の httpd.conf 設定・起動 ここをクリック]  してください。


2021.05.25 httpd-2.4.48 
2021.09.15 httpd-2.4.49 
2021.10.04 httpd-2.4.50 
2021.10.07 httpd-2.4.51 
2021.12.20 httpd-2.4.52 
2022.03.14 httpd-2.4.53 
 httpd-2.4.53  apr  ./httpd-2.4.53/srclib/ 

 1. httpd-2.4.53 

  cd /usr/local/src/;\
  tar xzvf httpd-2.4.53.tar.gz; \
  chown -R root. httpd-2.4.53; \
  cd ./httpd-2.4.53/srclib

 2. apr 

  tar xzvf /usr/local/src/apr-1.7.0.tar.gz; \
  chown -R root.apr-1.7.0/; \
  mv apr-1.7.0 apr; \
  tar xzvf /usr/local/src/apr-util-1.6.1.tar.gz; \
  chown -R root. apr-util-1.6.1/; \
  mv apr-util-1.6.1/ apr-util

 configure( make  ) 

  cd /usr/local/src/httpd-2.4.53; \
  ./configure \
  --with-included-apr \
  --enable-rewrite \    <----  URL 
  --enable-so \       <---- 
  --enable-deflate=shared <---- 

 SSL [./configure \][--enable-ssl \]
 mod_ssl.so 

・enable-rewrite : Rewriteサポート(mod_rewrite)
Apache側で要求されたURLを書き換えたり、リダイレクトしたりしてくれるモジュール
・enable-so : mod_soモジュールを静的に組み込む
・enable-deflate=shared : データの転送を圧縮するモジュールを組み込む

以下で、終われば、OK
-----------------------------------------------------------------------
config.status: creating support/split-logfile
config.status: creating build/rules.mk
config.status: creating build/pkg/pkginfo
config.status: creating build/config_vars.sh
config.status: creating include/ap_config_auto.h
config.status: executing default commands
configure: summary of build options:

  Server  Version: 2.4.53
  Install  prefix: /usr/local/apache2
   C  compiler:  gcc  -std=gnu99
  CFLAGS:    -g  -O2  -pthread
   CPPFLAGS:   -DLINUX  -D_REENTRANT  -D_GNU_SOURCE
  LDFLAGS:
   LIBS:
  C  preprocessor:  gcc  -E

③ make( コンパイル ) & install

  make && make install

以下で、終われば、OK
-----------------------------------------------------------------------
Installing CGIs
mkdir /usr/local/apache2/cgi-bin
Installing header files
Installing build system files
Installing man pages and online manual
mkdir /usr/local/apache2/man
mkdir /usr/local/apache2/man/man1
mkdir /usr/local/apache2/man/man8
mkdir /usr/local/apache2/manual
make[1]: ディレクトリ `/usr/local/src/httpd-2.4.53' から出ます


 httpd.conf

  

  .conf 

  ex, httpd.conf(  )

  cp /usr/local/apache2/conf/httpd.conf /home/miyasaka/httpd.conf.bak


cgi, SSI, .html使cgi, SSI  png, jpg 

 使
Al1as 使

httpd.conf  sed  sed 
( sed )
Linux (  )


[ sed  httpd-2.4.XX  httpd.conf  ] 
            []

 httpd.conf  ffftp windows    
 cp /home/miyasaka/src2/httpd.conf /usr/local/apache2/conf/


[ httpd-2.4.XX httpd.conf  ] 
            []

 Alias 使 DocumentRoot  >CGI, SSI, html 

 
 使

[ Alias  DocumentRoot  CGI, SSI, html  ] 
            []

編集済の httpd.conf は、再構築時使用すると便利なので windows PC へ保存します。
なお、ファイルの属性・所有者を変更しないと windows PC へ保存できないので変更します。
( ディレクトリ・ユーザ名は、私のサーバ機の場合の設定です。)


  cp /usr/local/apache2/conf/httpd.conf /home/miyasaka/; \
  chown -R miyasaka:miyasaka /home/miyasaka/httpd.conf; \
  chmod 644 /home/miyasaka/httpd.conf



 ( /var/www/html/www.smiyasaka.com  DocumentRoot )

  mkdir -p /var/www/html/www.smiyasaka.com; \
  chown -R miyasaka:miyasaka /var/www/; \
  chmod 777 /var/www/html/www.smiyasaka.com

 httpd.conf

  /usr/local/apache2/bin/apachectl configtest

   Syntax OK OK

   
  configtest DocumentRoot  configtest > 

   DocumentRoot must be a directory

 apache2 systemctl start 

  httpd.servce  httpd.servce apache 
  /usr/sbin/httpd 使

 systemctl start apache2 使

 ( systemctl .servce )
 apache2 使

[ systemctl service  ] 
            []

 80, 443 

  http 
 80

  firewall-cmd --add-port=80/tcp --permanent
    
  firewall-cmd --add-service=http --permanent

  firewall-cmd --add-port=443/tcp --permanent
    
  firewall-cmd --add-service=https --permanent

  success OK

  firewall-cmd --reload
  success OK

  

  firewall-cmd --list-all

   http OK
  dhcpv6-client ftp http ssh

 /usr/local/apache2/logs 

  httpd.conf ( DocumentRoot  )>
 

  SSICGI 

[  ] 
            []

  
SELinux 
 Apache (  ) 
setsebool -P httpd_enable_homedirs 1;\
firewall-cmd --reload


 

  1. htmlcgiSSI
  2.  perlsh
  3. webalizer apache(html)
  4. apache (1)
  5. root(10)
  6. SSL 

24


 IPPC
 [  ] 
 
 [/]

 cron 

  web URL 
  URL 
 www.gidnetwork.com www.port80software.com

 (1)
 http:// https:// 


右の写真のような情報が取得できます。
( H28.11.01 アクセスし、データ取得 )


Results for: www.smiyasaka.com
Web page compressed? Yes ← 圧縮有
Compression type? gzip ← 圧縮タイプ
Size, Markup (bytes) 13,077 ← 解凍した後の バイト数
Size, Compressed (bytes) 4,515 ← 圧縮された時の バイト数
Compression % 65.5 ← 圧縮率







www.gidnetwork.com からの回答
B

 root ffftp 
 

  chown -R miyasaka:miyasaka /usr/local/apache2/logs/deflate_log; \
  chmod -R 666 /usr/local/apache2/logs/deflate_log

   ----> /usr/local/apache2/logs/deflate_log

  ( TeraPad )

  () ()( [ % ] ) 

"GET  / HTTP/1.1" 10335/53768 (19%) Mozilla/5.0 (compatible; MSIE 9.0;
"GET  /.webcam/camdata.jpg HTTP/1.1" 730/1235 (59%) Mozilla/5.0 (compatible;
"GET  /.webcam/camdata.jpg HTTP/1.1" -/- (-%) Mozilla/4.0 (compatible; )
"GET  /fswebcam.html HTTP/1.1" 16258/71964 (22%) Mozilla/5.0 (compatible; 
"GET  /server.html HTTP/1.1" 13682/55830 (24%) Mozilla/5.0 (Windows NT 6.1; 
"GET  /html_point.html HTTP/1.1" 14973/70669 (21%) Mozilla/5.0 (Windows NT 
"GET  /html_point8.html HTTP/1.1" 1017/1985 (51%) Mozilla/5.0 (Windows NT 
"GET  /html_point4.html HTTP/1.1" 852/1575 (54%) Mozilla/5.0 (Windows NT
HTML[ 100 - () ]jpg 


 {()-()}÷()×100 
1( 53,768 - 10,335 )÷53,768×10080.78  

 mod_status 使 apache 使

apache  LANPC

 -1 httpd.conf 

   vi /usr/local/apache2/conf/httpd.conf

   139 

   LoadModule status_module modules/mod_status.so

   473() 

   Include conf/extra/httpd-info.conf

 -2 httpd-info..conf 

   vi /usr/local/apache2/conf/extra/httpd-info.conf

   <Location /server-status>
    SetHandler server-status

   16  Require host .example.com
      
   Require host localhost

   17  Require ip 127
      
   Require ip 192.168.0. <--- LAN 
   </Location> 

   
   25  #ExtendedStatus On
      
   ExtendedStatus On

   httpd 

   32 #<Location /server-info>
   33 #  SetHandler server-info
   34 #   Require host .example.com
   35 #  Require ip 127
   36 #</Location>

 sed 
( s/ 32,36s/^/#/ 3236 #)

sed -i -es/Require host \.example\.com/Require host localhost/g
s/Require ip 127/Require ip 192\.168\.0\./g
s/#ExtendedStatus On/ExtendedStatus On/g
32,36s/^/#//usr/local/apache2/conf/extra/httpd-info.conf

  httpd 

  systemctl restart apache2

 -3 LANPC

  [LANIP]/server-status?refresh=5 <--- 5 
  [LANIP]/server-status      <--- 

 
A


 apache  

  /usr/local/apache2/bin/httpd -v 

  Server version: Apache/2.4.52 (Unix) 
  Server built: Dec 21 2021 10:48:53

  

 1. Linux OS 

  cat /etc/redhat-release 

  CentOS Linux release 7.9.2009 (Core)

 2. Linux 

  uname -a 

 Linux LeoMiya 3.10.0-1160.25.1.el7.x86_64 #1 SMP Wed Apr 28 21:49:45 UTC 2021

 3. restart 

 

 httpd not running, trying to start
 (98)Address already in use: AH00072: make_sock: could not bind to address [::]:80
 (98)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80
 no listening sockets available, shutting down
 AH00015: Unable to open logs

 apachekill 
 httpd  lsof 調

  lsof -i | grep httpd

 
 httpd 1242 root 4u  IPv6 17421 0t0 TCP *:http (LISTEN)
 httpd 1248 miyasaka 4u IPv6 17421 0t0 TCP *:http (LISTEN)
 httpd 1249 miyasaka 4u IPv6 17421 0t0 TCP *:http (LISTEN)

 1242,1248,1249 kill ( -9 )

 kill -9 1242 1248 1249

 4. httpd  strat 

 (20014)Internal error (specific information not available): 
AH00058: Error retrieving pid file logs/httpd.pid
 AH00059: Remove it before continuing if it is corrupted.

  apache  httpd.pid 
 httpd.pid apache 
 
 httpd.PID 

 httpd.pid  find / -name httpd.pid 
  httpd.pid 
 ( )

  rm /usr/local/apache2/logs/httpd.pid

 5.  httpd  
( )

 httpd-2.4.52 

 systemctl stop apache2       <--- apache 
 systemctl disable apache2     <--- apache 
 rm -rf /usr/local/apache2      <--- 
 rm -rf /usr/local/src/httpd-2.4.52  <--- 

 httpd.conf 

 6. apach2 ( httpd ) 

  pstree 
 

   systemd-+-NetworkManager---2*[{NetworkManager}]
      (  )
       |-firewalld---{firewalld}
       |-httpd-+-httpd
       |     |-3*[httpd---63*[{httpd}]]
       |     `-3*[rotatelogs]


10-2. SELinux を有効にした時の apache2 のポリシー設定


  httpd 

 (  : httpd_sys_content_t )
 SSICGI    ---> httpd_sys_script_exec_t
 ReadWrite  ---> httpd_sys_rw_content_t
sh ---> httpd_unconfined_script_exec_t
 SSICGI 
---> httpd_unconfined_script_exec_t

  .html  httpd_sys_content_t 

   

 httpd_unified on

  httpd on

 httpd_enable_cgi  --> on  cgi 
 httpd_enable_homedirs  --> on  
 httpd_sys_script_anon_write  --> on  pubuic_content_rw_t 
  HTTP

 httpd_ssi_exec --> off  Web  SSI (server side include) 
 on

httpd-2.4.XX  off OK
httpd-2.4.6 off  SSI 

SELinux 
SELinux 
 semanage fcontext  restorecon 

 1. perl 1

  CGI  SSI httpd_sys_script_exec_t 
  Linux SELinux    httpd_unconfined_script_exec_t 


 semanage fcontext -a -t httpd_sys_script_exec_t\
 "/var/www/html/www.smiyasaka.com/SSI(/.*)?"
 restorecon -R -vF /var/www/html/www.smiyasaka.com/SSI/
 semanage fcontext -a -t httpd_unconfined_script_exec_t\
 /var/www/html/www.smiyasaka.com/SSI/cgi_test.cgi
 restorecon -vF /var/www/html/www.smiyasaka.com/SSI/cgi_test.cgi

 2. (.txt)> 1

  httpd_sys_rw_content_t  


 semanage fcontext -a -t httpd_sys_rw_content_t\
 "/var/www/html/www.smiyasaka.com/TXT(/.*)?"
 restorecon -R -vF /var/www/html/www.smiyasaka.com/TXT/

 1
 semanage fcontext 
    

 2
 SELinux 

  tar   --selinux  SELinux (  SELinux  )   SELinux 

  semanage fcontext -l -C   httpd-2.4.XX    HTML httpd-2.4.6  HTML SELinux   

 /bin/tar --selinux -zcvf .tar.gz 

  : 
 

  BackUP_Dir="/var/html/www/home_page"
 BackUP_Dir="${BackUP_Dir} /home/miyasaka/home_page_date"
  
 
  : 
  /home/BackUP_Dir/back_www_data20180225.tar.gz ${BackUP_Dir}   

 semanage fcontext  restorecon  

semanage fcontext -a -t <----- 

 -a
 -thttpd_sys_script_exec_t
 
  "/www(/.*)?" :  /www  
-d

restorecon -vF <----- 

-R
 
-v
 
/var/www//
-F
 

semanage fcontext -l -C <----- 



10-3. apache2 の SSL 化の手順と httpd.conf、httpd_ssl.conf の設定


   

使 www.smiyasaka.com  smiyasaka.com 
 使

   

 1. http://  https:// (  )
 2.  Let's Encrypt 使
 3. SELinux ( Enforcing )使

   

 1.  http://() 
 2. httpd-2.4.XX  apache2 使
 3. epel
 4. http https 80 443 
 5. 80 443 

1. 無償の Let's Encrypt を使用して認証鍵の証明書を取得します。
但し、有効期限が3ヶ月間ですので更新が必要になります。


① certbotパッケージと certbot の apache 用プラグインである

  python2-certbot-apache をインストールします。


  yum -y install certbot

  certbot.noarch 0:0.30.2-1.el7 がインストールされます。

  yum -y install python2-certbot-apache

  python2-certbot-apache.noarch 0:0.30.2-1.el7 がインストールされます。

※※ 参考情報 ① ※※
上記 yum インストールで [エラー: 何もしません] になる時には、下記を実行してから yum を実行してください。


  yum install -y epel-release

※※ 参考情報 ② ※※

epel-release の無効化の手順


  ア. コマンド rpm -qa | grep epel で epel のバージョンを調べる。

    例
    rpm -qa | grep epel
    epel-release-7-11.noarch

  イ. コマンド rpm -e で削除する。

    rpm -e epel-release-7-11.noarch


 certbot

  yum list installed | grep certbot

  certbot.noarch            0.30.2-1.el7     @epel
  python2-certbot.noarch       0.30.2-1.el7     @epel
  python2-certbot-apache.noarch   0.30.2-1.el7     @epel


 webroot ( 3)

  certbot( Web )

  

  certbot  -d  -w  DocumentRoot 

 DNS 
 www.smiyasaka.com  smiyasaka.com 
 
 ( )

   certbot certonly --webroot -w /var/www/html/www.smiyasaka.com\              -d www.smiyasaka.com -d smiyasaka.com

  

  

  Enter email address (used for urgent [] (Enter 'c' to cancel): 

   A

  (A)gree/(C)ancel: A

  YN

 (Y)es/(N)o: N

  コマンドが正常終了すると、下記の様に表示し、/etc/letsencrypt/live 以下に最新版の証明 書へのシンボリック リンクが作成される。

     [省略]

IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/www.smiyasaka.com/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/www.smiyasaka.com/privkey.pem
<------- 証明書のパス
Your cert will expire on 2019-05-16. To obtain a new or tweaked
version of this certificate in the future, simply run certbot
again. To non-interactively renew *all* of your certificates, run
"certbot renew"
- If you like Certbot, please consider supporting our work by:

Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
Donating to EFF: https://eff.org/donate-le

  証明書へのシンボリックリンクパスの確認

  ls -l /etc/letsencrypt/live/www.smiyasaka.com

合計 4
-rw-r--r--. 1 root root 692 2月 16 08:31 README
lrwxrwxrwx. 1 …… 41 2月 16 08:31 cert.pem -> ../../archive/www.smiyasaka.com/cert1.pem
lrwxrwxrwx. 1 …… 42 2月 16 08:31 chain.pem -> ../../archive/www.smiyasaka.com/ chain1.pem
lrwxrwxrwx. 1 …… 46 2月 16 08:31 fullchain.pem -> ../../archive/www.smiyasaka.com/fullchain1.pem
lrwxrwxrwx. 1 …… 44 2月 16 08:31 privkey.pem -> ../../archive/www.smiyasaka.com/privkey1.pem
[root@LeoMiya ~]#

ファイルが作成されていることが確認できました。各ファイルの役割は以下の通りです。

  cert.pem サーバー証明書本体

  chain.pem 中間証明書
  privkey.pem 秘密鍵ファイル
  fullchain.pem サーバー証明書と中間証明書のセット

2. httpd-2.4.53 の再インストール

SSL 化のための mod_ssl.so の組込は、個別のインストールでなく、 httpd-2.4.53 の再イン ストールで対応します。

① 下記コマンドでインストールしている apache2 を削除します。


  systemctl stop apache2; \
  systemctl disable apache2; \
  cd /usr/local/src/httpd-2.4.53/; \
  make uninstall; \
  rm -rf /usr/local/apache2; \
  rm -rf /usr/local/src/httpd-2.4.53


rm -rf /etc/httpd/

② mod_ssl.so を追加して再インストール

[省略] 詳細は、10-1 項を参照してください。


  cd /usr/local/src/httpd-2.4.53;\
  ./configure \
  --enable-ssl \      
<--- mod_ssl.so の追加
  --with-included-apr \
  --enable-rewrite \    
<--- http:// のアクセスを https:// に自動変換で使用
  --enable-so \
  --enable-deflate=shared


3. Apache  SSL httpd-ssl.conf

 DocumentRootServerNameErrorLogCustomLog httpd.conf 

   SSL  TLS1.3 
 (  SSL Server Test 11 )

cp /usr/local/apache2/conf/extra/httpd-ssl.conf /home/miyasaka/httpd-ssl.conf.bak

vi /usr/local/apache2/conf/extra/httpd-ssl.conf

   52 SSLCipherSuite HIGH:MEDIUM:!MD5:!RC4:!3DES
     

 SSLCipherSuite HIGH:MEDIUM:!MD5:!RC4:!3DES:!DH

 

     SSLCipherSuite "TLS_AES_256_GCM_SHA384 \
     TLS_CHACHA20_POLY1305_SHA256 \ <------- \ 
     ECDHE-RSA-AES128-GCM-SHA256 \
     ECDHE-RSA-AES256-GCM-SHA384 \
     ECDHE-RSA-AES256-SHA \
     ECDHE-RSA-AES256-SHA384 \
     DHE-RSA-AES256-GCM-SHA384 \
     DHE-RSA-AES256-SHA \
     DHE-RSA-AES256-SHA256"

 60 SSLProxyCipherSuite HIGH:MEDIUM:!MD5:!RC4:!3DES
     
    SSLProxyCipherSuite HIGH:MEDIUM:!MD5:!RC4:!3DES:!DH

 
 
     SSLProxyCipherSuite "TLS_AES_256_GCM_SHA384 \
     TLS_CHACHA20_POLY1305_SHA256 \
     ECDHE-RSA-AES128-GCM-SHA256 \
     ECDHE-RSA-AES256-GCM-SHA384 \
     ECDHE-RSA-AES256-SHA \
     ECDHE-RSA-AES256-SHA384 \
     DHE-RSA-AES256-GCM-SHA384 \
     DHE-RSA-AES256-SHA \
     DHE-RSA-AES256-SHA256"

  79 SSLProtocol all -SSLv3
     
SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1

 SSL  SSL 3.0 TLS1.3 

  80 SSLProxyProtocol all -SSLv3
     
SSLProxyProtocol all -SSLv3 -TLSv1 -TLSv1.1

 SSL   SSL 3.0 TLS1.3 

 124 DocumentRoot "/usr/local/apache2/htdocs"
     
 DocumentRoot "/var/www/html/www.smiyasaka.com"

 125 ServerName www.example.com:443
     
 ServerName ():443 

126 ServerAdmin you@example.com
     
 ServerAdmin ()

 127 ErrorLog "/usr/local/apache2/logs/error_log"
     
 ErrorLog "| /usr/local/apache2/bin/rotatelogs /usr/local/apache2/logs/
 () www.smiyasaka.com_error_log_%Y%m%d 86400 540"

 133

 Header set Strict-Transport-Security "max-age=315360000;includeSubDomains"
 Header edit Set-Cookie ^(.*)$ $1;HttpOnly;Secure
 Header always set X-Frame-Options SAMEORIGIN


 HSTS (HTTP Strict Transport Security)  SSL 
 
HTTPHTTPS
 HTTPS
 315,360,000   3,650  10

 144 SSLCertificateFile "/usr/local/apache2/conf/server.crt"
     
 # 
 SSLCertificateFile "/etc/letsencrypt/live/www.smiyasaka.com/cert.pem"

 154 SSLCertificateKeyFile "/usr/local/apache2/conf/server.key"
     
 # 
 SSLCertificateKeyFile "/etc/letsencrypt/live/www.smiyasaka.com/privkey.pem"

 165 #SSLCertificateChainFile "/usr/local/apache2/conf/server-ca.crt"
 
 # 
 SSLCertificateChainFile /etc/letsencrypt/live/www.smiyasaka.com/chain.pem

 249 <Files ~ "\.(cgi|shtml|phtml|php)$">
     
 <FilesMatch "\.(cgi|shtml|html)$"$gt;
 
252 <Directory "/var/www/cgi-bin">
     
 <Directory "/var/www/html/www.smiyasaka.com">

 
 287 #CustomLog "/usr/local/apache2/logs/ssl_request_log" \
 288 # "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
     
 Include conf/extra/httpd-log.conf <----  conf 
 ( Apache logrotate )使
 

 ( httpd-log.conf [])



 #
 Include conf/extra/httpd-zgip.conf <---- SSL  conf 
 #--------------------------------------------------
 # 
 # ()OFF
 ServerSignature Off
 #

  httpd-log.conf  (  conf )

  httpd-zgip.conf 
 touch /usr/local/apache2/conf/extra/httpd-log.conf
vi(  )
 vi /usr/local/apache2/conf/extra/httpd-log.conf
 ()
<IfModule log_config_module>
   #
   #======================================
   #       不要なログの記録をさせない設定
   #======================================
   #
   #      拡張子による制限
   SetEnvIf Request_URI\
 ".(gif)|(jpg)|(jpeg)|(png)|(bmp)|(ico)|(css)|(swf)$" no-logfile
   #
   #内部からのアクセスをログに記録しない対策
   # IPアドレスによる制限 ローカル
   SetEnvIf Remote_Addr "192.168.0." no-logfile

   # サーチエンジンのログは取らない。
   SetEnvIf User-Agent "Gigabot" no-logfile
   SetEnvIf User-Agent "Googlebot" no-logfile
   SetEnvIf User-Agent "MJ12bot" no-logfile
   SetEnvIf User-Agent "msnbot" no-logfile
   SetEnvIf User-Agent "psbot" no-logfile
   SetEnvIf User-Agent "TurnitinBot" no-logfile
   SetEnvIf User-Agent "Yahoo! Slurp" no-logfile
   SetEnvIf User-Agent "Zealbot" no-logfile

   # ワームによる制限のログは取らない。
   SetEnvIf Request_URI "default\.ida" no-logfile
   SetEnvIf Request_URI "null\.ida" no-logfile
   SetEnvIf Request_URI "NULL\.IDA" no-logfile
   SetEnvIf Request_URI "cmd\.exe" no-logfile
   SetEnvIf Request_URI "root\.exe" no-logfile
   SetEnvIf Request_URI "Admin\.dll" no-logfile
   SetEnvIf Request_URI "^/_mem_bin/" no-logfile
   SetEnvIf Request_URI "^/_vti_bin/" no-logfile
   SetEnvIf Request_URI "^/c/" no-logfile
   SetEnvIf Request_URI "^/d/" no-logfile
   SetEnvIf Request_URI "^/msadc/" no-logfile
   SetEnvIf Request_URI "^/scripts/" no-logfile

   # CGIディレクトリ
   SetEnvIf Request_URI "^/cgi-bin/" no-logfile

   # 巡回ロボットがアクセスする robots.txt
   SetEnvIf Request_URI "robots\.txt" no-logfile

   # 長いURLへの対処
   #
   # ログファイルは、www.smiyasaka.com_alog_( 年月日 )の
   # ファイル名で保存されます。
   #
   SetEnvIf Request_Method "(GET)|(POST)|(PUT)|(DELETE)|(HEAD)"\
 logfile SetEnvIf Request_Method "(OPTIONS)" no-logfile 
   CustomLog "| /usr/local/apache2/bin/rotatelogs\
 /usr/local/apache2/logs/www.smiyasaka.com_alog_%Y%m%d\
 86400 540"\
 combined env=!no-logfile
</IfModule>

  httpd-zgip.conf  (  conf )

  httpd-zgip.conf 
 touch /usr/local/apache2/conf/extra/httpd-zgip.conf
vi( mod_deflate )
 vi /usr/local/apache2/conf/extra/httpd-zgip.conf
 ()
<IfModule mod_deflate.c>
   #-------------------------------------------------------------
   # 転送データの圧縮設定(画像以外全て圧縮する)
   #            実際の圧縮率は、1 も 3 も大差ありません
   #-------------------------------------------------------------
   # 圧縮レベル 1 に設定
        DeflateCompressionLevel 1
   #
        # 全てを圧縮する設定
        SetOutputFilter DEFLATE
        #
        # gzip圧縮に対応していない古いブラウザを除外
        # Netscape 4.x has some problems...
   # 送信先ブラウザがNetscape 4.xの場合はtext/htmlのみ圧縮
        BrowserMatch ^Mozilla/4 gzip-only-text/html
        # Netscape 4.06-4.08 have some more problems
   # 送信先ブラウザがNetscape 4.06-4.08の場合は圧縮しない
        BrowserMatch ^Mozilla/4\.0[678] no-gzip
        # MSIE masquerades as Netscape, but it is fine
   # 送信先ブラウザがMSIEの場合は全て圧縮する
        BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
        #
        # 画像以外全て圧縮する
        # Don't compress images
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
        #
        # Make sure proxies don't deliver the wrong content
   # プロキシサーバーが圧縮未対応ブラウザへ圧縮ファイルを
   # 送信しないようにする
        Header append Vary User-Agent env=!dont-vary
   # html や css, js, javescript などは個別指定
        AddOutputFilterByType DEFLATE text/plain
        AddOutputFilterByType DEFLATE text/html
        AddOutputFilterByType DEFLATE text/xml
        AddOutputFilterByType DEFLATE text/css
        AddOutputFilterByType DEFLATE text/js
        AddOutputFilterByType DEFLATE text/javascript
        AddOutputFilterByType DEFLATE application/xhtml+xml
        AddOutputFilterByType DEFLATE application/xml
        AddOutputFilterByType DEFLATE application/rss+xml
        AddOutputFilterByType DEFLATE application/atom_xml
        AddOutputFilterByType DEFLATE application/js
        AddOutputFilterByType DEFLATE application/javascript
        AddOutputFilterByType DEFLATE application/x-javascript
        AddOutputFilterByType DEFLATE application/x-httpd-php
   #
        # 圧縮率の確認用ログ設定
        # 不要になったら、# で無効にしておく事。
        # Deflateが有効になっているか確認するログの出力
        #
        DeflateFilterNote Input instream
        DeflateFilterNote Output outstream
        DeflateFilterNote Ratio ratio
        LogFormat '"%r" %{outstream}n/%{instream}n\
 (%{ratio}n%%) %{User-agent}i' deflate
        CustomLog logs/deflate_log deflate
</IfModule>

httpd-SSL.conf  sed  sed 
( sed )
Linux (  ) 


[ sed  httpd-2.4.XX  httpd-ssl.conf  ] 
            []

4. Apache  SSL  httpd.conf 

 4

  vi /usr/local/apache2/conf/httpd.conf

  mod_socache_shmcb

   88 #LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
     
 LoadModule socache_shmcb_module modules/mod_socache_shmcb.so

 mod_socache_shmcb.sohttpd

  mod_ssl.so 

 133 #LoadModule ssl_module modules/mod_ssl.so
     
 LoadModule ssl_module modules/mod_ssl.so

  https://  https:// 

 152 #LoadModule rewrite_module modules/mod_rewrite.so
     
 LoadModule rewrite_module modules/mod_rewrite.so

  httpd-ssl.conf

 494 #Include conf/extra/httpd-ssl.conf
     
 Include conf/extra/httpd-ssl.conf

  sed 

sed -i -e/mod_socache_shmcb\.so/s/^#//
/mod_ssl\.so/s/^#//
/mod_rewrite\.so/s/^#//
/httpd-ssl\.conf/s/^#///usr/local/apache2/conf/httpd.conf

5. URL 

 http://  https:// ( 301 ) index.html  www 

 www Google Search Console  www 
 .htaccess 
 (  LAN  )

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
#
###  301リダイレクト http ---> htpps  ###
#
  RewriteCond %{HTTPS} off
  RewriteRule ^(.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
#
###  index.htmlあり  →  index.html無し  ###
###  %{HTTP_HOST} にしているのは、ローカルLAN からの
###  アクセスを有効にする為。
#
  RewriteCond %{REQUEST_URI} ^.*/index\.html$
  RewriteRule ^(.*)index.html$ https://%{HTTP_HOST}/$1 [R=301,L]
#
###  www ありのドメインに統一する  ###
###  [NC] は、大文字、小文字の区別なしの指定
#
  RewriteCond %{HTTP_HOST} ^smiyasaka\.com$ [NC]
  RewriteRule ^(.*) https://www.smiyasaka.com/$1 [R=301,L]
#
</IfModule>


    
http://  https:// 
 

    
httpd.conf  All mod_rewrite.so 使

   #AllowOverride None
     
    AllowOverride All

  https httpd-ssl.conf
 

6. エラーのチェック

  /usr/local/apache2/bin/apachectl configtest

「 Syntax OK 」と表示されればOKです。>

7. apache2.service の変更して reload を追加します。

  vi /usr/lib/systemd/system/apache2.service
------------------------------------------------------

[Unit]
Description=httpd-2.4.53 daemon
After=network.target

[Service]
Type=forking
ExecStart=/usr/local/apache2/bin/apachectl start
ExecReload=/usr/local/apache2/bin/apachectl graceful
<--- 安全な再起動を追加します。
ExecStop=/usr/local/apache2/bin/apachectl stop

[Install]
WantedBy=multi-user.target

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

  systemctl start apache2  <--- 起動
  systemctl reload apache2 
<--- 安全な再起動
  systemctl stop apache2  <--- 停止

8. SELinux 対策 httpd からの秘密鍵の Read / Write を有効にする。

semanage fcontext -a -t httpd_sys_rw_content_t\
"/etc/letsencrypt/live/www.smiyasaka.com(/.*)?"; \
restorecon -R -vF /etc/letsencrypt/live/www.smiyasaka.com/

     上記設定の確認

  ls -Z /etc/letsencrypt/live/www.smiyasaka.com/


9. apache2  https://( LAN IP)

  systemctl start apache2

  Windows PC  Web  LAN IP使

  ( LAN IP)
 
OK
  URL  https://( LAN IP)

  [  ]
 
 PC [  ]  (IP)

10. 証明書の更新

下記コマンドを実行して更新出来ました。
crontab に登録し、毎月 同じ日時( 19日 03時 )に実行する様に設定しました。


00 03 19 * * /bin/certbot certonly --webroot -w /var/www/html/www.smiyasaka.com\
-d smiyasaka.com -d www.smiyasaka.com --renew-by-default && /bin/systemctl\
reload apache2

オプションの説明

certonly       SSL/TLS サーバ証明書の取得のみを行います。

--renew-by-default  リクエストされたドメイン名の SSL/TLS サーバ証明書が既に存在する場合には、残りの有効期間にかかわらず、証明書を更新します。
-w   webrootを使用する場合に証明書の一時保管ディレクトリを指定
-d   証明書を作成するホスト名(FQDN)を指定する
    複数指定も可能で、その場合は一つの証明書で複数のホスト名に対応する

更新の確認は、下記コマンドで行います。(下記の例は、私のサーバ機の場合です。)
日付が更新されいれば、OKです。


  ls -l /etc/letsencrypt/live/www.smiyasaka.com

total 4
-rw-r--r--. 1 root root 692 Feb 16 08:31 README
lrwxrwxrwx. 1 root root 41 May 19 03:00 cert.pem -> ../../archive/www.smiyasaka.com/cert4.pem
lrwxrwxrwx. 1 root root 42 May 19 03:00 chain.pem -> ../../archive/www.smiyasaka.com/ chain4.pem
lrwxrwxrwx. 1 root root 46 May 19 03:00 fullchain.pem -> ../../archive/www.smiyasaka.com/fullchain4.pem
lrwxrwxrwx. 1 root root 44 May 19 03:00 privkey.pem -> ../../archive/www.smiyasaka.com/privkey4.pem>


10-4. nghttp2 を使用して SSL プロトコル HTTP/1.1, HTTP/2 対応の設定


1. OpenSSL , nghttp2  URL 

 https://github.com/tatsuhiro-t/nghttp2/releases/
 https://www.openssl.org/source/

 20223 nghttp2 1.47.0 OpenSSL 1.1.1n 
  nghttp2 使openssl 
 nghttp2-1.34.0.tar.gz   openssl 

2. Openssl 

OpenSSL 

 cd /usr/local/src/; \
 yum -y install perl-core

35

 OpenSSL
  /opt/openssl 

 cd /usr/local/src/; \
 tar zxvf openssl-1.1.1n.tar.gz; \
 cd openssl-1.1.1n; \
 ./config --prefix=/opt/openssl \
 --openssldir=/opt/openssl shared zlib

 make && make install

   OpenSSL1.1.1n /etc/ld.so.conf.d 
    nghttpd2  make 

 ln -s /opt/openssl/lib/libcrypto.so.1.1 /lib64/libcrypto.so.1.1;\
 ln -s /opt/openssl/lib/libssl.so.1.1 /lib64/libssl.so.1.1;\
 echo /opt/openssl/lib > /etc/ld.so.conf.d/openssl111.conf;\
 ldconfig   <------- 

3 SSL 

 libssl.so.

 ldd /opt/openssl/bin/openssl  <------- ldd

  linux-vdso.so.1 => (0x00007fffc3fc9000)
  libssl.so.1.1 => /opt/openssl/lib/libssl.so.1.1 (0x00007f876b92a000)
  libcrypto.so.1.1 => /opt/openssl/lib/libcrypto.so.1.1 (0x00007f876b43d000)
  libz.so.1 => /lib64/libz.so.1 (0x00007f876b227000)
  libdl.so.2 => /lib64/libdl.so.2 (0x00007f876b023000)
  libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f876ae07000)
  libc.so.6 => /lib64/libc.so.6 (0x00007f876aa39000)
  /lib64/ld-linux-x86-64.so.2 (0x00007f876bbbd000)


4. nghttp2 

 nghttp2 ( janssonlibev )

cd /usr/local/src/;\
yum -y install jansson-devel libev-devel

nghttpd2  make ( SCL : Software collections ) 使gcc () 

yum -y install centos-release-scl;\ <--- SCL
yum -y install devtoolset-7;\  <--- gcc 
scl enable devtoolset-7 bash  <--- gcc 

 OpenSSL 1.1.1k  /opt/openssl/  OPENSSL_CFLAGS  OPENSSL_LIBS  OpenSSL env 

  cd /usr/local/src; \
  tar xvfz nghttp2-1.47.0.tar.gz; \
  cd nghttp2-1.47.0/; \  env (  ) 
  env OPENSSL_CFLAGS="-I/opt/openssl/include" \
  OPENSSL_LIBS="-L/opt/openssl/lib -lssl -lcrypto"; \
  ./configure \
   --disable-static \
   --enable-lib-only \
   --enable-app

nghttp2-1.43.0 --disable-static  --enable-lib-only 

 --disable-static 
 --enable-lib-only libnghttp2

 
nghttp2-1.45.1 
     (  )
 Test:
  CUnit:     no (CFLAGS='' LIBS='')
  Failmalloc:   yes
 Libs:
  OpenSSL:    yes (CFLAGS=' ' LIBS='-lssl -lcrypto ') 
  Libxml2:    yes (CFLAGS='' LIBS='-lxml2 ')
  Libev:     yes (CFLAGS='' LIBS='')
  Libc-ares    yes (CFLAGS=' ' LIBS='-lcares ')
  libngtcp2:    no (CFLAGS='' LIBS='')
  libngtcp2_crypto_openssl: no (CFLAGS='' LIBS='')
  libngtcp2_crypto_boringssl: no (CFLAGS='' LIBS='')
  libnghttp3:   no (CFLAGS='' LIBS='')
  libbpf:     no (CFLAGS='' LIBS='')
  Libevent(SSL): no (CFLAGS='' LIBS='')
  Jansson:     yes (CFLAGS='' LIBS='')
  Jemalloc:    no (LIBS='')
  Zlib:      yes (CFLAGS=' ' LIBS='-lz ')
  Systemd:    yes (CFLAGS=' ' LIBS='-lsystemd ')
     ( 5 )
 Third-party:
  http-parser:  no
  MRuby:     no (CFLAGS='' LIBS='')
  Neverbleed:   no
 Features:
  Applications:  no
  HPACK tools:  no
  Libnghttp2_asio:no
  Examples:   no
  Python bindings:no
  Threading:   no
  HTTP/3 (EXPERIMENTAL): no
  

  make && make install

 CentOS  /usr/local/lib  [ (.so) ] 
/etc/ld.so.conf/usr/local/lib  ldconfig 

  echo /usr/local/lib >> /etc/ld.so.conf; \
  ldconfig   <--- 

   

httpd  libnghttp2.so 

5. httpd-2.4.53 の再インストール

プロトコル HTTP/2 対応化のための mod_http2.so の組込は、個別のインストールでなく、 httpd-2.4.53 の再インストールで対応します。

① 下記コマンドでインストールしている apache2 を削除します。


  systemctl stop apache2; \
  systemctl disable apache2; \
  rm -rf /usr/local/apache2; \
  rm -rf /usr/local/src/httpd-2.4.53


② APR と APR-util は、ソースファイルから、make と make install でインストールします。
 ( このインストールは、時間がかかります。)

   APR をインストールする。

  cd /usr/local/src/;\
  tar xvzf apr-1.7.0.tar.gz;\
  cd ./apr-1.7.0;\
  ./configure \
  make && make install

   APR-util をインストールする。

  cd /usr/local/src/;\
  tar xvzf apr-util-1.6.1.tar.gz;\
  cd ./apr-util-1.6.1;\
  ./configure \
  --with-apr=/usr/local/apr \
  make && make install

③ mod_http2.so を追加する為の再インストール

[省略] 詳細は、10-1 項を参照してください。


  

 nghttp2 httpd-2.4.XX make 

 httpd-2.4.47 ( make )

   /bin/ld: cannot find -lidn
   /bin/ld: cannot find -lssh2
   collect2: error: ld returned 1 exit status

 httpd-2.4.48 ( make )

   /opt/rh/devtoolset-7/redhat-linux/7/ld: cannot find -lidn
   /opt/rh/devtoolset-7/redhat-linux/7/ld: cannot find -lssh2
      ()

 httpd-2.4.XX ( make ) 

 idnssh2 ( cannot find -lidn, cannot find -lssh2 )


 idn  ssh2 
find / -name *ssh2*
/usr/lib64/libssh2.so.1
/usr/lib64/libssh2.so.1.0.1   <--- 使

find / -name *idn*
/usr/lib64/libidn.so.11
/usr/lib64/libidn.so.11.6.11   <--- 使



cd /usr/lib64/
ln -s libidn.so.11.6.11 libidn.so   <--- [] libidn.so 
ln -s libssh2.so.1.0.1 libssh2.so   <--- [] libssh2.so 


 ln 

ln -s 

ln -s [] [] 

httpd-2.4.53 

  cd /usr/local/src/httpd-2.4.53;\  <--- httpd-2.4.53
  ./configure \
  --enable-ssl \
  --with-ssl=/opt/openssl \  <---  openssl 
  --enable-ssl-staticlib-deps \ <--- OS  openssl 
Apache  SSL 
  --enable-http2 \   <--- mod_http2.so 
  --with-apr=/usr/local/apr \
  --with-apr-util=/usr/local/apr \
  --enable-rewrite \
  --enable-so \
  --enable-deflate=shared \
  --enable-mods-shared=all   <--- 

  httpd-2.4.53  make  install 

 make && make install

   aprapr-util  
( apr, apr-util )

 (1). httpd-2.4.53 

  cd /usr/local/src/;\
  tar xzvf httpd-2.4.53.tar.gz; \
  chown -R root. ; \
  cd ./httpd-2.4.53/srclib

 (2). apr, apr-util 

  tar xzvf /usr/local/src/apr-1.7.0.tar.gz; \
  chown -R root. apr-1.7.0/; \
  mv apr-1.7.0 apr; \
  tar xzvf /usr/local/src/apr-util-1.6.1.tar.gz; \
  chown -R root. apr-util-1.6.1/; \
  mv apr-util-1.6.1/ apr-util

 (3). configure

  cd /usr/local/src/httpd-2.4.53; \
  ./configure \
   ()
   --with-apr=/usr/local/apr \
  --with-apr-util=/usr/local/apr \  --with-included-apr \ 

6. Apache の SSLの設定 httpd-ssl.confファイルの追加編集

10-3 項の設定が完了してから、下記を追加します。

vi /usr/local/apache2/conf/extra/httpd-ssl.conf

132行目 SSLEngine on の次の行に下記を追加


  #---- HTTP/1.1 HTTP/2 add ----
  <IfModule http2_module>
   ProtocolsHonorOrder On
   Protocols h2 http/1.1
  </IfModule>


h2 とは、TLS暗号化接続によるHTTP/2プロトコル

http/1.1 とは、従来のHTTP/1.1プロトコル。 非暗号化接続および、TLS(SSL)暗号化接続の
両方で利用可


上記の操作を sed コマンドで一括処理してみました。


sed -i -e "#
#---- SSLEngine on の次の行に追加 ----------
#
/SSLEngine on/a\n\
#---- HTTP/1.1 HTTP/2 有効化 ----\n\
<IfModule http2_module>\n\
ProtocolsHonorOrder On\n\
Protocols h2 http\/1\.1\n\
</IfModule>" /usr/local/apache2/conf/extra/httpd-ssl.conf

7. Apache の SSL の設定 httpd.conf ファイルの編集

10-3 項の設定が完了してから、下記2ヶ所を変更します。

  vi /usr/local/apache2/conf/httpd.conf>

〇 mod_http2.so を有効化するため、コメントアウトを解除します。

  134 #LoadModule http2_module modules/mod_http2.so
     ↓ ↓
     
LoadModule http2_module modules/mod_http2.so

8. エラーのチェック

  /usr/local/apache2/bin/apachectl configtest

  「 Syntax OK 」と表示されればOKです。


9. apache2  https://( LAN IP)

  systemctl start apache2

   Windows PC  Web  LAN IP使

  https://( LAN IP)
 
OK

  
  [  ] ---> [ (L) ] 
  (IP) - F12  
 [  ]
 /  HTTP/2 HTTP2 h2 
 HTTPS  HTTP/1.1 
  Web google  firefox [ 
  ] [] 

10. 最新バージョンの OpenSSL が使用され、圧縮もされているかを
     www.port80software.com にアクセスして確認してみました。

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

右の写真のような情報が取得できます。
( 2019.03.24 アクセスしたデータ )

URL: https://www.smiyasaka.com

Web server type: Apache/2.4.39(Unix) OpenSSL/1.1.1b

Compression status: Compressed(gzip) ← 圧縮                   タイプ
Original size: 31428 bytes ← 解凍した
              後の バイト数
Compressed size: 7630 bytes ← 圧縮された                 時の バイト数
Compression % 76.0% ← 圧縮率

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

www.port80software.com からの回答
openssl-1.1.1c

※ 追伸 ※ この方法での構築が良いのかの判定は、私のスキルでは出来ませんすが、まずは動作したので紹介しています。


10-5. 圧縮パッケージ Brotli を使用しての圧縮処理の追加


 Brotli 使使
 Brotli 使10-4 


  (br) Brotli 

 openssl, nghttp2  Brotli 

  Brotli 
   cd /usr/local/src; \
   tar xvzf brotli-1.0.9.tar.gz; \
   cd brotli-1.0.9/; \
   mkdir out && cd out; \
   ../configure-cmake

   CMake Warning at CMakeLists.txt:319 (message): 

    make ---> make install 

  Brotli/usr/local/lib  
  echo /usr/local/lib > /etc/ld.so.conf.d/usr-local-lib.conf; \
  ldconfig

   httpd-2.4.53 
  systemctl stop apache2; \
  systemctl disable apache2; \
  rm -rf /usr/local/apache2; \
  rm -rf /usr/local/src/httpd-2.4.53

  httpd-2.4.53 

   SSL  HTTP/2Brotli 
  cd /usr/local/src; \
  tar xzvf httpd-2.4.53.tar.gz; \
  cd /usr/local/src/httpd-2.4.53;\
  ./configure \
  --enable-ssl \
  --with-ssl=/opt/openssl \  <---  openssl 
  --enable-ssl-staticlib-deps \
  --enable-http2 \
  --enable-brotli \     <--- Brotli 
  --with-brotli=/usr/local/lib \  <--- Brotli 
  --with-apr=/usr/local/apr \
  --with-apr-util=/usr/local/apr \
  --enable-mods-shared=all
  --enable-rewrite \
  --enable-deflate=shared \  <---  gzip 使
  --enable-so          

      make --->  make install 

  /usr/local/apache2/conf/httpd.conf 

 httpd.conf []

 106
 #LoadModule brotli_module modules/mod_brotli.so

  /usr/local/apache2/conf/extra/httpd-ssl.conf 

 httpd-ssl.conf []

 132 SSLEngine on 
 Include conf/extra/httpd-Brotli.conf <------- 

 Include conf/extra/httpd-zgip.conf 

  httpd-Brotli.conf  (  conf )

  httpd-Brotli.conf 
 touch /usr/local/apache2/conf/extra/httpd-Brotli.conf
vi( brotli_module )
 vi /usr/local/apache2/conf/extra/httpd-Brotli.conf
  htmljscss ( br)

<ifModule brotli_module>
      #---------------------------------------------------
      #                 Brotli 圧縮設定
      #---------------------------------------------------
      #
      ## 圧縮レベル: 0-11 (default: 11)
      BrotliCompressionQuality 5
      #
      ## BrotliWindowSize: 10-24 (default: 22)
      BrotliCompressionWindow 18
      #
      AddOutputFilterByType BROTLI_COMPRESS text/html text/plain\
        text/css text/xml text/javascript\
        application/json application/javascript\
        application/x-javascript\
        application/xml\
        application/xml+rss
      #
      SetOutputFilter BROTLI_COMPRESS
      SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-brotli
      #
      BrotliFilterNote Input instream
      BrotliFilterNote Output outstream
      BrotliFilterNote Ratio ratio
      #
      # 圧縮率の確認用ログ設定
      # 不要になったら、# で無効にしておく事。
      # BROTLI_COMPRESSが有効になっているか確認するログの出力
      #
      LogFormat '"%r" %{outstream}n/%{instream}n\
 (%{ratio}n%%) %{User-agent}i' brotli
      CustomLog "logs/Brotil_access_log" brotli
      #---------------------------------------------------
</ifModule brotli_module>

  apache 
   systemctl start apache2

  apache2 
   /usr/local/apache2/bin/apachectl -M

    ()
   deflate_module (shared) <--- zgip 
   brotli_module (shared) <--- Brotli 
   mime_module (shared)
    ()
   ssl_module (shared)  <--- ssl 
   http2_module (shared) <--- http2(h2) 
 ()

  

   root ffftp 

   chown -R miyasaka:miyasaka /usr/local/apache2/logs/Brotil_access_log; \
   chmod -R 666 /usr/local/apache2/logs/Brotil_access_log

    ----> /usr/local/apache2/logs/Brotil_access_log

  ( notepad )

  () ()( [ % ] ) 
 "GET / HTTP/2.0" 5781/31172 (18%) Mozilla/5.0 (Windows NT 10.0) 

 ( BrotliCompressionQuality 5  )
 {()-()}÷()×100 
 1( 31172 - 5781 ) ÷ 31172 × 100  81.45  

 15

BrotliCompressionQuality 1----> "GET / HTTP/2.0" 12619/31172 (40%) 

BrotliCompressionQuality 2----> "GET / HTTP/2.0" 6759/31172 (21%) 

BrotliCompressionQuality 3----> "GET / HTTP/2.0" 6613/31172 (21%) 

BrotliCompressionQuality 4----> "GET / HTTP/2.0" 6214/31172 (19%) 

BrotliCompressionQuality 5----> "GET / HTTP/2.0" 5781/31172 (18%) 

  web 

 web    --->     jpg, png  .html, .js, .css 


-------------------------------------------
content-encoding:br

br は、Brotli の圧縮アルゴリズムフォーマット

content-type:text/html

圧縮対象ファイル html
-------------------------------------------

応答ヘッダーの情報
B

  Brotli使web
  URL  URL 
 tools.paulcalvano.com

  https:// 

       B

⑩ 私の Web サイトの安全性の評価を受けてみました。

 Qualys SSL LABS の提供する「 SSL Server Test 」という WebサイトにおけるSSL暗号化の安全性をチェックするための無料ツールで評価を受けてみました。
 結果は、下記の通り[ A+ ]( 安全 )と評価されました。

A

11. fswebcom-20200725.tar.gz のインストールと定点カメラの設定


  fswebcam-20200725 
 fswebcam-20200725 

2021.07.09 

[  ]
fswebcam-20100622.tar.gz 
(VL ) yum 

 
cd /usr/local/src;\
yum -y install vlgothic-*

 fswebcom使

  fswebcam-20100622.tar.gz 

  
  cd /usr/local/src/; \
  rpm -ivh gd-progs-2.0.35-26.el7.x86_64.rpm; \
  rpm -ivh gd-devel-2.0.35-26.el7.x86_64.rpm

yum 

  yum 
  cd /usr/local/src/; \
  yum -y install gd-progs gd-devel

  fswebcam-20100622  configure
  tar zxvf fswebcam-20100622.tar.gz;\
  cd ./fswebcam-20100622; \
  ./configure --prefix=/usr

  
-------------------------------------------------------
 checking for working mmap... yes
 checking for gdImageCreateTrueColor in -lgd... yes
 checking for gdImageStringFT in -lgd... yes
 checking for gdImageJpeg in -lgd... yes
 checking for gdImagePngEx in -lgd... yes

 Buffer type ........... 16 bit
 PNG support ........... yes
 JPEG support .......... yes
 Freetype 2.x support .. yes
 V4L1 support .......... yes
 V4L2 support .......... yes

 configure: creating ./config.status
 config.status: creating Makefile
 config.status: creating config.h

  make  
  make && make install

  
 ------------------------------------------------------
 mkdir -p /usr/bin
 mkdir -p /usr/share/man/man1
 install -m 755 fswebcam /usr/bin
 install -m 644 fswebcam.1.gz /usr/share/man/man1

  Logicool C270  UVC  USB 調

  -s Brightness=65%
  -s Contrast=15%  <---- 

  Logicool C270  CentOS 7.0 

 cat /proc/bus/usb/devices ----> cat /sys/kernel/debug/usb/devices

 

  cat /sys/kernel/debug/usb/devices 

  S: SerialNumber=E981E810
  ( E981E810 USB )

12. clamav-0.103.2-1 ( アンチウィルスソフト )のインストール


  [ 2021.05.13  ]
 clamav-0.103.2-1 

 20215 
 freshclam /etc/cron.d/clamav-update clamscan   /etc/cron.daily/  (  )

  
    : :

   cd /usr/local/src; \
   rpm -Uvh pcre2-10.23-2.el7.x86_64.rpm; \  <---- 0.10X.X 
   rpm -Uvh libprelude-5.2.0-2.el7.x86_64.rpm; \
   rpm -Uvh clamav-filesystem-0.103.2-1.el7.noarch.rpm; \
   rpm -Uvh clamav-data-0.103.2-1.el7.noarch.rpm; \
   rpm -Uvh clamav-lib-0.103.2-1.el7.x86_64.rpm; \
   rpm -Uvh clamav-update-0.103.2-1.el7.x86_64.rpm; \
   rpm -Uvh clamav-0.103.2-1.el7.x86_64.rpm

   rpm yum 

  yum  

   cd /usr/local/src;\
   yum -y install epel-release;\
   yum -y --enablerepo=epel install clamav clamav-update

    clamav 

  1. rpm -qa | grep clam 
   
   
   .rpm 
  2. ,,    freshclam 

   : clamupdate  : clamupdate 
 (clamav)(clamav)???

    clamav 

   groupadd clamav   <----  clamav 

    clamav 

   /bin/false"Clamav AntiVirus"

   useradd -g clamav -s /bin/false -c "Clamav AntiVirus" clamav

    -g :  -c : (  )
    -s : 
    /bin/false : 


  clamav 

   ()

   grep clam /etc/group

   clamupdate:x:990:
   clamav:x:1001:

   ()

   grep clam /etc/passwd

   clamupdate:x:991:990:Clamav database update user:/var/lib/clamav:/sbin/nologin
   clamav:x:1001:1001:Clam AntiVirus:/home/clamav:/bin/false

  freshclam 
  cp /etc/freshclam.conf /home/miyasaka/freshclam.conf.bak; \
  sed -i -es/#DatabaseDirectory/DatabaseDirectory/g
  s/#UpdateLogFile/UpdateLogFile/g 
  s/#DatabaseOwner /DatabaseOwner /g /etc/freshclam.conf

  vi /etc/freshclam.conf
  :13 13

  

 13 DatabaseDirectory /var/lib/clamav   <---- 

 17 UpdateLogFile /var/log/freshclam.log  <---- 

 56 DatabaseOwner clamupdate   <---- 

  freshclam_sleep 3

 36

   vi /etc/cron.d/clamav-update

 ## It is ok to execute it as root; freshclam drops privileges and becomes
 ## user 'clamav' as soon as possible
        0   */3 * * * root /usr/share/clamav/freshclam-sleep
           
     6

  
 

   freshclam

   [Ctrl]+c 
 

※ 参考情報 ※
   freshclam を実行した時に、下記エラーになる時の対策方法

   ERROR: Can't change dir to /usr/local/share/clamav

   ディレクトリ /usr/local/share/clamav を作り、所有者を clamav に移行する。

   mkdir /usr/local/share/clamav;\
   chown clamav /usr/local/share/clamav

   所有者を移行しないと、下記の様なエラーメッセージが出ます。

ERROR: Can't create temporary directory /usr/local/share/clamav/clamav-a…(省略)….tmp
Hint: The database directory must be writable for UID 1001 or GID 100


  ()
 

   clamscan

   

   /root/.bash_logout: OK
   /root/.bash_profile: OK
   /root/.bashrc: OK
   /root/.cshrc: OK
   /root/.tcshrc: OK
   /root/anaconda-ks.cfg: OK
   /root/.bash_history: OK

  ----------- SCAN SUMMARY -----------
  Known viruses: 4830340
  Engine version: 0.99.2
  Scanned directories: 1
  Scanned files: 7
  Infected files: 0   <---- 
   Data scanned: 0.00 MB
  Data read: 0.00 MB (ratio 0.00:1)
  Time: 38.824 sec (0 m 38 s)

  
 httpd  apr-util 

 

 /usr/local/src/apr-util-1.5.4.tar.gz: Xml.Exploit.CVE_2013_3860-3 FOUND
 /usr/local/src/httpd-2.4.23/srclib/apr-util/test/data/billion-laughs.xml: 
Xml.Exploit.CVE_2013_3860-3 FOUND

  

 (Clam AntiVirus)

   (Clam AntiVirus)


 

[  ] 
            []

  freshclam 

 freshclam ( )

  cat /var/log/freshclam.log-yyyymmdd  <---- yyyy : 西 mm :  dd : 

  cat /var/log/freshclam.log-20160922

 freshclam 

  vi /etc/logrotate.d/clamav-update
 cp /etc/logrotate.d/clamav-update /home/miyasaka/clamav-update.bak; \
 sed -i -es/monthly/daily/g
 3i\      missingok\n\
 rotate 5/etc/logrotate.d/clamav-update

 

  /var/log/freshclam.log {
   monthly    <---- 
   notifempty   <---- 
  }

        5

  /var/log/freshclam.log {
    daily   <---- 
    missingok <---- 
    rotate 5  <---- 5
    notifempty  <---- 
  }

  ClamAV SELinux

 setsebool 
 ClamAV 

  setsebool -P antivirus_can_scan_system 1;\
  setsebool -P antivirus_use_jit 1

 

  getsebool -a | grep antivirus

  antivirus_can_scan_system -->on
  antivirus_use_jit -->on

yum を使用して ClamAV のバージョンアップする手順

  ClamAVは EPELレポジトリにあるので、EPELレポジトリを追加します。

① EPELレポジトリのインストール

  yum install -y epel-release

② yum で ClamAV をアップデートします。

  yum -y --enablerepo=epel update clamav

③ バージョンを確認してみます。

  バージョンの確認コマンド

  rpm -qa | grep clam

アップデート前のバージョン

clamav-data-0.103.4-1.el7.noarch
clamav-lib-0.103.4-1.el7.x86_64
clamav-filesystem-0.103.4-1.el7.noarch
clamav-update-0.103.4-1.el7.x86_64
clamav-0.103.4-1.el7.x86_64

↓ ↓ ↓

アップデート後のバージョン 2022.01.24 現在

clamav-data-0.103.5-1.el7.noarch
clamav-lib-0.103.5-1.el7.x86_64
clamav-filesystem-0.103.5-1.el7.noarch
clamav-update-0.103.5-1.el7.x86_64
clamav-0.103.5-1.el7.x86_64



13. chkrootkitの導入

① chkrootkit のインストール

make で下記エラーでるので不足パッケージ( glibc-static )をインストールしておきます。

---------------------------------------------------
/bin/ld: -lc が見つかりません

collect2: エラー: ld はステータス 1 で終了しました
make: *** [strings-static] エラー 1。

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


ここは、依存性が多いので yum でインストールします。

  cd /usr/local/src/; \
  yum -y install glibc-static

② chkrootkit のインストール

  cd /usr/local/src; \
  tar zxvf chkrootkit.tar.gz; \
  cd chkrootkit-0.50; \
  make sense; \
  mv ./chkrootkit /usr/bin/chkrootkit

③ 起動用シェルスクリプトの作成

  cd /usr/local/src; \
  vi rootkit.sh
-----------------------------------------------------------
#!/bin/sh
# コマンドパスの設定
PATH=/usr/bin:/bin:/root/bin  
<--- 環境変数へ chkrootkit のパス設定
#
LOG='/var/log/chkrootkit.log'

# chkrootkit実行
chkrootkit > ${LOG}

 if [ ! -z "$(grep INFECTED$ ${LOG})" ]; then 
<--- 改ざんがあったかチェック

   # 改ざんがあった時の root 宛メール
   
# upstartパッケージ更新時のSuckit誤検知対策
   if ! rpm -V `rpm -qf /sbin/init` >/dev/null 2>&1;

    then
     cat "$(grep INFECTED$ ${LOG})" | mail -s "rootkit discovery" root
   fi
 else
   # 改ざんが無かった時の root 宛メールの出力の有
   echo "**** rootkit check OK ****"  
<--- 手動実行時の確認メッセージ
    echo "**** rootkit check OK ****" | mail -s "*** rootkit check ***" root
 fi
#
chmod 600 ${LOG}


    if ! rpm -V `rpm -qf /sbin/init` > /dev/null 2>&1; 

 rpm -qf 
 RPM調

  rpm -qf /sbin/init  upstart-0.6.5-13.el6_5.3.x86_64 

 rpm -V 
 

 if ! 0  then 
 /sbin/init
 > /dev/null 2>&1; 

 /sbin/init

  rootkit.sh 

   chmod 700 rootkit.sh

  2 cron 

   0 2 * * * /usr/local/src/rootkit.sh

  

 root 
 mail  rootkit check OK 

 
   rootkit(chkrootkit)

  chkrootkit 
  

[ chkrootkit ] 
 []

   Searching for Suckit rootkit... Warning: /sbin/init INFECTED 
 ( 2018.09.16  )
  rootkit.sh  chkrootkit 
 

 # chkrootkit chkrootkit.log 
 chkrootkit > ${LOG} 
  
 # chkrootkit chkrootkit.log 
 ## [Searching for Suckit rootkit... Warning: /sbin/init INFECTED] ###
 ##  ###

 chkrootkit | grep INFECTED | egrep -v "/sbin/init" > ${LOG} 

##  ## 
| grep INFECTED  "INFECTED"  "/sbin/init" 
 | egrep -v "/sbin/init" 


14. sendmail のインストール


  root sendmail 

  cd /usr/local/src; \
  rpm -Uvh hesiod-3.2.1-3.el7.x86_64.rpm; \
  rpm -Uvh procmail-3.22-36.el7.x86_64.rpm; \
  rpm -Uvh sendmail-8.14.7-5.el7.x86_64.rpm

  yum 

  yum -y install sendmail

  sendmail 

  systemctl start sendmail

  # 

  

  systemctl enable sendmail

  # OK

 root mail 
   mail 使


15. Logwatch のインストールと毎日のメールを簡単にチェックする方法


 

  cd /usr/local/src/; \
  rpm -ivh logwatch-7.5.4-1.noarch.rpm

 yum 

  yum -y install logwatch

  Logwatch 

  logwatch.conf   root

   

1sed 
    

cp /usr/share/logwatch/default.conf/logwatch.conf /home/miyasaka/logwatch.conf.bak; \
sed -i -es/#Archives = No/Archives = YES/
s/Detail = Low/Detail = Med/
s/sendmail -t/sendmail -t -f root@localhost/
s/#LogDir/LogDir//usr/share/logwatch/default.conf/logwatch.conf

  vi /usr/share/logwatch/default.conf/logwatch.conf


71 

#Archives = Yes
  
 Archives = Yes

Low (=0), Med (=5), High (=10)  010
82 Med 

Detail = Low
     
Detail = Med

 
 120 rooo
 [ Can't execute sendmail -t: No such file or directory ]

  mailer = "/usr/sbin/sendmaill -t"
        
  mailer = "/usr/sbin/sendmaill -t -f root@localhost"

 
 139 # 

 #LogDir = /var/log
    
 LogDir = /var/log

  Logwatch cron.daily 34  crontab 

  Logwatch  rooo  

 1. Logwatch  rooo  

 2. Logwatch  rooo10

 3. cron 4

 4. /var/spool/mail/root   

 5.  chkrootkit DiCE   

 

 

  12/13 13:34 miyasaka.com
  IP
 × 12/14 10:46 IP 
 × 12/16 16:37 IP 
 × 12/18 15:54 IP 
  12/19 15:03 IP >183.176.129.222 <---- 
  12/19 15:03 miyasaka.com         IP
  IP 

  
 corn  [ > /dev/null 2>&1 ] 
 
  rooo
 (  )

 6. DiCE  roooIP7 cron 
 ( DiCE IP )

 7. Logwatch  rooo Jcode   Shift_JIS 

 8. rooo  perl cp(    )使  open  ( get_data )
 (cp) open 使便
 

  open( get_data, "<+");

 cgi  Logwatch  rooo
 使

   
 rooo

[ Logwatch  rooo ] 
 []


16. 漢字コード変換用に nkf のインストール


  apache  nkf   
 CentOS 6.6 Jcode 使CentOS 7  cron   Jcode 
 CentOS 7 ( UTF-8  )   nkf 使
 Jcode 

  nkf 

  cd /usr/local/src; \
  tar zxvf nkf-2.1.5.tar.gz; \
  cd nkf-2.1.5; \
  make && make install

   
-----------------------------------------------------------
 mkdir /usr/local/bin <----  nkf 
 mkdir:  `/usr/local/bin' : 
 make: [install]  1 ()
 mkdir /usr/local/man
 mkdir /usr/local/man/man1
 mkdir /usr/local/man/ja
 mkdir /usr/local/man/ja/man1
 cp -f nkf /usr/local/bin/
 cp -f nkf.1 /usr/local/man/man1/
 cp -f nkf.1j /usr/local/man/ja/man1/nkf.1
 -----------------------------------------------------------
  nkf 使

 EUC-JP   Shift_JIS   cron   nkf

 1) 

   /usr/local/bin/nkf -s --overwrite (  )

   -s :  Shift_JIS 
   -e :  EUC  
   -w :  UTF-8  

   (  --overwrite )

 2) 

   /usr/local/bin/nkf -s (  ) > (  )

 3)  nkf 使 Tera Term  EUC   | nkf -e 

  ex. cat -n  | nkf -e

  

  GMODE  Shift-JIS, EUC-JP 

  nkf -g (  )

  

   Linux which 

   nkf 

  which nkf ---> /usr/local/bin/nkf

  perl,(sh)nkf使  

  cron  perl, (sh)使

  1. Tera Term 使   eucJP( EUC ) cron  perl, (sh)  nkf 使root ( ja_JP.UTF-8 )  

  11 */1 * * * export LANG=ja_JP.eucJP; /(DocumentRoot)/ondo_.pl

  2. nkf  EUC   
 Tera Term  cron    ( cron root   UTF-8  )
 ( Tera Term  EUC  EUC   )

  Tera Tarm ( perl, sh )  

 perl SD_Card_Check.pl   SD J[h }Eg nj 
  nkf 使 perl SD_Card_Check.pl | nkf -e  
 Tera Term  EUC 

 perl SD_Card_Check.pl | nkf -e ----> SD   

  3. cron  perl 使 (sh)使  export LANG=ja_JP.eucJP; 


17. 自前プログラムでダイナミック DNS を定期更新させる。


 20201010 ( DiCE )
  DNS (  )IP(  )  (  DNS   DNS  Domain Name System )

DiCE   Error:  


VALUE DOMAIN 使
VALUE DOMAIN 

https://dyn.value-domain.com/cgi-bin/dyn.fcg?d=[]&p=[]&h=[]&i=[IP]

&i=[IP] IP
a( IP )

 sh () crontab (115 ) ( DiCE )
crontab 115 23
* 23 1,15 * * /root/VALUE_DOMAIN_DNS_set.sh > /dev/null 2>&1


  

shwget 使
DiCE 
DiCE DiCE 

https://dyn.value-domain.com/cgi-bin/dyn.fcg?ip IP

 sleep 2s 

vi VALUE_DOMAIN_DNS_set.sh

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

#!/bin/sh
#
# 
VALUE DOMAIN DNS サーバー 更新処理 IPアドレスは、省略
# 
省略時は、アクセス時のIPアドレスがセットされる。
#
#  
date コマンド %-d : 先頭の 0 カット
#  
%_H : 先頭の 0 をスペースにする H : 24時間表示
#  
mm/dd hh:mm 形式 日付データ作成
#
echo -ne "$(date +"%_m")/$(date +"%-d") $(date +"%_H"):$(date +"%M")\n" >> /usr/local/DiCE/log/events.log
#
#   
IPアドレス取得
#
wget -O - 'https://dyn.value-domain.com/cgi-bin/dyn.fcg?ip' >> /usr/local/DiCE/log/events.log
#
#   
改行 追加
#
echo -ne "\n" >> /usr/local/DiCE/log/events.log
#
sleep 2s     
# 2 秒待
#
#  
VALUE DOMAIN ネームサーバー登録IPアドレス更新
#
wget -O - 'https://dyn.value-domain.com/cgi-bin/dyn.fcg?d=XXXXXX.XXX&p=○○○○&h=*' >> /usr/local/DiCE/log/events.log
#

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


 wget -O - ()-
 >> /usr/local/DiCE/log/events.log  events.log 
 XXXXXX.XXXwww 
 VALUE DOMAIN 
 echo -ne (\n) echo 
  https:// 使



10/9 23:00
119.150.8.211
status=0
OK

   グローバルIPアドレスが、変化したときの対策


 IP 99 ()(ISP) IP 
( )

 VALUE DOMAIN  IP 
1020
( 20221)

https://www.value-domain.com/moddns.php?action=moddns2&domainname=[] 

 IP 


IP 

 [ IP  ] 

IP 

 crontab 10

*/10 * * * * /root/IP_Check.sh > /dev/null 2>&1


   vi IP_Check.sh

#!/bin/sh
#
#------------------------------------------------
#
モデム(ブロードバンドルータ)が、管理しているIPアドレスを取得
#
Atermip=$(wget -O - 'http://dyn.value-domain.com/cgi-bin/dyn.fcg?ip')
#
#Atermip="000.000.000.000"   
# Test 用 IPアドレス
echo "Aterm G.IP $Atermip"      
# 確認用
#
#------------------------------------------------
#
dig コマンドでネームサーバが認識しているIPアドレスを取得
#
結果を get_data に格納する
#
;; ANSWER SECTION:行の次の行を取得する( grep -A 1 )
#
get_data=$(dig
[www 付きドメイン名]> | grep -A 1 ";; ANSWER SECTION:" | grep [www 付きドメイン名])
#
#
ドメインのある行のみが抽出されます
#
IP_file_Array=(`echo ${get_data}`) 
# 配列として代入
#
echo "dig G.IP ${IP_file_Array[4]}"   
# 5番目に IPアドレス 確認用
#
myip=$(echo -n ${IP_file_Array[4]})
# 改行削除
#
#echo "${myip} 改行削除"       
# 改行削除確認用
#---------------------------------------------------------
#
グローバルIPアドレス 判定  相違の時 更新処理をさせる。
#
if [ ${Atermip} != ${myip} ]; then
#
        echo "IPアドレス変更"
## ( ここに グローバルIPアドレス 更新の処理を記述する。)
#
else
        echo "変化無し"
fi
#
# 終了
#------------------------------------------------




18. 自宅サーバの管理・運用監視対策等


 1). 

 
 IP

  DiCE  ==>IP ==>    (crontab) ==> 

 DiCE  ==>IP ==>  ==> 

    
   

  

 #!/bin/bash
 # 
# DiCE.service 
 # IP 192.168.0.HH 
 #----------------------------------------------------------------------
 # DiCE 
 systemctl stop DiCE.service
 systemctl disable DiCE.service

 # IP 192.168.0.XX ---> 192.168.0.HH
 sed -i -e "s/192\.168\.0\.XX/192\.168\.0\.HH/g"\
 /etc/sysconfig/network-scripts/ifcfg-enp2s0

 # crontab  ()
 # * * * * * /var/www/system/New_check_process.pl 
 sed -i -e "/New_check_process\.pl/s/^/#/" /var/spool/cron/root

 # 
 poweroff
 #----------------------------------------------------------------------

  

 ( )
 #!/bin/bash
 # 
# DiCE.service 
 # IP 192.168.0.XX 
 #----------------------------------------------------------------------
 # DiCE 
 systemctl enable DiCE.service
 systemctl start DiCE.service

 # IP 192.168.0.HH ---> 192.168.0.XX
 sed -i -e "s/192\.168\.0\.HH/192\.168\.0\.XX/g"\
 /etc/sysconfig/network-scripts/ifcfg-enp2s0

 # crontab  ()
 # #* * * * * /var/www/system/New_check_process.pl  # 
 sed -i -e "/New_check_process\.pl/s/^#//" /var/spool/cron/root

 # 
 reboot
 #----------------------------------------------------------------------
 SDSD

 SD    (  )  
 SD

 SD
 

 
(  LAN)
 2). apache httpd-2.4.XX  httpd-2.4.6 
  

 httpd-2.4.XXopensslnghttp2brotli   apache  htppd-2.4.6  htppd-2.4.6 
SELinux htppd-2.4.6 

httpd-2.4.XX  httpd-2.4.6 sh root 

(sh )
 status 

  apache2 ---->> httpd-2.4.6 
#!/bin/bash
# apache2 ---->> httpd
#-----------------------------
# apache2  
systemctl disable apache2
systemctl stop apache2

# httpd 
systemctl enable httpd
systemctl start httpd
systemctl status httpd
#-----------------------------
  httpd-2.4.6 ---->> apache2 
#!/bin/bash
# httpd ---->> apache2
#-----------------------------
# httpd  
systemctl disable httpd
systemctl stop httpd

# apache2 
systemctl enable apache2
systemctl start apache2
systemctl status apache2
#-----------------------------
 3). 

 ( ps -ef ) httpd,sshd,vsftpd/proftpd,DiCE   1

 http /usr/local/apache2/bin/httpd
 

 perl   cron 1

 [ Linux  ] 
            []


 4). CPU 

 CPU sensors 
 lm_sensors rpm 
 yum 
 20199 

   cd /usr/local/src; \
   rpm -Uvh lm_sensors-3.4.0-8.20160601gitf9185e5.el7.x86_64.rpm

   yum 

   yum -y install lm_sensors

  32bit CentOS 6.7 

   CPU  SSI  

 -----------------------------------------------------------
 #!/usr/bin/perl
 #----------------------------------------------------
 # lm_sensors使 CPU 
 #----------------------------------------------------
 #  Core 

 $Data1 = `/bin/sensors | grep Core`;

 #  CPU 
 @Data2 = split("\n",$Data1);
 #  
 @Data = split(" ",$Data2[0]);
 # 
 $temp = substr( $Data[2], 0,3 );
 #  HTML 
 print "CPU  $temp \n";
 -----------------------------------------------------------


 5). ftp 

   ftp 

   cd /usr/local/src; \>
   rpm -Uvh ftp-0.17-67.el7.x86_64.rpm

   yum 

   yum -y install ftp


 6). OS()()

OS( yum -y update )OS
 reboot 
 reboot 

 CentOS 7  reboot 
  /boot 
 
 

   a. /boot 使調

    df -m /boot

    

    Filesystem  1M-blocks Used Available Use% Mounted on
    /dev/sda1  497 248  249 50% /boot

   b. /boot 

    ls -l /boot

  219604
 -rw-------. 1 root root 2963297 5 12 20:13 System.map-3.10.0-327.18.2.el7.x86_64
 -rw------- 1 root root 2963822 6 24 02:14 System.map-3.10.0-327.22.2.el7.x86_64
 -rw------- 1 root root 2964683 8 3 20:21 System.map-3.10.0-327.28.2.el7.x86_64
 -rw------- 1 root root 2964731 8 19 04:15 System.map-3.10.0-327.28.3.el7.x86_64
 -rw-------. 1 root root 2963044 11 20 2015 System.map-3.10.0-327.el7.x86_64

    (  )

    

   c. 

    package-cleanup --oldkernels --count=1 <---- 2
    

 :fastestmirror, langpacks, priorities
 ---> 
 --->  kernel.x86_64 0:3.10.0-327.el7  
 --->  kernel.x86_64 0:3.10.0-327.18.2.el7  
 --->  kernel.x86_64 0:3.10.0-327.22.2.el7  
 --->  kernel.x86_64 0:3.10.0-327.28.2.el7  
 --->  kernel-devel.x86_64 0:3.10.0-327.el7  
 --->  kernel-devel.x86_64 0:3.10.0-327.18.2.el7  
 --->  kernel-devel.x86_64 0:3.10.0-327.22.2.el7  
 --->  kernel-devel.x86_64 0:3.10.0-327.28.2.el7  
 ---> 

    (  )

    : 507 M
     [y/N]y <---- y 

    (  )

    :
    kernel.x86_64 0:3.10.0-327.el7      kernel.x86_64 0:3.10.0-327.18.2.el7
    kernel.x86_64 0:3.10.0-327.22.2.el7    kernel.x86_64 0:3.10.0-327.28.2.el7
    kernel-devel.x86_64 0:3.10.0-327.el7   kernel-devel.x86_64 0:3.10.0-327.
    kernel-devel.x86_64 0:3.10.0-327.22.2.el7 kernel-devel.x86_64 0:3.10.0-327.

    !

   c. 

     df -m /boot

      1M- 使 使 使% 
    /dev/sda1  497  108  390 22% /boot

    50%  22% 

   d. /boot 

    ls -l /boot

  75708
 -rw------- 1 root root 2964731 8 19 04:15 System.map-3.10.0-327.28.3.el7.x86_64
 -rw-r--r-- 1 root root 126431 8 19 04:15 config-3.10.0-327.28.3.el7.x86_64

    (  )

    


 7). root 

 使 /var/log    cron-20160918  maillog-20160918 ,  messages-20160918 
root  調rm(rm-- )
rm   ls -l 

   cd /var/log  <----  /var/log 
   rm -- cron-20160918  <---- cron 

   rm:  `cron-20160918' ?
   y 
   

 
  
 ファイル名 と  記録されるログの内容 

    btmp      : 各ユーザーのログイン失敗情報   
    cron      : cron実行時の情報
    freshclam.log  : clamavのウィルスアップデート結果
    maillog     : メールプログラムが出力したメッセージ
    messages     : デーモンの動作状況
    secure     : ログインなど認証を実行した情報
    spooler     : 印刷スプールに関する情報
    wtmp       : ログイン情報
    yum.log     : yumの操作結果

 8). IP

IP vi /etc/sysconfig/network-scripts/ifcfg-enp2s0   

 CentOS7 nmtui  system-config-network-tui> 
 

 使

 使nmtui 

   nmtui   
  [] [Enter]
    enp2s0  [Enter]
 
    IPv4 
  <OK>[Enter]

IP () 192.168.0.XX/24 XX
 /24 (255.255.255.0)

    <>[Enter]
 
 IPsystemctl restart NetworkManager  reboot 
 
写真 ①A 写真 ②B 写真 ③C

 9). SD

SD
 

 SD lsblk 調

  lsblk 
     NAME MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
     sda 8:0    0 119.2G  0 disk
     |-sda1 8:1    0   500M  0 part /boot
     `-sda2 8:2    0   117G  0 part
              ( 省略 )
     sdb      8:16   1  14.7G  0 disk
     `-sdb1   8:17   1  14.7G  0 part      <-- SDカードのデバイス名

 ( -sdb1 SDsdb )
    ONKYO DP315 PC 

     mouse PC sdb 

    16GB 
       mmcblk0       179:0    0  14.7G  0 disk
       `-mmcblk0p1   179:1    0  14.7G  0 part

     4GB 
       mmcblk0  179:0    0   3.7G  0 disk

 

  ()

  vi /usr/lib/systemd/system/SD_Card_mount.service 
 (  SD_Card_mount )
 --------------------------------------------------------------------------- 
[Unit]
 Description= SD_Card_mount
 After=network.target

 [Service]
 Type=simple
 ExecStart=/root/SD_Card_mount.sh

 [Install]
 WantedBy=multi-user.target

設定項目の説明

Description= 〇〇〇〇   <---- サービスのタイトル(任意の文字列)
After=network.target   <---- networkが起動してから実行
Type=simple       <---- コマンドを実行したらすぐに起動完了
ExecStart=/root/SD_Card_mount.sh  <---- 実行コマンド


  SD_Card_mount 

   systemctl enable SD_Card_mount

 systemctl status SD_Card_mount  inactive (dead) ()

 * SD_Card_mount.service - SD_Card_mount
 Loaded: loaded (/usr/lib/systemd/system/SD_Card_mount.service; enabled; 
vendor preset: disabled)
 Active: inactive (dead)  

 SD

   vi SD_Card_mount.sh ( root  )
 --------------------------------------------------------------------------- 
#!/bin/sh
 #---------------------------------------------
 # SD
 #---------------------------------------------
 # sdb () sdb1 
 #
 mount -t vfat /dev/sdb /mnt/SD_Card || mount -t vfat /dev/sdb1 /mnt/SD_Card
 ---------------------------------------------------------------------------

     sdb, sdb1 PC
        /mnt 
        ()  SD_Card  /mnt 

     mkdir -p /mnt/SD_Card

  

  systemctl start SD_Card_mount  lsblk 

     sdb       8:16  1 14.7G  0 disk
     `-sdb1      8:17  1 14.7G  0 part /mnt/SD_Card

      
     start 


戻る