centos7 - taka512/memo GitHub Wiki
CentOS7
1. インストール
参考
https://blog.apar.jp/linux/194/
1.1 ログインアカウントとグループの追加
# groupadd -g 500 common
# useradd -u 500 -g 500 xxxx
# passwd xxxxx
1.2 sudoファイルにグループ追加
グループにsudo権限を追加
# vi /etc/sudoers
or
# visudo
%common ALL=(ALL) ALL
1.3 rootでログインできないようにsshの設定
# vi /etc/ssh/sshd_config
# パスワードでのrootアカウントへのログインを不可
PermitRootLogin no
# パスワード無しでのログインを不許可
PermitEmptyPasswords no
# パスワードでのログインを許可
PasswordAuthentication yes
# sshdを再起動
systemctl restart sshd.service
1.4 基本コマンドのインストール
yum -y groupinstall base
yum -y groupinstall network-tools
1.5 yumアップグレード
yum -y upgrade
1.6 不要サービスの停止
systemctl disable abrt-ccpp
systemctl disable abrt-oops
systemctl disable abrt-vmcore
systemctl disable abrt-xorg
systemctl disable abrtd
systemctl disable atd
systemctl disable auditd
systemctl disable avahi-daemon
systemctl disable kdump
systemctl disable mdmonitor
systemctl disable dmraid-activation
1.7 SELinux無効設定
vi /etc/sysconfig/selinux
---(下記を変更)---------------------------
SELINUX=enforcing
↓
SELINUX=disabled
1.8 firewalld設定
現在の設定の確認
# 全部
firewall-cmd --list-all-zones
# public
firewall-cmd --list-services --zone=public
追加で http と https を許可
firewall-cmd --add-service=http --zone=public --permanent
firewall-cmd --add-service=https --zone=public --permanent
設定を読込
firewall-cmd --reload
1.9 Chrony設定(NTP)
#初回は手動で時間合わせをします。
ntpdate ntp.nict.jp
#オリジナルのコンフィグをバックアップします。
mv -i /etc/chrony.conf /etc/chrony.conf.org
#コンフィグを作成します。
vi /etc/chrony.conf
---(下記を追加)---------------------------
server ntp.nict.jp
server ntp.nict.jp
server ntp.nict.jp
------------------------------
#サービスを起動します。
systemctl restart chronyd
#自動起動設定をします。
systemctl enable chronyd
1.10 Gmailリレー設定
# GmailのSMTP認証情報ファイルの作成
vi /etc/postfix/gmail
---(下記を追加)---------------------------
[smtp.gmail.com]:587 <Gmailのアドレス>:<Gmailのパスワード>
---------------------------
chmod 600 /etc/postfix/gmail
postmap /etc/postfix/gmail
# Postfixの設定
vi /etc/postfix/main.cf
---(下記を最終行に追加)---------------------------
relayhost = [smtp.gmail.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/gmail
smtp_sasl_security_options = noanonymous
smtp_sasl_tls_security_options = noanonymous
smtp_sasl_mechanism_filter = plain
smtp_use_tls = yes
------------------------------
# 設定した内容を読込みます
systemctl reload postfix
# root宛メールの送信先を変更します
vi /etc/aliases
---(下記を追加)---------------------------
root: <Gmailのアドレス>
---------------------------
# 設定を反映させます。
newaliases
#メールが送信できる事を確認します
echo test | mail -s hostname root
1.11 リポジトリの追加(64bit)
epel
yum install epel-release
remi
yum -y install http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
1.12 各種ミドルウェアインストール
memcached
yum -y install memcached-devel
yum -y install php-pecl-memcache
コマンド
systemctl
設定の参照
# 一覧
systemctl list-unit-files
# list-dependenciesだとツリー状に見れる
systemctl list-dependencies
設定をオフ
# 最初に、firewallサービスを探す。
systemctl list-unit-files | grep firewall
# firewalld.serviceだと解ったので、disableする。
systemctl disable firewalld.service
サービスの起動
# 起動
systemctl start httpd.service
# ステータス表示
systemctl status httpd.service
# 停止
systemctl stop httpd.service
# apacheの有効化
systemctl enable httpd.service
# apacheの無効化
systemctl disable httpd.service
設定ファイル
NIC1の設定(NATアダプター)
/etc/sysconfig/network-scripts/ifcfg-enp0s3
dns
/etc/resolv.conf
ifconfigは廃止
ip addr show
nwの設定
nmtui