LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > SUSE / openSUSE
User Name
Password
SUSE / openSUSE This Forum is for the discussion of Suse Linux.

Notices


Reply
  Search this Thread
Old 06-05-2007, 06:56 PM   #1
ssa2204
LQ Newbie
 
Registered: Aug 2006
Posts: 12

Rep: Reputation: 0
Apache Vhosts And Separate Logs


I have been trying to set up Apache to log to individual files for each virtual host. Either I get Apache to run without separate logs, or Apache fails to load. I have tried just about everything, but nothing seems to work.

With the config I have below, I am now able to get vhosts working, just not logging the way I want it. I get get to each website no problem. Problem may be that I was using both Yast to initially set up vhosts, while also reading the docs on Apache's site which confused me more. At the moment, the log file will be created, just no data is inserted. Everything is still going to var/log/apache2/access_log

Here is my config:
apache2/conf.d/vhosts.conf
<VirtualHost *:80>
ServerAdmin webmaster@my-domain1.com
DocumentRoot /srv/www/htdocs/
ServerName www.my-domain1.com
ServerAlias www.my-domain1.com
ErrorLog /var/log/apache2/www.my-domain1.com-error_log
CustomLog /var/log/apache2/www.my-domain1.com-access_log common
</VirtualHost>

<VirtualHost *:80>
ServerAdmin webmaster@my-domain2.com
DocumentRoot /srv/www/htdocs/my-domain2
ServerName www.my-domain2.com
ServerAlias www.my-domain2.com
ErrorLog /var/log/apache2/www.my-domain2.com-error_log
CustomLog /var/log/apache2/www.my-domain2.com-access_log common
</VirtualHost>
apache2/vhosts.d/vhosts.conf
<VirtualHost www.my-domain1.com>
DocumentRoot /srv/www/htdocs
ServerName www.my-domain1.com
ServerAdmin www.my-domain1.com
<Directory /srv/www/htdocs>
AllowOverride None
Order allow,deny
Allow from all
DirectoryIndex index.php
</Directory>
ScriptAlias /cgi-bin/ /srv/www/cgi-bin
<Directory /srv/www/cgi-bin>
AllowOverride None
Options +ExecCGI -Includes
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

<VirtualHost www.my-domain2.com>
DocumentRoot /srv/www/htdocs/crm
ServerName www.my-domain2.com
ServerAdmin admin@my-domain2.com
<Directory /srv/www/htdocs/my-domain2>
AllowOverride None
Order allow,deny
Allow from all
DirectoryIndex index.php
</Directory>
ScriptAlias /cgi-bin/ /srv/www/cgi-bin
<Directory /srv/www/cgi-bin>
AllowOverride None
Options +ExecCGI -Includes
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
 
Old 06-05-2007, 08:40 PM   #2
rtspitz
Member
 
Registered: Jan 2005
Location: germany
Distribution: suse, opensuse, debian, others for testing
Posts: 307

Rep: Reputation: 32
why are there 2 locations for virtualhost configs ?

on opensuse I just have to use sth. like this in /etc/apache2/listen.conf

Code:
NameVirtualHost *:80
and then put a config file for each virtualhost in /etc/apache2/vhosts.d/

those files are processed as they are sorted when using the ls command.
this does matter, as the very first file will be used as the default-server, which matches all requests not directed to other known virtualhosts.


so I use files like:

Code:
 100-default.conf
101-domain-a.conf
102-domain-b.conf

100-default.conf:

this "new" default server will log to the usual log-files of apache2.

Code:
<VirtualHost *:80>
DocumentRoot "/srv/www/htdocs"
<Directory "/srv/www/htdocs">
allow from all
Options +Indexes
</Directory>
</VirtualHost>

101-domain-a.conf:

Code:
#
# VirtualHost template
# Note: to use the template, rename it to /etc/apache2/vhost.d/yourvhost.conf.
# Files must have the .conf suffix to be loaded.
#
# See /usr/share/doc/packages/apache2/README.QUICKSTART for further hints
# about virtual hosts.
#
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#
<VirtualHost *:80>
    ServerAdmin not-yet@nowhere.coma
    ServerName www.domain-a.com

    # DocumentRoot: The directory out of which you will serve your
    # documents. By default, all requests are taken from this directory, but
    # symbolic links and aliases may be used to point to other locations.
    DocumentRoot /srv/www/vhosts/www.domain-a.com/htdocs

    # if not specified, the global error log is used
    ErrorLog /var/log/apache2/www.domain-a.com-error_log
    CustomLog /var/log/apache2/www.domain-a.com-access_log combined

    # don't loose time with IP address lookups
    HostnameLookups Off

    # needed for named virtual hosts
    UseCanonicalName Off

    # configures the footer on server-generated documents
    ServerSignature On


    # Optionally, include *.conf files from /etc/apache2/conf.d/
    #
    # For example, to allow execution of PHP scripts:
    #
    # Include /etc/apache2/conf.d/mod_php4.conf
    #
    # or, to include all configuration snippets added by packages:
    # Include /etc/apache2/conf.d/*.conf


    # ScriptAlias: This controls which directories contain server scripts.
    # ScriptAliases are essentially the same as Aliases, except that
    # documents in the realname directory are treated as applications and
    # run by the server when requested rather than as documents sent to the client.
    # The same rules about trailing "/" apply to ScriptAlias directives as to
    # Alias.
    #
    ScriptAlias /cgi-bin/ "/srv/www/vhosts/www.domain-a.com/cgi-bin/"


    # "/srv/www/cgi-bin" should be changed to whatever your ScriptAliased
    # CGI directory exists, if you have one, and where ScriptAlias points to.
    #
    <Directory "/srv/www/vhosts/www.domain-a.com/cgi-bin">
        AllowOverride None
        Options +ExecCGI -Includes
        Order allow,deny
        Allow from all
    </Directory>


    #
    # This should be changed to whatever you set DocumentRoot to.
    #
    <Directory "/srv/www/vhosts/www.domain-a.com/htdocs">

        #
        # Possible values for the Options directive are "None", "All",
        # or any combination of:
        #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
        #
        # Note that "MultiViews" must be named *explicitly* --- "Options All"
        # doesn't give it to you.
        #
        # The Options directive is both complicated and important.  Please see
        # http://httpd.apache.org/docs-2.0/mod/core.html#options
        # for more information.
        #
        Options -Indexes -FollowSymLinks +SymLinksIfOwnerMatch +Includes
        XBitHack on

        #
        # AllowOverride controls what directives may be placed in .htaccess files.
        # It can be "All", "None", or any combination of the keywords:
        #   Options FileInfo AuthConfig Limit
        #
        #AllowOverride None
        AllowOverride All

        #
        # Controls who can get stuff from this server.
        #
        Order allow,deny
        Allow from all

    </Directory>

</VirtualHost>

Last edited by rtspitz; 06-05-2007 at 08:48 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
PORTSENTRY separate LOGS gabsik Linux - Software 0 05-12-2006 02:35 AM
Firewall and router separate logs gabsik Linux - Networking 2 04-17-2006 03:53 PM
portsentry separate logs and TCPwrappers gabsik Linux - Security 5 04-05-2006 09:08 AM
syslogd and named logs - separate file slimak Debian 3 11-16-2004 02:51 AM
Separate firewall logs and general logs dominant Linux - General 3 04-20-2004 02:26 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > SUSE / openSUSE

All times are GMT -5. The time now is 07:35 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration