2

I am running PHP Version => 5.3.0

As you can see, I default to turning off php's engine.

1) Can I turn php off by default in httpd.conf globally, in the master virtual host container?

2) I have not tried #1 above, but in the below 'php_value engine on'. When I load any page, it will download the file, and php is effectively off. If I remove the line, then php comes alive.

I can not find docs on this specific setting for 5.3, so I am nut sure this is a bug, or normal behavior.

I would like to default server wide to off, and to have to explicitly enable it for each virtual host, without having to remember to have the line in the virtual host block.

Sample template I have been using...

 <VirtualHost *:80>
    DocumentRoot "/path"
    ServerName example.com
    ServerAlias www.example.com
    DirectoryIndex index.php

    # php setttings
    php_admin_value open_basedir "/path/:/private/var/tmp/:"
    php_value engine off

    <Directory "/path">
        Options FollowSymLinks
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>
 </VirtualHost>

1 Answer 1

2

Yes, you can turn off PHP globally in your Apache httpd configuration and then activate it for some virtual hosts.

Besides actually loading the module with the LoadModule directive, you have to assign the application/x-httpd-php handler to some files or file extensions.

The necessary configuration could look like the following snippet:

<FilesMatch "\.ph(p5?|tml)$">
  SetHandler application/x-httpd-php
</FilesMatch>

This snippet will have mod_php parse files with the extension .php, .php5 and .phtml.

2
  • I have had no luck getting php globally off, php_value engine off httpd.conf. What context does it go into within httpd.conf? I will usually include into httpd.conf users/*.conf and have lastname.firstname.conf for setting up a virtual host for a client. It is in that conf file I would want to php_value engine 1, though so far, none of this works other than per virtual host. I can toggle it on and off per virtual host, but not off server wide, then over-ride to on per virtual host.
    – Anonymous
    Oct 13, 2009 at 4:04
  • The directive php_value engine off can be used anywhere in the main Apache configuration, any Directory, and any VirtualHost block. See php.net/manual/en/configuration.changes.php and php.net/manual/en/apache.configuration.php#ini.engine
    – joschi
    Oct 13, 2009 at 13:10

You must log in to answer this question.