1
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

MacのMAMPでバーチャルホストをカスタマイズ

Posted at

MAMPでバーチャルホストをカスタマイズする方法について書きます。

前提条件

  • MacにMAMPがインストールされていること

設定

httpd.confファイルで以下の箇所の#コメントアウトを外します。

/Applications/MAMP/conf/apache/httpd.conf
# Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf

httpd-vhosts.confファイルの末尾に以下のような記述を追記します。
ListenVirtualHostに使われていない適当なポート番号を、
DocumentRootDirectoryには使いたいディレクトリパスを入れます。

/Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
Listen 8001
<VirtualHost *:8001>
    DocumentRoot "/Users/userId/test"
    <Directory "/Users/userId/test">
        AllowOverride All
    </Directory>
</VirtualHost>

同じようにポート番号を8002、8003と使われていない番号で追記していくと、
複数のバーチャルホストを設定することが出来ます。

アクセス

safariで設定したポート番号のページを開く

open -a '/Applications/safari.app' http://localhost:8001

参考文献

この記事は以下の情報を参考にして執筆しました。

1
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?