Fedora Core 6

ふぃどーら・こあ・しっくす/ふぇどら・こあ・しっくす最終更新日 2013年9月4日

読みが違うという指摘がありましたので、併記しました。おそらく「ふぃどーら」が英語読みに近いかとは思いますが、日本人は「ふぇどら」と読むでしょう、ということで。

RedHat Linuxの血をひくディストリビューション。

Fedora Project

Fedora JP Project (あんまり更新/情報がない)

RedHat 6.2, 7.1, 7.2, 7.3, 9 ときてFedora Core, Fedora Core 2, Fedora Core 3と来たらしい。今はFedora 7。そして8がベータテスト中かな。

ここから下は Fedora Core 6 の記述。また、作業の参考には、Fedoraで自宅サーバー構築Fedora Core 6インストールを見ながらやっています。

インストールパッケージは必要最小限におさえ、あとで必要なものを個別にインストールしていく。

というインストール方針が非常にマッチしていると思われます。デスクトップクライアント用にインストールしようとする方にはなんの参考にもならないと思います。

インストール編

退役したPCを、社内ウェブサーバーに転用するためにインストールする記録。

バンバン新しいのが出てくるので、最新版にチャレンジしてもいいのですが、実質的に、新しい機能がなんか必要かというと、社内のウェブサーバーごときには不要なもので、以前試しにダウンロードしていたFedora Core 6のCD-Rを使ってインストールを行ないます。

ということで、まずはCDイメージを取ってきて、CDライティングソフトで焼き込む。

とりあえず、本家から取るのは厳しそうなので、テキトーなミラーサイトを選択して入手するんですが、

http://torrent.fedoraproject.org/ から、BitTorrentで Fedora-7-i386.torrent をダウンロードして、と思ったらDVD版しかなかったのでやめ(該当機にDVDドライブが装着されていないため) 。

CD-ROM版のあるFedora Core 6にします。Fedora Core 6はCD5枚。

テキトーに手持ちのCDライティングソフトで、ISOイメージを焼き込んでCD-Rにします。

早速インストール。

CD #1を入れてブート。

サーバー用途なので、

> linux text

として、テキスト版のインストーラーを使う。GUI版でやると、説明に画面写真がいるので(おい)。カーソルキーと[Tab]でカーソルの移動、[Space]で選択・解除、[Enter]で決定、というのが基本操作。

インストーラーでは、インストーラーの開始前にメディアをチェックしますか?と訊いてくれるので、不要なら Skip

せっかくだからチェックして頂くことにするなら OK

しかし、Linuxをインストールするたびにバージョンが変わってるのもどうかと思うよなあ…。まあいいや。

5枚のCD-Rのチェックが無事完了したら、ディスク1をセットし直してContinue

Welcome to Fedora Core! で OK ( [Enter] )

Language Selection サーバー自体は日本語化する気がないので、English

Keyboard Selection キーボード設定106日本語キーボードなので jp106 (Englishだと[:][*]とかのキー割り当てが英語キーボードと違うのがツライ)

Partitioning Type パーティーションがあるので警告される。専用にするので、 Remove all partitions on selected drives and create default layout にして OK

Warning 最終確認なので、よければ Yes (今までとYesとNoの位置が逆なので注意)

Review Partition Layout 見なくてもいいけど Yes

Device Start End Size Type Mount Point
VG VolGroup00     38016M VolGroup  
LV LogVol01     1024M swap  
LV LogVol00     26992M ext3 /
/dev/hda          
hda1 1 13 101M ext3 /boot
hda2 14 4865 28030M physical v  

40GBのハードディスクの例ですが、まー、見たってわからないのでそのままOK

Boot Loader Condiguration Use GRUB Boot Loader を選択して OK

Boot Loader Configuration 特に指定はないのでそのまま OK

Boot Loader Configuration あんまり厳密に運営したくないので、Boot Loader Password は空欄のまま OK

Boot Loader Configuration ブートオーダーといっても1個しかないのでそのまま OK

Boot Loader Configuration ブートローダーのインストール先を聞かれるがデフォルトのまま OK

