まだ続いております。
自宅でも気軽に WEB のテストができる環境がほしいと思い立ち、宅内にテスト環境として、専用の PC に VMware をいれ、その上に CentOS で WEB サーバーを建ててしまおう!というのが目標です。Linux 初心者の作業ログですのであしからず。
前回までに、CentOS のインストールが完了しています。今回は CentOS の初期設定を行います。
作業用ユーザーの作成
いつも root で作業していると、大事なシステムファイルを消してしまったりとか、危険がつきもの。そこで、通常では必要な時のみ root の権限を使い、それ以外はユーザー権限で作業を行うようです。
そこで、まず作業用のユーザーを作成します。今回はテスト用として “user” というアカウントを作成します。
[root@centos ~]# useradd user
アカウントは作成した段階ではパスワードが設定されておらず、ログインすることができません。そこで passwd コマンドでパスワードを設定します。
[root@centos ~]# passwd user Changing password for user user. New UNIX password: Retype new UNIX password: passwd: all authentication tokens updated successfully. [root@centos ~]#
“user” というアカウントがでているか確認のため、実際にログインしてみます。root に戻るときは exit コマンドで戻ることができます。
[root@centos ~]# su - user [user@centos ~]$
root になれるアカウントを限定
上で作成した “user” アカウントを root になれるアカウントに設定します。まず、”user” を wheel グループにいれます。どこのサイトを見ても当たり前のように wheel に追加する手順がでてくるのですが、この wheel グループとは何なんでしょうか ? 調べてもあまり情報がでてこないのですが、当たり前すぎることなのでしょうか。。今後の宿題です。
この作業も root でサクッと。
[root@centos ~]# usermod -G wheel user
次に、PAM の su の設定ファイルを変更します。PAM とは何か、また、Linux の各種設定ファイルを編集する “vi” エディタも予習済みなので、さらっと行きます。
PAM の su の設定ファイルの場所は、/etc/pam.d ディレクトリです。ここに、su をはじめ、PAM で認証を行うアプリケーションそれぞれの設定ファイルが、そのままのファイル名であります。今回はその中の su の # (赤いとこ) を削除
[root@centos ~]# vi /etc/pam.d/su
#%PAM-1.0
auth sufficient pam_rootok.so
# Uncomment the following line to implicitly trust users in the "wheel" group.
#auth sufficient pam_wheel.so trust use_uid
# Uncomment the following line to require a user to be in the "wheel" group.
#auth required pam_wheel.so use_uid
auth include system-auth
account sufficient pam_succeed_if.so uid = 0 use_uid quiet
account include system-auth
password include system-auth
session include system-auth
session optional pam_xauth.so
~
~
~
"/etc/pam.d/su" 12L, 486C written
[root@centos ~]#
設定したアカウント “user” 以外のアカウントで su – が実行できないことを確認します。そのためにアカウントを作るのもどうかと思いますが、今回は “user02″ をデフォルト設定で作成し、
[root@centos ~]# useradd user02 [root@centos ~]# passwd user02 Changing password for user user02. New UNIX password: Retype new UNIX password: passwd: all authentication tokens updated successfully. [root@centos ~]#
それぞれのアカウントでログインしなおして、su – できるか確認確認。
[user@centos ~]$ su - パスワード: [root@centos ~]#
“user” では無事 root に。
[user02@centos ~]$ su - パスワード: su: パスワードが違います [user02@centos ~]$
確認用に作った “user02″ では、su – で root になることができません。でも、その時のメッセージって「パスワードが違います」なんですね。。
yum の初期設定
このあたり、手順は完全にCentOS5初期設定を参考にさせていただいています。
さて、CentOS の初期設定の情報は WEB 上にたくさんありますが、yum の設定を行っているのは他であまり見なかったので、その理由を引用させていただきます。
・デフォルトで1時間ごとにアップデートチェックを行うようになっており、手動によるパッケージインストールと競合するとインストールが失敗する
・大量にメモリを消費する(約10MB以上使用)
http://centossrv.com/centos5-init.shtml
cd で init.d ディレクトリまで行って tum-updatesd の停止削除を行ってみました。場所は、/etc/rc.d/init.d/ です。yum コマンドに指定している -y オプションは確認メッセージを非表示にするものです。
tum-updatesd の停止削除ですが、tum-updatesd は、のちほどインストールする yum-cron と同じく、アプリケーションを一括でアップデートしてくれるアプリケーションです。違いとして、常駐型でメモリリークを起こしやすいとのこと。
http://wingse.blog57.fc2.com/blog-entry-143.html
そこで、tum-updatesd をアンインストールしてしまうわけですね。
[root@centos init.d]# yum-updatesd stop [root@centos init.d]# yum -y remove yum-updatesd Loaded plugins: fastestmirror Setting up Remove Process Resolving Dependencies --> Running transaction check ---> Package yum-updatesd.noarch 1:0.9-2.el5 set to be erased --> Finished Dependency Resolution Dependencies Resolved ========================================================================================== Package Arch Version Repository Size ========================================================================================== Removing: yum-updatesd noarch 1:0.9-2.el5 installed 55 k Transaction Summary ========================================================================================== Install 0 Package(s) Update 0 Package(s) Remove 1 Package(s) Downloading Packages: Running rpm_check_debug Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction Erasing : yum-updatesd [1/1] Removed: yum-updatesd.noarch 1:0.9-2.el5 Complete! [root@centos init.d]#
ずいぶん長いものがでましたが、成功したようです。
次は、fastestmirrorプラグインインストールをインストールします。このプラグインを入れると yum コマンドを実行する際、ミラーリストから自動で早いリポジトリを選択
してくれるようです。比較すると劇的に変わるらしいのですが、やったことがないので、なんとも。。手早く先へ進むため、検証なしで GO!
[root@centos init.d]# yum -y install yum-fastestmirror Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: ftp.riken.jp * updates: rsync.atworks.co.jp * addons: ftp.riken.jp * extras: ftp.riken.jp Setting up Install Process Parsing package install arguments Package yum-fastestmirror-1.1.16-13.el5.centos.noarch already installed and latest version Nothing to do
と、思ったら最初から入ってるんですね、yum-fastestmirror。OS CentOS 5.3 です。
う?ん、はじめての yum だったのに。
インストール済パッケージの一括アップデートです。若干時間がかかります。
[root@centos /]# yum -y update
続いて、yum-cron のインストールです。yum-cron はアプリケーションのアップデートを自動でやってくれるアプリケーションです。
以下のコマンドを実行。
[root@centos /]# yum -y install yum-cron http://centossrv.com/bbshtml/webpatio/1185.shtml
ところが、エラーが発生。
Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: ftp.riken.jp * updates: rsync.atworks.co.jp * addons: ftp.riken.jp * extras: ftp.riken.jp Setting up Install Process Parsing package install arguments No package yum-cron available. Nothing to do
パッケージが見つからないと、、調べてみると、CentOS 5.3 には yum-cron がない模様
http://centossrv.com/bbshtml/webpatio/1185.shtml
今回はテスト環境づくりなので、最悪自動アップデートはできなくてもいいけど、できたいなあ、、
宿題がふえました。
root宛メールを転送
、、の設定をためしたのですが、さっぱりうまくゆかず、いつかやろうということに。最終的には qmail を使うので、それで回避できればなあと。。
やってみたこと。
・sendmail-cfインストール
・sendmail設定ファイル編集
・sendmail.mcからsendmail.cfを作成 ← ここでエラー ディレクトリが見つからない。。スペルミスかな。。
・旧root宛メール転送設定削除
・/etc/aliases に root: hoge@nifty.com を追加
・newaliases 実行
・echo test|mail root → やっぱりメールは来ない。
はまりそうなので、また今度?
SELinuxの無効化
引き続きCentOS5初期設定を参考にさせていただいています。でも、なぜ SELinux を無効化するのかが書いていなかったので、調べてみました。
さっと調べた限りでは、あまり有力な情報はなかったけれど、どうやら SELinux がいろんな方面に影響してシステム設定がやっかいなことになるらしい。それなら、全部の設定が完了してから有効にするほうがよさそう、ということみたいです。
[root@centos /]# getenforce Enforcing [root@centos /]# setenforce 0 [root@centos /]# getenforce Permissive
次は、起動時に SELinux を無効にする設定です。
[root@centos /]# vi /etc/sysconfig/selinux # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - SELinux is fully disabled. SELINUX=disabled # SELINUXTYPE= type of policy in use. Possible values are: # targeted - Only targeted network daemons are protected. # strict - Full SELinux protection. SELINUXTYPE=targeted
リブートして、再度 SELinux の状況を確認。
[root@uotarou ~]# getenforce Disabled
無効化成功です!
つづきます。
今回の宿題:
・システムからのメール転送設定
・yum-cron をどうしよう。。








[...] 自宅でVMware + CentOS – その6 CentOS 初期設定 [...]