Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have an Apache server with multiple webprojects. Every project has a development, and a production site associated like this:

/srv/www/project1/dev 
/srv/www/project1/prod

/srv/www/project2/dev
/srv/www/project2/prod

/srv/www/project3/dev
/srv/www/project3/prod

Every project also has a virtual-host file - this is for project 1:

# Prod
<VirtualHost 123.45.789.123:80>
    ServerAdmin john@doe.com
ServerName www.johndoe.com
DocumentRoot /srv/www/project1/dev
</VirtualHost>

# Dev
<VirtualHost 123.45.789.123:80>
    ServerAdmin john@doe.com
    ServerName dev.johndoe.com
DocumentRoot /srv/www/project1/dev

    # enable php error_reporting for development site
<Directory /srv/www/project1/dev>
    <IfModule mod_php5.c>
        php_value error_reporting 214748364
        php_flag display_errors 1
    </IfModule>
</Directory>
</VirtualHost>

Everything is working fine like this. However, I find it redundant to add the IfModule mod_php5.c part to all virtual hosts. Is it possible to add it to the default virtual host file like this (I've tried, and can't make it work):

    <DirectoryMatch "^/srv/www/.+/dev">
            <IfModule mod_php5.c>
                    php_value error_reporting 214748364
                    php_flag display_errors 1
            </IfModule>
    </DirectoryMatch>

Looking forward to hear your input!

share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

Add your <DirectoryMatch> block directly to the server config, don't put it inside a <VirtualHost> block. Check here for more information about the scope of this directive: http://httpd.apache.org/docs/2.2/mod/core.html#directorymatch

share|improve this answer
    
Excellent, thank you! –  sqren Jul 10 '11 at 15:44
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.