2

サイトごとのApacheログ(アクセスとエラー)とホストごとのphp変数の割り当てを許可するようにApacheを構成したいと思います。私は単一のドメインを持っており、すべてのサイトはそれを介してアクセスされます。

http:// domain / site1
http:// domain / site2
..。

このようにAliasディレクティブを使用する場合...

エイリアス/site1/ var / www / vhosts / httpdocs / site1
エイリアス/site2/ var / www / vhosts / httpdocs / site2

...サイトごとのカスタムログもサイトごとのphp変数も設定できません。

だから私はVirtualHostディレクティブを使ってみましたが、それを動作させることができません。各仮想ホストのServerAliasでdomain/site1を使用してみましたが、機能しません。また、 VirtualHostディレクティブに/ site1を直接 追加しようとしましたが、許可されていないと思います。私はたくさんの組み合わせを試しましたが、何も機能しません。VirtuaHostsが複数のドメインの使用に焦点を合わせていることは知っていますが、このシナリオには解決策があると思います。

Directory drectiveも試しましたが、CustomLogをその中に入れることはできません。何か案は?

助けてくれてありがとう。

Aitor

4

1 に答える 1

0

$HTTP_PATH/conf.d/vhost.confApache Webサーバーのメイン構成ファイルに含まれているvhost定義を挿入しました$HTTP_PATH/conf/httpd.confか?

phpとの統合を確認しましたhttpd.confか?phpモジュールなどを読み込んでいます。

php.iniアプリケーション.htaccessphp要件に関してファイルを確認しましたか?

サーバー上の任意のホスト名でサイトにアクセスできない限り、エイリアスを作成することは本当に悪い方法です...しかし、それが検索エンジンのスコアを確実に下げることを忘れないでください。

/ var / log / httpd / error_logを差し引いて、詳細をお知らせください。

あなたはそれを得ることができますtail -f /path/to/error/log

追加: httpdモジュールを見ることができますmod_log_config。デフォルトのログ行は次のようにフォーマットされています。

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined 

次のように変更します。

LogFormat "%v %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined

%vは、ログ内に仮想ホストの名前を挿入します。これらの名前は、以下に示すパーサーによって表示およびフィルタリングされます。

そして、apache Webサーバーで配布されているスクリプトを使用して、virtualhostsで分離されたログファイルを取得します/src/support/split-logfile.pl

#!/usr/bin/perl
#
# ====================================================================
# Copyright (c) 1995-1998 The Apache Group.  All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer. 
#
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in
#    the documentation and/or other materials provided with the
#    distribution.
#
# 3. All advertising materials mentioning features or use of this
#    software must display the following acknowledgment:
#    "This product includes software developed by the Apache Group
#    for use in the Apache HTTP server project (http://www.apache.org/)."
#
# 4. The names "Apache Server" and "Apache Group" must not be used to
#    endorse or promote products derived from this software without
#    prior written permission.  For permission please contact
#    Apache@Apache.Org.
#
# 5. Products derived from this software may not be called "Apache"
#    nor may "Apache" appear in their names without prior written
#    permission of the Apache Group.
#
# 6. Redistributions of any form whatsoever must retain the following
#    acknowledgment:
#    "This product includes software developed by the Apache Group
#    for use in the Apache HTTP server project (http://www.apache.org/)."
#
# THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
# EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE APACHE GROUP OR
# ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
# OF THE POSSIBILITY OF SUCH DAMAGE.
# ====================================================================
#
# This software consists of voluntary contributions made by many
# individuals on behalf of the Apache Group and was originally based
# on public domain software written at the National Center for
# Supercomputing Applications, University of Illinois, Urbana-Champaign.
# For more information on the Apache Group and the Apache HTTP server
# project, please see <http://www.apache.org/>.
#

#
# This script will take a combined Web server access
# log file and break its contents into separate files.
# It assumes that the first field of each line is the
# virtual host identity (put there by "%v"), and that
# the logfiles should be named that+".log" in the current
# directory.
#
# The combined log file is read from stdin. Records read
# will be appended to any existing log files.
#
%is_open = ();

while ($log_line = <STDIN>) {
    #
    # Get the first token from the log record; it's the
    # identity of the virtual host to which the record
    # applies.
    #
    ($vhost) = split (/\s/, $log_line);
    #
    # Normalize the virtual host name to all lowercase.
    # If it's blank, the request was handled by the default
    # server, so supply a default name.  This shouldn't
    # happen, but caution rocks.
    #
    $vhost = lc ($vhost) or "access";
    #
    # If the log file for this virtual host isn't opened
    # yet, do it now.
    #
    if (! $is_open{$vhost}) {
        open $vhost, ">>${vhost}.log"
            or die ("Can't open ${vhost}.log");
        $is_open{$vhost} = 1;
    }
    #
    # Strip off the first token (which may be null in the
    # case of the default server), and write the edited
    # record to the current log file.
    #
    $log_line =~ s/^\S*\s+//;
    printf $vhost "%s", $log_line;
}
exit 0;

そして、これらが十分でないかどうかを次のlogcronスクリプトで確認できます。これらの記事のテキストに従うことができます。

于 2012-09-11T15:55:59.010 に答える