前提
xamppにて4つのWebページをLAN内で公開することに成功しました。
(http://IPアドレス/index1.phpでLAN内の他のPCからアクセス成功)
しかし、ドメイン名を任意の文字列に設定することができません。
それぞれのファイルの場所はこんな感じです。
htdocs/sample1.jp/index1.php
htdocs/sample2.jp/index2.php
htdocs/sample3.jp/index3.php
htdocs/sample4.jp/index4.php
これまでに変更した設定の内容
- xampp/apache/conf/httpd.conf
Listen 80 //60行目
APACHEの通信する窓口の設定
ServerName sample:80 //228行目
(ドメイン名にしたい文字列):(ポート番号)で入力しました
<IfModule dir_module> //285行目 DirectoryIndex index1.php index2.php index3.php index4.php index.html </IfModule>
ファイルの探す順番です。
- xampp/apache/conf/extra/httpd-vhosts.conf
NameVirtualHost *:80 //20行目
アクセス先のIPアドレスに対して、名前ベースの仮想アドレスを設定していることを表しているそうです。
//末尾に追加 <VirtualHost *:80> DocumentRoot C:/xampp/htdocs ServerName sample </VirtualHost> <Directory "C:/xampp/htdocs/sample1.jp"> order deny,allow allow from ALL </Directory> <Directory "C:/xampp/htdocs/sample2jp"> order deny,allow allow from ALL </Directory> <Directory "C:/xampp/htdocs/sample3.jp"> order deny,allow allow from ALL </Directory> <Directory "C:/xampp/htdocs/sample4.jp"> order deny,allow allow from ALL </Directory>
サーバとディレクトリの設定
- C:/Windows/drivers/etc/hosts
192.168.11.34 sample
(IPアドレス) ドメイン名
試したこと
・ドメイン名ではなくIPアドレスでのアクセスに成功しました。
・Wifiの設定をパブリックからプライベートにしました。
補足情報(FW/ツールのバージョンなど)
XAMPP7.4.26
参考
https://gist.github.com/Buravo46/d3fbe74259cdfc73001c
【XAMPP】バーチャルホストを設定し、同じLAN内の他PCからアクセスする方法.
https://fukuro-press.com/xampp-launch-multiple-sites/
XAMPPで複数サイトをローカル環境に立ち上げる手順まとめ