Network Configuration for eth0 最初はDHCPでよく、IPv6は当分用がないので、

[*] Use dynamic IP Configuration (DHCP)
[*] Enable IPv4 support
[ ] Enable IPv6 support
[*] Activate on boot

OK

Hostname Configuration (*) manuallywww5(ウェブサーバーとして5代目) として OK

Time Zone Selection Asia / Tokyo を選んで OK

Root Password 忘れないパスワードを適当に設定して OK

ウェブサーバー用途ですが、最小構成にしたいので、

[ ] Office and Productivity
[ ] Software Development
[*] Web server

[*] Customize software selection

とする。2個目のSoftware Developmentはモジュールのコンパイルとかが発生するといるかもしれないので、動的なサーバーを検討している場合はチェックした方がいいかも。

OK

エンドユーザーからはプロバイダーとかと同じようにFTPで更新してもらうのがわかりやすいと思うので、

[*] FTP Server

あと、サーバーとして動作する上でいらなそうなオプションを外す。

[ ] Editors
[ ] GNOME Desktop Environment
[ ] Graphical Internet
[ ] Printing Support
[ ] Text-based Internet
[ ] X Window System

この時点でチェックされているのは

[*] Administration Tools
[*] FTP Server
[*] Web Server

のみ。

動的なサーバーを構築したり、Namazu入れたりするときは、

[*] Development Libraries
[*] Development Tools

を追加で選択しておいた方がいいのかもしれませんが、今回はチェックしません。

OK で 

Dependency Check

しばらくかかります。

Instllation to begin で OK

インストール準備完了で次へ 

この設定でCD #1、#2 が必要、とのこと。#3、#4、#5はプラスチックゴミか…。まあ、CD #1だけでここまで進めてから、必要な分だけ焼いてもいいかもですね。

Continue


 

ぼんやりまってるとCDの入れ替えを要求されるのでそれに応じていく。


 

終わると再起動。2枚目の所要時間はわずか。


Setup Agent というのが出てたが、メモを取ってたら消えた(笑)。

Fedora Core release 6 (Zod)
Kernel 2.6.18-1.2798.fc6 on an i686

www5 login:

とテキストベースで起動したのでOKかな。


rootでログイン。パスワードはさっきセットしたヤツ。


 

作業用ユーザーの作成

具体的には、FTPで作業をさせるためのアカウントを作成する。

useradd **** ←任意のアカウント

passwd **** ←任意のアカウントにパスワード設定
Changing password for user ****.
New UNIX password: ←パスワードを入力
BAD PASSWORD: it is based on a dictionary word 単純なので怒られていますが、無視。
Retype new UNIX password: ←もう一度入力
passwd: all authentication tokens updated successfully.

パッケージのインストール設定

ウェブサーバーなので自動更新したりするとやっかいなので、そういう設定はすっ飛ばし。(しない)

[root@fedora ~]# /etc/rc.d/init.d/yum-updatesd stop ← アップデート通知デーモン停止
yum-updates を停止中: [ OK ]

[root@fedora ~]# chkconfig yum-updatesd off ← アップデート通知デーモン自動起動設定解除

root宛のメールを転送

システムからroot宛に重要なメールが送られてくるので、root宛メールを普段使用しているメールアドレス宛に転送するようにする

[root@fedora ~]# sed -i '/^root:/d' /etc/aliases ← 旧root宛メール転送設定削除
[root@fedora ~]# echo "root: ****@****.***" >> /etc/aliases  ← root宛メールを普段使用しているメールアドレス(例:****@****.***)宛に転送する設定を追加 [root@fedora ~]# newaliases ← 転送設定反映
/etc/aliases: 77 aliases, longest 17 bytes, 786 bytes total
[root@fedora ~]# echo test|mail root ← テストメールをroot宛に送信してみる
テストメールが転送先メールアドレス宛に届いていることを確認する

ファイヤーウォール停止

サーバーなので。

