4

Apacheは正しく機能していますが、仮想ホストは期待どおりに機能しています。私のオペレーティングシステムはWindows7です。

しかし、私は答えを見つけようとしている1つの問題を抱えており、Googleはあまり成果を上げていませんでした-とにかくWindowsの場合、Linuxの場合のみです(この場合は実際には当てはまりません)。

サーバーを常に再起動せずに新しい仮想ホストを追加するにはどうすればよいですか?

(Apacheバージョン2.2は私が現在実行しているものです)

次のように、ホストファイルとvhosts内のファイルに新しいホストを追加します。

<VirtualHost *:80>
ServerName  host1.tld
ServerAlias www.host1.tld
DocumentRoot /www/vhosts/host1.tld
ErrorLog /www/Apache22/logs/error.log

<Directory "/www/vhosts/host1.tld">
    Options All
    AllowOverride All
    order allow,deny
    allow from all
</Directory>

<VirtualHost *:80>
ServerName  mywebsite.com
ServerAlias www.mywebsite.com
DocumentRoot /www/vhosts/mywebsite.com
ErrorLog /www/Apache22/logs/error.log

<Directory "/www/vhosts/mywebsite.com">
    Options All
    AllowOverride All
    order allow,deny
    allow from all
</Directory>

誰かが同様の解決策をとっていますか?もしそうなら、あなたのアドバイスは何ですか?

4

2 に答える 2

3

VirtualDocumentRootを使用して、単一のブロックですべての仮想ホストを構成できる場合があります

<VirtualHost *:80>
UseCanonicalName Off
VirtualDocumentRoot /www/vhosts/%0
ErrorLog /www/Apache22/logs/error.log

<Directory "/www/vhosts">
    Options All
    AllowOverride All
    order allow,deny
    allow from all
</Directory>
于 2011-01-17T20:24:39.967 に答える
0

サーバーを再起動せずに apache を再起動できます。Mac に apache を再起動する Apple スクリプトがあるので、1 回のクリックと 1/4 秒で新しい apache 構成をロードできます。Python に簡単に移植できる Apple スクリプトを次に示します (Windows で使用するため)。

set stopString to do shell script "sudo /usr/local/apache2/bin/apachectl stop" with administrator privileges and password
set startString to do shell script "sudo /usr/local/apache2/bin/apachectl start" with administrator privileges and password

if startString as string = "" then
    "Apache started correctly"
else
    stopString & " , " & startString
end if
于 2011-01-17T20:19:38.660 に答える