まだだ、まだ終わらんよ
まだできません!/etc/apache2/sites-available/default は以下のようになっている。
<VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> 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 </VirtualHost>
このdefaultだけをa2ensiteした状態で、
- /var/www/foo.html
- /var/www/bar.html
- /var/www/dir1/hoge.html
- /var/www/dir1/fuga.html
作って、それぞれ
- http://localhost/foo.html
- http://localhost/bar.html
- http://localhost/dir1/hoge.html
- http://localhost/dir1/fuga.html
でアクセスしたらどれもforbiddenになった。http://localhost/index.htmlだけはアクセスできた。dir1内のファイルはともかく、foo.htmlとbar.htmlにはアクセスできるつもりでいたのだが。
Apacheの実行ユーザから見えるようにアクセス権を変更する
先日のエントリで、public_htmlがApacheの実行ユーザから見えるかどうかをチェックするようコメントいただいたので、その点をチェック。まず、Apacheの実行ユーザは /etc/apache2/apache2.conf
# These need to be set in /etc/apache2/envvars User ${APACHE_RUN_USER} Group ${APACHE_RUN_GROUP}
って書いてあった。コメントにある通り、APACHE_RUN_USERは /etc/apache2/envvars に定義してあった。見たこと無いユーザ名だった。ともかく、このユーザから見えればOKらしいのでchmodしてみた
sudo chmod +r /www/var/foo.html
するとちゃんと見えた。よしこれが原因やな!多分!