トップ 差分 一覧 ping ソース 検索 ヘルプ PDF RSS ログイン

Linux ユーザホームページ作成



目次



記事一覧

キーワード

Linux ユーザホームページ作成


ユーザを作成し、公開ディレクトリを作成
  • [username]にユーザ名を指定

useradd [username]
passwd [password]

chmod -R 711 /home/[username]
cd /home/[username]
mkdir public_html
vi index.html
chmod 644 index.html
 
apache httpdの設定を変更

http://httpd.apache.org/docs/2.2/ja/mod/mod_userdir.html

<IfModule mod_userdir.c>
   UserDir disable
   UserDir enabled [username] [username2] ... 
      
   UserDir public_html  <-- コメント解除
</IfModule>

↓コメント解除

<Directory /home/*/public_html>
    AllowOverride FileInfo AuthConfig Limit
    Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
    Options +ExecCGI                    <-- CGI使用時追加
    AddHandler cgi-script .cgi .pl      <-- CGI使用時追加
    <Limit GET POST OPTIONS>        Order allow,deny
        Allow from all
    </Limit>
    <LimitExcept GET POST OPTIONS>
        Order deny,allow
        Deny from all
    </LimitExcept>
</Directory>

Basic認証

必要があればBasic認証を行う

  • apache httpdの設定に追記
<Directory "/home/[username]/public_html">
    AuthType Basic
    AuthName "Restricted Files"
    AuthUserFile /home/[username]/shadow
    Require valid-user
    Options Indexes Multiviews
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>
  1. /etc/shadow ファイルを、/home/[username]/shadow にコピーしてくる。
  2. 許可するユーザの行を残し、他を削除し保存する

アクセス

http://[ホスト名]/~[username]

にてアクセスする。



YAGI Hiroto (piroto@a-net.email.ne.jp)
twitter http://twitter.com/pppiroto

Copyright© 矢木 浩人 All Rights Reserved.