Ubuntuでドキュメントルートのファイル一覧を非表示にする
ドキュメントルートにindex.htmlがないとファイルの一覧が表示されてしまうので、その一覧を消したい。
apacheの設定を調べるとCentOSとかのが出てきて案外設定に手間取ったので備忘録。
課題
webサーバにアクセスした時にファイルの一覧を表示させない。
解決
「/etc/apache2/sites-available/default」に入っている設定をいじる。
10行目の「Options Inexes FollowSystemLinks MultiViews」設定をコメントアウト。
11行目に「Options All -Indexes」設定を追加。
「sudo /etc/init.d/apache2 restart」でApacheの再起動
/etc/apache2/sites-available/default
ServerAdmin webmaster@localhost DocumentRoot /var/www Options FollowSymLinks AllowOverride None # Options Indexes FollowSymLinks MultiViews Options All -Indexes AllowOverride None Order allow,deny allow from all ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all ErrorLog ${APACHE_LOG_DIR}/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined Alias /doc/ "/usr/share/doc/" <Directory "/usr/share/doc/"> Options Indexes MultiViews FollowSymLinks AllowOverride None Order deny,allow Deny from all Allow from 127.0.0.0/255.0.0.0 ::1/128