[root@fedora ~]# /etc/rc.d/init.d/iptables stop ← ファイアウォール停止
Flushing firewall rules : [ OK ]
Setting chains to policy ACCEPT: filter [ OK ]
Unloading iptables modules: Removing netfilter NETLINK layer. [OK]
[root@fedora ~]# chkconfig iptables off ← ファイアウォール自動起動解除
[root@fedora ~]# chkconfig --list iptables ← ファイアウォール自動起動解除確認
iptables 0:off 1:off 2:off 3:off 4:off 5:off 6:off ← ランレベル全てがoffになっていることを確認

 

ああ SELinux

SELinuxの無効化。SELinuxが有効になっていると、さまざまな局面でハマれます…。きちんと勉強してSELinuxに対応するか、横着してSELinux自体を無効にするか、それはあなた次第。

[root@fedora ~]# setenforce 0 ← SELinux無効化
audit(1188998548.581.4): enforcing=0 old_enforcing=1 auid=4294967295
[root@fedora ~]# getenforce ← SELinux状態確認
Permissive ← SELinux無効(有効だとEnforcing)
[root@fedora ~]# vi /etc/sysconfig/selinux ← SELinux設定ファイル編集

SELINUX=enforcing を SELINUX=disabled に変更 ← システム起動時にSELinuxを無効化

APM、ACPI機能の無効化

以下に示す理由により、APMまたはACPI機能による電源管理機能を無効化する。

・24時間稼動させるサーバーなので、省電力機能は不要
・誤操作等により電源ボタンを押してしまった場合にサーバーがシャットダウンしないようにする

[root@fedora ~]# /etc/rc.d/init.d/apmd stop ← apmd停止
[root@fedora ~]# chkconfig apmd off ← apmd自動起動設定解除
[root@fedora ~]# /etc/rc.d/init.d/acpid stop ← acpid停止
Stopping acpi daemon: [ OK ]
[root@fedora ~]# chkconfig acpid off ← acpid自動起動設定解除

※マシンによりAPM、ACPIどちらかしか有効になっていないが、機械的に両方とも停止する操作をすればオッケー。

NTPサーバーの設定

適当なWindowsサーバーあたりをターゲットにして、それと時刻を同期するようにすると、このサーバーの時刻を気にしなくてよくなるはず。

[root@fedora ~]# yum -y install ntp ← NTPサーバーインストール

■NTPサーバー設定

[root@fedora ~]# mv /etc/ntp.conf /etc/ntp.conf.org ← オリジナルのntp設定ファイルをリネーム
[root@fedora ~]# vi /etc/ntp.conf ← ntp設定ファイル新規作成
driftfile /var/lib/ntp/drift
server プロバイダのNTPサーバー名 ← 適当なNTPサーバー※1

(1)NTPサーバー起動 NTPサーバー起動時に大幅に時刻がずれているとNTPサーバーが起動できないので、いったん、手動で時刻を合わせる

[root@fedora ~]# ntpdate ntp.dnsbalance.ring.gr.jp ← 手動で時刻を合わせる
12 Jun 01:23:24 ntpdate[11476]: adjust time server 133.186.4.15 offset 0.002576 sec
[root@fedora ~]# /etc/rc.d/init.d/ntpd start ← NTPサーバー起動
ntpd を起動中: [ OK ]
[root@fedora ~]# chkconfig ntpd on ← NTPサーバー自動起動設定
[root@fedora ~]# chkconfig --list ntpd ← NTPサーバー自動起動設定確認
ntpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off ← ランレベル2〜5のonを確認

Webサーバー構築(Apache)

基本的にはここ参照

Webサーバー構築(Apache)

Apache更新

Apacheは最初のオプションですでにインストールされているのですが、ウェブサーバーの重要な部分ですので更新してもいいです。

[root@fedora ~]# yum -y install httpd ← Apacheインストール

Apache設定

(1)Apache設定

[root@fedora ~]# vi /etc/httpd/conf/httpd.conf ← Apache設定ファイル編集
ServerTokens OS

ServerTokens Prod ← エラーページ等でOS名を表示しないようにする

ServerAdmin root@localhost

ServerAdmin webmaster@fedorasrv.com ← エラーページ等に表示される管理者メールアドレスを指定

#ServerName www.example.com:80

ServerName fedorasrv.com:80 ← サーバー名を指定

