vagrant仮装環境で、apacheの設定をしていたのですが、参考にしていたファイルのapacheの設定でわからないことが出てきたので、相談させてください。
httpd.confないから
IncludeOptional conf.d/*.conf Include conf.d/vhosts.conf
でvhosts.confと呼ばれるファイルを呼び出しています。
で、そこにServerNameが記されているのですが、このserverNameが develhost と記載されています。
このdevelhostによって自動的にプログラムの入ったディレクトリ名とサーバー名を結びつけているとは思うのですが、どこでそのような設定をしているのかわからず、develhostで調べても情報が全くなかったので、教えていただけないでしょうか。
想定している挙動としては、workspace以下に複数のプログラムを入れて、それぞれのトップディレクトリ名とvagrantで設定しているIPアドレスをホスト側で結びつけると自動的にpublic_html下のファイルへブラウザからアクセスできるようになることです。
以下vhosts.confになります。
<VirtualHost *:80> ServerAdmin warden VirtualDocumentRoot /workspace/%0/public_html ServerName develhost EnableSendfile Off <Directory /workspace/*/public_html> php_value display_errors On Order deny,allow Allow from all AllowOverride All Require all granted </Directory> SetEnv ENV_SERVER_TYPE devel </VirtualHost> <VirtualHost *:443> SSLEngine on SSLProtocol all -SSLv2 SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW SSLCertificateFile /etc/pki/tls/certs/localhost.crt SSLCertificateKeyFile /etc/pki/tls/private/localhost.key <Files ~ ".(cgi|shtml|phtml|php3?)$"> SSLOptions +StdEnvVars </Files> <Directory "/var/www/cgi-bin"> SSLOptions +StdEnvVars </Directory> SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0 VirtualDocumentRoot /workspace/%0/public_html ServerName develhost <Directory /workspace/*/public_html> php_value display_errors On Order deny,allow Allow from all AllowOverride All Require all granted </Directory> SetEnv ENV_SERVER_TYPE devel </VirtualHost>
apacheについて詳しくわかっていない状況ですが、よろしくお願い致します。
足りない情報等がありましたら言ってください。
==========追加==============
以下サイトでvirtual document rootのやり方が乗っていました。
ただ、これできになるのは、ServerName を xxxxx.xxxx.xxxだけにしてしまっていますが、
もともと ServerName yyyyy.xxxx.xxx で設定されていたサイトにもアクセスができるということですよね。
これが正しいとしたら、 VirtualDocumentRootを設定する際の servername は なんでも良く、他に変更すべきことはないということでしょうか。
また、どうしてこれで yyyyy.xxxx.xxx などにもアクセスできるようになるのでしょうか。
(どこかでserverNameが設定されているとか?)
以下参考サイト
https://www.softel.co.jp/blogs/tech/archives/2189
DocumentRootを使うとこうなるところが、
<VirtualHost *:80> ServerName xxxxx.xxxx.xxx DocumentRoot "/home/apache/xxxxx.xxxx.xxx/htdocs" </VirtualHost> <VirtualHost *:80> ServerName yyyyy.xxxx.xxx DocumentRoot "/home/apache/yyyyy.xxxx.xxx/htdocs" </VirtualHost> <VirtualHost *:80> ServerName zzzzz.xxxx.xxx DocumentRoot "/home/apache/zzzzz.xxxx.xxx/htdocs" </VirtualHost>
VirtualDocumentRootでまとめてこう書ける。
<VirtualHost *:80> ServerName xxxx.xxx ServerAlias *.xxxx.xxx VirtualDocumentRoot "/home/apache/%0/htdocs" </VirtualHost>