apache2設定 その2
apache2.confはいじらず、設定を個別ファイルで作成します。
優先順位は個別で作ったファイルのほうが高いハズです。
あと、例によってこちらを参考にさせていただきました。
共通のディレクトリ設定
$ sudo vi /etc/apache2/conf.d/directory_settings
<directory />
Options All
Options -Indexes
AllowOverride All
Order allow,deny
allow from all
</directory>
セキュリティ絡みの設定
$ sudo vi /etc/apache2/conf.d/security ServerTokens ProductOnly ServerSignature Off
メインサイトの設定
wwwユーザーの設定
/home/wwwにホームをもつ、wwwユーザ作っておきます。
$ cd /home/ $ sudo mkdir www $ sudo mkdir www/www $ sudo mkdir www/log $ sudo chown -R www-data:www-data www
vipwでユーザーwww-dataのホームを変更。
$ sudo vipw www-data:x:33:33:www-data:/home/www:/bin/sh # /var/www → /home/www
設定
$ cd /etc/apache2/sites-available/
$ sudo cp default my_site
$ sudo vi my_site
NameVirtualHost *:8080
<VirtualHost *:8080>
ServerAdmin mail@localhost # 管理者のメールアドレス
DocumentRoot /home/www/www
<Directory />
Options FollowSymLinks ExecCGI
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiVieWs ExecCGI
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 /home/www/log/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /home/www/log/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
</Directory>
</VirtualHost>
確認
/home/www/www/ に、適当なindex.htmlを作成。
$ sudo /etc/init.d/apache2 restart $ wget -S http://(ホストのIPかアドレス)
で、確認を行う。