<Directory "/var/www/html">

#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs-2.0/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks
   ↓
Options Includes ExecCGI FollowSymLinks ← CGI,SSI許可、ファイル一覧表示禁止

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride None
   ↓
AllowOverride All ← .htaccessの許可

#
# The following directives define some format nicknames for use with
# a CustomLog directive (see below).
#
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined

LogFormat "%h %l %u %t \"%!414r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
  ← 長すぎるURI(414エラー)はログに記録しない

#
# For a single logfile with access, agent, and referer information
# (Combined Logfile Format), use the following directive:
#
SetEnvIf Request_URI "default\.ida" no_log ← 追加(wormからのアクセスをログに記録しない)
SetEnvIf Request_URI "cmd\.exe" no_log ← 〃
SetEnvIf Request_URI "root\.exe" no_log ← 〃
SetEnvIf Request_URI "Admin\.dll" no_log ← 〃
SetEnvIf Request_URI "NULL\.IDA" no_log ← 〃
SetEnvIf Remote_Addr 192.168.1 no_log ← 追加(内部からのアクセスをログに記録しない)
CustomLog logs/access_log combined env=!no_log ← 上記以外のアクセスをログに記録する

ServerSignature On

ServerSignature Off ← エラーページ等でApacheのバージョンを表示しないようにする

AddDefaultCharset UTF-8

#AddDefaultCharset UTF-8 ← コメントアウト

#AddHandler cgi-script .cgi

AddHandler cgi-script .cgi .pl ← #をとる(CGIスクリプトに.plを追加
=不要)

[root@fedora ~]# rm -f /etc/httpd/conf.d/welcome.conf ← テストページ削除

[root@fedora ~]# rm -f /var/www/error/noindex.html ← テストページ削除



(2)Perlコマンドへ/usr/local/bin/perlでもアクセスできるようにする。

[root@fedora ~]# ln -s /usr/bin/perl /usr/local/bin/perl ← /usr/local/bin/perlから/usr/bin/perlへリンクをはる

[root@fedora ~]# whereis perl ← Perlのパスを確認
perl: /usr/bin/perl /usr/local/bin/perl /usr/share/man/man1/perl.1.gz   ← Perlのパスに/usr/local/bin/perlが表示されることを確認


(3)ドキュメントルート所有者変更
ここでは、例としてドキュメントルート所有者をfedoraに変更する。
[root@fedora ~]# chown fedora. /var/www/html/ ← ドキュメントルート所有者変更

[root@fedora ~]# ll /var/www/ ← ドキュメントルート所有者変更確認
合計 48
drwxr-xr-x 2 root root 4096 10月 5 11:45 cgi-bin
drwxr-xr-x 3 root root 4096 10月 9 00:19 error
drwxr-xr-x 5 fedora fedora 4096 9月 27 17:43 html
drwxr-xr-x 3 root root 4096 9月 27 09:29 icons

manual
usage

が他にあるが無視。

■Apache起動


(1)Apache起動
[root@fedora ~]# /etc/rc.d/init.d/httpd start ← Apache起動
Starting httpd: [ OK ]

[root@fedora ~]# chkconfig httpd on ← Apache自動起動設定

[root@fedora ~]# chkconfig --list httpd ← Apache自動起動設定確認
httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off ← ランレベル2〜5のonを確認


 

(3)外部からのWebサーバーアクセス確認
外部からWebサーバーにアクセスできるか確認する。

WindowsパソコンなどのブラウザでIPアドレスへアクセス

http://192.168.0.11

など。

Fedora Core Test Page

っていうのが出ればまずオッケー。

FTPサーバーの構築

あとは、更新用のFTPサーバーを構築すればオッケー。

FTPサーバー構築(vsftpd)

■vsftpdインストール
[root@fedora ~]# yum -y install vsftpd ← vsftpdインストール



■vsftpd設定
(1)vsftpd設定
[root@fedora ~]# vi /etc/vsftpd/vsftpd.conf ← vsftpd設定ファイル編集
# Allow anonymous FTP? (Beware - allowed by default if you comment this out).
anonymous_enable=NO ← anonymousユーザ(匿名ユーザ)のログイン禁止

