ブラウザから、http://hoge.local にアクセスしたときに、
Mac上の/Workspaces/Web/sites/hoge.com/deploy/htdocs/に置いた
index.html が表示されるようにしたい。
1-1.
xamppをダウンロード、インストール
1-2.
Macのアプリケーションフォルダ内の
XAMPP/xamppfiles/etc の、
httpd-vhosts.conf を開く。
ファイル後半にある、
# Virtual hosts
#Include /Applications/XAMPP/etc/extra/httpd-vhosts.conf
の部分を、
# Virtual hosts
Include /Applications/XAMPP/etc/extra/httpd-vhosts.conf
とコメントアウトを解除する。
これで、extra/httpd-vhosts.conf で設定した内容が読み込まれるようになる。
1-3.
たった今読み込む設定をした、
/Applications/XAMPP/xamppfiles/etc/extra 内の、
httpd-vhosts.conf を開く
1-4.
一番下に自分の作りたいローカルサーバの設定を追加する。
例:
<VirtualHost *:80> ServerAdmin admin@hoge.com DocumentRoot "/Workspaces/Web/sites/hoge.com/deploy/htdocs" ServerName hoge.local ErrorLog "/Workspaces/Web/sites/hoge.com/deploy/logs/error_log" CustomLog "/Workspaces/Web/sites/hoge.com/deploy/logs/access_log" common </VirtualHost>
<Directory "C:/Workspace/web/localhost/htdocs/">
AllowOverride All
Require all granted
</Directory>
ServerAdmin : 管理者のメアド(なんでもいい)
DocumentRoot "サイトのルートのディレクトリ"
ServerName サイトのドメイン
ErrorLog "エラーログを保存する場所/ファイルの名前(ファイルは自動で作られる)"
CustomLog "アクセスログを保存する場所/ファイルの名前(ファイルは自動で作られる)" common
2-1.
続いて
/private/etc に移動して、
hosts を開く
2-2.
127.0.0.1 localhost
127.0.0.1 hoge.local
みたいにローカルのアドレスを追加して保存。
これで、ブラウザで、http://hoge.localにアクセスすると、サイトのルートフォルダ(この例では、/Workspaces/Web/sites/hoge.com/deploy/htdocs)に置いたindex.htmlファイルが表示されるはず。
当然、
/Workspaces/Web/sites/hoge.com/deploy/htdocs/img/logo.jpg
には、
http://hoge.local/img/logo.jpg
からアクセスできる。
No comments:
Post a Comment