http://something.com/somethingまたはhttp://{server-ip-address-here}/something のようなドメイン名で apache に仮想ホストを設定できるかどうかに興味があり ます。
私はUbuntuサーバーでApache 2.2.20を使用しています。これは私のホームサーバーであり、ここでいくつかのものをテストしています。ここにはDNSサーバーがありません。私が持っているのは、パブリックIPアドレスと、オープンDNSサービスからそれに接続されたドメイン名だけです.
それで、私は何をしましたか:
- /etc/apache2/sites-availableに新しいファイル「demo」を作成しました
私はこれをそこに置きました(実際には、デフォルトファイルから変更してコピーされます):
<VirtualHost *:80> ServerAdmin webmaster@localhost ServerName {mydomain-here}/demo/ DocumentRoot /vhosts/demo <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /vhosts/demo/> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined Alias /doc/ "/usr/share/doc/" <Directory "/usr/share/doc/"> Options Indexes MultiViews FollowSymLinks AllowOverride None Order deny,allow Deny from all Allow from 127.0.0.0/255.0.0.0 ::1/128 </Directory> </VirtualHost>
/etc/apache2/sites-enabled/ に /etc/apache2/sites-available/demo を指すシンボリックリンクを作成しました
/vhosts/demo/index.htmlファイルを作成しました。
そして今、私が得たのは、{my-domain} に行くと、作成した vhost に行くということですが、問題は、{my-domain}/demo だけでなく、どのような場合でもサーバーが私をそこに向けていることです。
結論として、異なる仮想ホストを作成し、それらを同じベース URL を持つ異なる URL (www.mydomain.com/vhost1、www.mydomain.com/vhost2 など) にアタッチできるようにしたいと考えています。
出来ますか?ありがとう :)