# Activate logging of uploads/downloads.
xferlog_enable=NO ← /var/log/vsftpd.logに接続・転送を記録(1/3)しない

# You may override where the log file goes if you like. The default is shown
# below.
xferlog_file=/var/log/vsftpd.log ← /var/log/vsftpd.logに接続・転送を記録(2/3)

# If you want, you can have your log file in standard ftpd xferlog format
xferlog_std_format=YES ← /var/log/vsftpd.logに接続・転送を記録(3/3)

# By default the server will pretend to allow ASCII mode but in fact ignore
# the request. Turn on the below options to have the server actually do ASCII
# mangling on files when in ASCII mode.
# Beware that on some FTP servers, ASCII support allows a denial of service
# attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd
# predicted this attack and has always been safe, reporting the size of the
# raw file.
# ASCII mangling is a horrible feature of the protocol.
ascii_upload_enable=YES ← アスキーモードでのアップロードを許可 #をとる
ascii_download_enable=YES ← アスキーモードでのダウンロードを許可 #をとる

# You may fully customise the login banner string:
ftpd_banner=Welcome to blah FTP service. ← FTPログイン時にソフト名とバージョンが表示されないようにする

# You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot().
chroot_local_user=YES ← デフォルトでホームディレクトリより上層へのアクセスを禁止する
chroot_list_enable=YES ← ホームディレクトリより上層へのアクセスを許可するユーザのリストの有効化
# (default follows)
chroot_list_file=/etc/vsftpd/chroot_list ← ホームディレクトリより上層へのアクセスを許可するユーザのリスト

# You may activate the "-R" option to the builtin ls. This is disabled by
# default to avoid remote users being able to cause excessive I/O on large
# sites. However, some broken FTP clients such as "ncftp" and "mirror" assume
# the presence of the "-R" option, so there is a strong case for enabling it.
ls_recurse_enable=YES ← ディレクトリごと削除できるようにする #をとる

以下を最下行へ追加
local_root=public_html ← ログイン時のディレクトリを~/public_htmlにする
use_localtime=YES ← タイムスタンプ時間を日本時間にする
pasv_addr_resolve=YES ← PASVモード接続先IPアドレスをホスト名から取得する
pasv_address=fedorasrv.dip.jp ← PASVモード接続先IPアドレスが牽けるホスト名※
pasv_min_port=60000 ← PASVモード接続時の最小ポート番号
pasv_max_port=60030 ← PASVモード接続時の最大ポート番号
ssl_enable=YES ← SSLの有効化
rsa_cert_file=/etc/pki/tls/certs/vsftpd.pem ← サーバー証明書を指定
force_local_logins_ssl=NO ← ログイン時にSSL接続を強制しない※暗号化しない接続もできるようにする場合のみ
force_local_data_ssl=NO ← データ転送時にSSL接続を強制しない※暗号化しない接続もできるようにする場合のみ


(2)ホームディレクトリより上層へのアクセスを許可するユーザの登録
[root@fedora ~]# echo fedora >> /etc/vsftpd/chroot_list
  ← 例としてユーザfedoraによるホームディレクトリより上層へのアクセスを許可する場合



※管理者や、自身のホームディレクトリ以外へアクセスできるようにしておく必要があるユーザのみ登録しておく

1ユーザーだけしか使わないので制御しない


■vsftpd起動
(1)vsftpd起動
[root@fedora ~]# /etc/rc.d/init.d/vsftpd start ← vsftpd起動
Starting vsftpd for vsftpd: [ OK ]

[root@fedora ~]# chkconfig vsftpd on ← vsftpd自動起動設定

[root@fedora ~]# chkconfig --list vsftpd ← vsftpd自動起動設定確認
vsftpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off ← ランレベル2〜5のon確認



FTPで接続して、/var/www/html

を更新する。

 

[システム管理者のひとり言]

鳥繁.COM
このページは鳥繁.COMアクセスアップキャンペーンの一環で作成されています。
Copyrights © 2002-2013 Torihan.COM. All rights reserved.