
ローカルの Raspberry Pi ボックスに DnsMasq を設定して、ローカル デバイスをネットワーク上の単純なパス (例: laptop.local) にマッピングしています。ローカル Web 開発にはラップトップで WAMP を使用しており、この設定は非常にうまく機能しています。ただし、URL を整理し、教育目的のために、ラップトップのサブディレクトリ (現在は "laptop.local/website") をサブドメイン (例: "website.laptop.local") にマッピングするにはどうすればよいでしょうか。
答え1
DNSが正しく設定されていると仮定すると、ラップトップ.ローカル適切な Apache 仮想ホストを利用するには、WAMP 構成を更新するだけで済む可能性があります。
WAMPの設定
サブドメインを格納するディレクトリを作成します。これは、WAMP インストールがアクセスできる場所 (ルート
www
フォルダの下または横など) で実行してください。オープンApacheconfファイル(WAMP インストールの Apache
conf
ディレクトリ下、または適切なメニュー インターフェイス経由 (例Apache → httpd.conf
))。この行のコメントを解除します(#を削除します)。
# Include conf/extra/httpd-vhosts.conf
それは
Include conf/extra/httpd-vhosts.conf
Apache
conf\extra
フォルダを開いて を見つけますhttpd-vhosts.conf
。ファイルの末尾に次のような内容を追加します。# Virtual host entry for website.laptop.local # Anything with a # is a comment <VirtualHost *:80> ServerName website.laptop.local #ServerAlias *.website.laptop.local # DocumentRoot should correspond to wherever the HTML files # for your website.laptop.local site are located. This is an example! DocumentRoot "C:/wamp/www/subdomains/my-website" ErrorLog "logs/my-website-error.log" CustomLog "logs/my-website-access.log" common # If you have any problems with "Forbidden", try uncommenting # the following (assumes Apache 2.4.x). #<Directory "C:/wamp/www/subdomains/my-website"> #AllowOverride None #Options None #Require all granted #</Directory> </VirtualHost>
必ず有効にしてくださいエイリアスモジュールそしてvhost_alias_moduleApache モジュール。通常、これは適切なメニュー インターフェイスを通じて (再び) 実行されますが、適切なモジュール行のコメントを解除するだけで
Apache → Apache modules
実行できる可能性もあります。httpd.conf
WAMP サーバーを再起動します。
エラーがないと仮定すると、ウェブサイト.ラップトップ.ローカル利用可能になるはずです。