今回はwheelグループを対象に設定する。下記コマンドを実行して/etc/sudoersを編集する。
# visudo
ファイル終盤ぐらいにある下記の部分、上の方をコメントブロックし、下の方をコメント解除する。
## Allows people in group wheel to run all commands # %wheel ALL=(ALL) ALL ## Same thing without a password %wheel ALL=(ALL) NOPASSWD: ALL
人生の最終目標は気ままな老後生活
今回はwheelグループを対象に設定する。下記コマンドを実行して/etc/sudoersを編集する。
# visudo
ファイル終盤ぐらいにある下記の部分、上の方をコメントブロックし、下の方をコメント解除する。
## Allows people in group wheel to run all commands # %wheel ALL=(ALL) ALL ## Same thing without a password %wheel ALL=(ALL) NOPASSWD: ALL
今回はDNSサーバーもDHCPサーバーも1台で兼任させる。
まずインストールする。
※Version bind9.11.26 dhcp4.3.6
# dnf install bind dhcp-server
bindから設定する。
下記の箇所の内容を変更または追記する。
options { // zoneファイルの保存場所 directory "/var/named/"; // ほかのdnsサーバーはいないのでno notify no; // LAN内からの問い合わせを許可 allow-query { localhost; 192.168.1.0/24; }; // 自分で名前解決できないときの丸投げ先 forwarders { 192.168.1.254; 8.8.8.8; }; }; zone "example.jp." { type master; file "example.jp.zone"; // 自身からの変更を許可しておく allow-update { localhost; }; };
さっき指定したzoneファイルを作成する。
※admin.example.jp.の部分はadmin@example.jpという管理者のE-mailという意味
$TTL 86400 @ IN SOA dns.example.jp. admin.example.jp. ( 2022032319 10800 36400 604800 86400 ) IN NS dns.example.jp. dns IN A 192.168.1.11
作成したらファイルの所有者をnamedに変更する。
※/var/named/にスティッキービットが設定されているため
# chown named:named /var/named/example.jp.zone
設定ファイルを下記のように編集する。
# DNSサーバーに更新要求を送信する設定 ddns-update-style interim; # 普通のDHCPの設定 subnet 192.168.1.0 netmask 255.255.255.0 { range 192.168.1.101 192.168.1.120; option routers 192.168.1.254; option domain-name "example.jp"; option domain-name-servers 192.168.1.11; # 更新を通知するDNSサーバーを指定 zone example.jp. { primary localhost; } }
SELinuxとFirewallに例外を追加する。
# setsebool -P named_write_master_zones true # firewall-cmd --add-service=dns --permanent # firewall-cmd --add-service=dhcp --permanent # firewall-cmd --reload
サービスを有効にして起動。
# systemctl enable named # systemctl start named # systemctl enable dhcpd # systemctl start dhcpd
nsupdateを使用してDNSサーバーを更新をテストするには bind-utils をインストールし、nsupdateコマンドを実行する。実行したら対話型コンソールになるので下記のような感じで入力する。何もエラーが出なければOK。
>server 127.0.0.1 >update add test.example.jp. 3600 A 192.168.1.222 >send >server 127.0.0.1 >update delete test.example.jp. >send
rndcでdumpして現在のDNSレコードを確認する。
# rndc dumpdb -zones # cat /var/named/named_dump.db | grep dns.example.jp.
AlmaLinux release 8.5 (Arctic Sphynx) Apache 2.4.37 OpenSSL 1.1.1k
SSL関連のパッケージをインストールする。
# dnf install openssl # dnf install mod_ssl
ZeroSSLにログインして発行した証明書のzipファイルをWebサーバーにアップロードして解凍する。
# unzip test.example.com.zip -d /etc/ssl/test.example.com/
SELinuxのラベル付けを行うためのユーティリティをインストールする。
# dnf install policycoreutils-python-utils
httpdからファイルを読み込めるようにSELinuxのラベルを追加する。
# semanage fcontext -a -t httpd_sys_content_t "/etc/ssl/test.example.com(/.*)?" # restorecon -RF /etc/ssl/test.example.com/
Apacheの設定ファイルの最下部にSSL証明書の設定を追記する。
<VirtualHost *:443> ServerName test.example.com DocumentRoot "/var/www/html/test/" <Directory "/var/www/html/test/"> AllowOverride All </Directory> SSLEngine on SSLProtocol -All +TLSv1.2 SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!SEED:!IDEA:!3DES:!RC4:!DH SSLHonorCipherOrder On SSLCertificateFile /etc/ssl/test.example.com/certificate.crt SSLCertificateKeyFile /etc/ssl/test.example.com/private.key SSLCertificateChainFile /etc/ssl/test.example.com/ca_bundle.crt </VirtualHost>
Apacheの設定を再読み込みする。
# systemctl reload httpd
AlmaLinux release 8.5 (Arctic Sphynx) MariaDB 10.3.28
MariaDBをインストールする。
# dnf install mariadb-server
設定ファイルの[mysqld]の下に文字コードの指定を追記する。
[mysqld] character-set-server=utf8mb4
MariaDBの初期設定を行う。
# mysql_secure_installation --------------------------------- NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MariaDB to secure it, we'll need the current password for the root user. If you've just installed MariaDB, and you haven't set the root password yet, the password will be blank, so you should just press enter here. Enter current password for root (enter for none): OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MariaDB root user without the proper authorisation. Set root password? [Y/n] y New password: Re-enter new password: Password updated successfully! Reloading privilege tables.. ... Success! By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] y ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] y ... Success! By default, MariaDB comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] y - Dropping test database... ... Success! - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] y ... Success! Cleaning up... All done! If you've completed all of the above steps, your MariaDB installation should now be secure. Thanks for using MariaDB!
AlmaLinux release 8.5 (Arctic Sphynx) Apache 2.4.37 OpenSSL 1.1.1k
SSL関連のパッケージをインストールする。
# dnf install openssl # dnf install mod_ssl
Let’sEncryptの証明書を発行するためのcertbotをインストールする。
# dnf install epel-release # dnf install certbot
SSL証明書を発行する。何度も失敗したりしても制限がかかるので、–dry-runオプションを指定してテストする。
# certbot certonly --webroot -w /var/www/html/test/ -d test.example.com ------------------------------------------------------------- Saving debug log to /var/log/letsencrypt/letsencrypt.log Enter email address (used for urgent renewal and security notices) (Enter 'c' to cancel): admin@test.example.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Please read the Terms of Service at https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must agree in order to register with the ACME server. Do you agree? - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (Y)es/(N)o: Y - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Would you be willing, once your first certificate is successfully issued, to share your email address with the Electronic Frontier Foundation, a founding partner of the Let's Encrypt project and the non-profit organization that develops Certbot? We'd like to send you email about our work encrypting the web, EFF news, campaigns, and ways to support digital freedom. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (Y)es/(N)o: N Account registered. Requesting a certificate for test.example.com Successfully received certificate. Certificate is saved at: /etc/letsencrypt/live/test.example.com/fullchain.pem Key is saved at: /etc/letsencrypt/live/test.example.com/privkey.pem This certificate expires on 2022-06-01. These files will be updated when the certificate renews. Certbot has set up a scheduled task to automatically renew this certificate in the background. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
発行が成功すると下記の場所に証明書が作られる。ほかのサーバーに移行する場合は/etc/letsencrypt/ごとコピーすればOKだった。
/etc/letsencrypt/live/test.example.com/cert.pem /etc/letsencrypt/live/test.example.com/privkey.pem /etc/letsencrypt/live/test.example.com/chain.pem
cronで毎朝4時にSSL証明書を更新するジョブを追加する。更新されるかは自動で決定され、更新された場合のみ–deploy-hookオプションで指定されたコマンドが実行される。
0 4 * * * certbot renew --deploy-hook "systemctl reload httpd"
Apacheの設定ファイルの最下部にSSL証明書の設定を追記する。
<VirtualHost *:443> ServerName test.example.com DocumentRoot "/var/www/html/test/" <Directory "/var/www/html/test/"> AllowOverride All </Directory> SSLEngine on SSLProtocol -All +TLSv1.2 SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!SEED:!IDEA:!3DES:!RC4:!DH SSLHonorCipherOrder On SSLCertificateFile /etc/letsencrypt/live/test.example.com/cert.pem SSLCertificateKeyFile /etc/letsencrypt/live/test.example.com/privkey.pem SSLCertificateChainFile /etc/letsencrypt/live/test.example.com/chain.pem </VirtualHost>
Apacheの設定を再読み込みする。
# systemctl reload httpd
AlmaLinux release 8.5 (Arctic Sphynx) Apache 2.4.37 PHP 7.2.24
Apacheをインストールする。
# dnf install httpd
Apacheの設定ファイル内の「Indexes」を削除して、index.phpが存在しない場合のディレクトリ内の一覧表示機能を無効にする。
<Directory "/var/www/html"> #Options Indexes FollowSymLinks Options FollowSymLinks
続けてApacheの設定ファイルにドメインごとにディレクトリ指定を行う設定を追記する。
# # test.example.com Subdomain configuration # <VirtualHost *:80> ServerName test.example.com DocumentRoot /var/www/html/test/ <Directory /var/www/html/test/> AllowOverride All </Directory> </VirtualHost>
SELinuxのラベル付けを行うためのユーティリティをインストールする。
# dnf install policycoreutils-python-utils
/var/www/html/test/以下のファイルをhttpdから変更できるようSELinuxのラベルを付与する。
# semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html/test(/.*)?" # restorecon -RF /var/www/html/test/
httpdがネットワークに接続することを許可する。
# setsebool -P httpd_can_network_connect true
PHPと使用する拡張をインストールする。
# dnf install php # dnf install php-mbstring # dnf install php-json # dnf install php-mysqlnd # dnf install php-xml # dnf install php-gd
8MB程度のファイルをアップロードするため、下記の箇所を設定変更する。
post_max_size = 10M upload_max_filesize = 10M
WEBサイトからE-mailを送信するため、sendmailをインストールして有効化する。
# dnf install sendmail # dnf install postfix # systemctl enable --now postfix
httpdからE-mailを送信できるようSELinuxの設定を変更する。
# setsebool -P httpd_can_sendmail true
Apacheを起動して有効化する。
# systemctl enable --now httpd
AlmaLinux release 8.5 (Arctic Sphynx)
専用のユーザーを追加してパスワードを設定する。
# useradd sftp # passwd sftp
専用のディレクトリを作成する。chrootに指定するディレクトリの所有者はrootでパーミッションは755である必要がある。
# mkdir /data/ # chmod 755 /data/ # mkdir /data/sftp/ # chown sftp:sftp /data/sftp/
設定ファイルを変更してサブシステムをinternal-sftpに変更する。
#Subsystem sftp /usr/libexec/openssh/sftp-server Subsystem sftp internal-sftp
再度、設定ファイルを変更、「Match User」の箇所の例をコピーして下記のように追記する。
Match User sftp X11Forwarding no AllowTcpForwarding no PermitTTY no ForceCommand internal-sftp ChrootDirectory /data/
ノートパソコンのディスプレイの色がなんか変な感じがして、好みの問題かもしれないけど、温かみが足りないと思いRGBを調整した。
下記のコマンドでディスプレイ名を確認する。
$ xrandr
「eDP」という名前だったので、下記コマンドを自動起動するアプリケーションに登録する。
xrandr --output eDP --gamma 1:0.93:0.93
gnome-pluginとアプレットをクリックした際に起動するカレンダーアプリケーションをインストールする。
# apt install xfce4-genmon-plugin # apt install gnome-calendar
下記のスクリプトファイルを作成する。
#!/bin/bash echo "<txt>"$(date +'%b%-d日(%a) %R')"</txt>" echo "<txtclick>gnome-calendar</txtclick>" echo "<tool>"$(date +'%x (%a)')"</tool>"
下記コマンドで作成したスクリプトを実行可能にし、XFCEパネルにアイテム「ジェネリックモニター」を追加して、作成したスクリプトを指定する。
$ chmod +x /home/user/bin/xfce4-genmon-calendar.sh
画面共有用のtigervncサーバーをインストールする。
# apt install tigervnc-common # apt install tigervnc-scraping-server
パスワードファイルを作成する。
$ vncpasswd
下記のコマンドを実行してサーバーを起動する。
$ x0vncserver -passwordfile /home/user/.vnc/passwd