CentOSをつかって自宅サーバを構築−Webサーバ・Mailサーバ・Sambaサーバ etc


Apacheのインストール

 # yum -y install httpd
 
 # yum -y install php php-mbstring php-pear

設定

httpd.confの編集

 # vi /etc/httpd/conf/httpd.conf
 
 【44行目】
 ServerTokens OS
  ↓
 ServerTokens Prod ←OSの表示がされないようにする
 
 【251行目】
 ServerAdmin root@localhost
  ↓
 ServerAdmin (管理者)@nantonaku.myhome.cx ←管理者のメールアドレスを指定
 
 【265行目】
 #ServerName www.example.com:80
  ↓
 ServerName nantonaku.homelinux.com:80 ←サーバー名を指定
 
 【320行目】
 Options Indexes FollowSymLinks
  ↓
 Options FollowSymLinks Includes ExecCGI ←SSI,CGIの実行を許可する
 
 【327行目】
 AllowOverride None
  ↓
 AllowOverride All ←.htaccessを許可する
 
 【391行目】
 DirectoryIndex index.html index.html.var
  ↓
 DirectoryIndex index.html index.html.var index.cgi index.php ←ディレクトリ名だけでアクセス可能にする
 
 【524行目】
 ServerSignature On
  ↓
 ServerSignature Off ←Apacheのバージョンを表示しない
 
 【542行目】
 Options Indexes MultiViews
  ↓
 Options MultiViews ←ファイル一覧を表示しないようにする
 
 【747行目】
 AddDefaultCharset UTF-8
  ↓
 #AddDefaultCharset UTF-8 ←コメントアウト
 
 【778行目】
 #AddHandler cgi-script .cgi
  ↓
 AddHandler cgi-script .cgi .pl ←".pl"を追加

ドキュメントルートの所有権変更

 # chown apache:apache /var/www/html

不要なページの削除

 # rm -f /etc/httpd/conf.d/welcome.conf
 ↑ウェルカムページ削除
 
 # rm -f /var/www/error/noindex.html
 ↑デフォルトエラーページ削除

Perlのシンボリックリンク作成

 # ln -s /usr/bin/perl /usr/local/bin/perl
 
 # whereis perl
 perl: /usr/bin/perl /usr/local/bin/perl /usr/share/man/man1/perl.1.gz
 ↑Perlのパスに/usr/local/bin/perlが表示されることを確認

Apacheの起動

 # /etc/rc.d/init.d/httpd start
自動起動の設定を確認
 # chkconfig --list httpd
 httpd           0:off   1:off   2:on    3:on    4:on    5:on    6:off
2〜5が"on"になっていない場合
 # chkconfig httpd on

Wiki内検索

フリーエリア

管理人/副管理人のみ編集できます