$ sudo vi /etc/apache2/httpd.conf
バーチャルホストの設定を読み込むようにする。
# Virtual hosts - #Include /private/etc/apache2/extra/httpd-vhosts.conf + Include /private/etc/apache2/extra/httpd-vhosts.conf
次にバーチャルホストの設定を行う。
$ sudo vi /etc/apache2/extra/httpd-vhosts.conf下記の設定を追加する。
DocumentRootやServerNameは自由に設定してください。
<VirtualHost *:80>
DocumentRoot "/Users/username/sandbox"
ServerName sandbox.localhost
ErrorLog "/private/var/log/apache2/sandbox.localhost-error_log"
CustomLog "/private/var/log/apache2/sandbox.localhost-access_log" common
DirectoryIndex index.php index.html
<Directory "/Users/username/sandbox">
Options Includes ExecCGI FollowSymLinks
AllowOverride All
Order deny,allow
Allow from All
</Directory>
</VirtualHost>
ドメイン名を/etc/hostsに追加する。
$ sudo vi /etc/hosts"127.0.0.1 sandbox.localhost"を追記する。
## # Host Database # # localhost is used to configure the loopback interface # when the system is booting. Do not change this entry. ## 127.0.0.1 localhost 255.255.255.255 broadcasthost ::1 localhost fe80::1%lo0 localhost 127.0.0.1 sandbox.localhost
フォルダを作成して、パーミッションを変更する。
$ chmod +x ~/sandbox
Apacheを再起動する。
$sudo apachectl restartアクセスに失敗する場合、error_logを見ると原因が分かる。
" (13)Permission denied: access to * denied"が出る場合は作成したフォルダの大本のパーミッションが原因だったりするので、大本の方にも"chmod +x"をすれば解決する。
また、"httpd-vhosts.conf"に"~/"は指定出来ないので、ちゃんと"/Users/username/"を指定する必要がある。
0 件のコメント :
コメントを投稿