Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
php5 plus php6-cgi, AddHandler only works for .php6
View unanswered posts
View posts from last 24 hours

Reply to topic    Gentoo Forums Forum Index Unsupported Software
View previous topic :: View next topic  
Author Message
Robert Kosten

Joined: 25 Sep 2009
Posts: 6

PostPosted: Sun Nov 29, 2009 11:02 am    Post subject: php5 plus php6-cgi, AddHandler only works for .php6 Reply with quote

I'm running the usual apache2 (2.2.13-r1) php5 (5.2.10-pl2-gentoo) combination, but just for fun I'd like to toy with php6 (php6.0-200911290730) ;-) Following the old tutorial I get all .php files to execute with php5 and all .php6 files with php6, so far so good. I don't use vhosts, so setting up a specific directory for php6 would be nice (PHPEclipse doesn't play nice with the .php6 extension), sadly the method from the tutorial (relying on vhosts) is not applicable. .htaccess would be my usual candidate, but adding AddHandler php6-cgi .php does not work (fantasy extensions, like .php7 do, however!), only removing -D PHP5 causes .php files to be parsed by php6 (not ideal, since I need a few applications that thow a fit under 6). I'm assuming my apache config is simply wrong, but I'm not familiar with it beyond rewrite rules, etc., maybe someone here could help me?

/etc/apache2/httpd.conf (symlink /etc/apache2/apache2.conf)
# This is a modification of the default Apache 2.2 configuration file
# for Gentoo Linux.                                                 
# Support:                                                           
#   [mailing lists]       
#                 [web forums]           
#   irc://      [irc chat]             
# Bug Reports:                                                       
#                    [gentoo related bugs] 
#   [apache httpd related bugs]
# This is the main Apache HTTP server configuration file.  It contains the
# configuration directives that give the server its instructions.         
# See <URL:> for detailed information.   
# In particular, see                                                     
# <URL:>             
# for a discussion of each configuration directive.                       
# Do NOT simply read the instructions in here without understanding       
# what they do.  They're here only as hints or reminders.  If you are unsure
# consult the online docs. You have been warned.                           
# Configuration and logfile names: If the filenames you specify for many   
# of the server's control files begin with "/" (or "drive:/" for Win32), the
# server will use that explicit path.  If the filenames do *not* begin     
# with "/", the value of ServerRoot is prepended -- so "var/log/apache2/foo_log"
# with ServerRoot set to "/usr" will be interpreted by the                     
# server as "/usr/var/log/apache2/foo.log".                                     

# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.                     
# Do not add a slash at the end of the directory path.  If you point
# ServerRoot at a non-local disk, be sure to point the LockFile directive
# at a local disk.  If you wish to share the same ServerRoot for multiple
# httpd daemons, you will need to change at least LockFile and PidFile. 
ServerRoot "/usr/lib64/apache2"                                         

# Dynamic Shared Object (DSO) Support
# To be able to use the functionality of a module which was built as a DSO you
# have to place corresponding `LoadModule' lines at this location so the     
# directives contained in it are actually available _before_ they are used.   
# Statically compiled modules (those listed by `httpd -l') do not need       
# to be loaded here.                                                         
# Example:                                                                   
# LoadModule foo_module modules/                                   
# GENTOO: Automatically defined based on APACHE2_MODULES USE_EXPAND variable.
#         Do not change manually, it will be overwritten on upgrade.         
# The following modules are considered as the default configuration.         
# If you wish to disable one of them, you may have to alter other             
# configuration directives.                                                   
# Change these at your own risk!                                             

LoadModule actions_module modules/
LoadModule alias_module modules/   
LoadModule auth_basic_module modules/
LoadModule authn_alias_module modules/
LoadModule authn_anon_module modules/ 
LoadModule authn_dbm_module modules/   
LoadModule authn_default_module modules/
LoadModule authn_file_module modules/     
LoadModule authz_dbm_module modules/       
LoadModule authz_default_module modules/
LoadModule authz_groupfile_module modules/
LoadModule authz_host_module modules/         
LoadModule authz_owner_module modules/       
LoadModule authz_user_module modules/         
LoadModule autoindex_module modules/           
<IfDefine CACHE>                                               
LoadModule cache_module modules/                   
LoadModule cgi_module modules/                       
<IfDefine DAV>                                                 
LoadModule dav_module modules/                       
<IfDefine DAV>                                                 
LoadModule dav_fs_module modules/                 
<IfDefine DAV>                                                 
LoadModule dav_lock_module modules/             
LoadModule deflate_module modules/               
LoadModule dir_module modules/                       
<IfDefine CACHE>                                               
LoadModule disk_cache_module modules/         
LoadModule env_module modules/                       
LoadModule expires_module modules/               
LoadModule ext_filter_module modules/         
<IfDefine CACHE>                                               
LoadModule file_cache_module modules/         
LoadModule filter_module modules/                 
LoadModule headers_module modules/               
LoadModule include_module modules/               
<IfDefine INFO>                                                 
LoadModule info_module modules/                     
LoadModule log_config_module modules/         
LoadModule logio_module modules/                   
<IfDefine CACHE>                                               
LoadModule mem_cache_module modules/           
LoadModule mime_module modules/                     
LoadModule mime_magic_module modules/         
LoadModule negotiation_module modules/       
LoadModule rewrite_module modules/               
LoadModule setenvif_module modules/             
LoadModule speling_module modules/               
<IfDefine SSL>                                                 
LoadModule ssl_module modules/                       
<IfDefine STATUS>                                               
LoadModule status_module modules/                 
LoadModule unique_id_module modules/           
<IfDefine USERDIR>                                             
LoadModule userdir_module modules/               
<IfDefine PHP6CGI>                                             
## This block will allow execution of php-cgi                   
<Directory /usr/local/bin>                                     
        <files php-cgi>                                         
                allow from all                                 
                options execcgi

LoadModule usertrack_module modules/
LoadModule vhost_alias_module modules/

# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
User apache
Group apache

# Supplemental configuration
# Most of the configuration files in the /etc/apache2/modules.d/ directory can
# be turned on using APACHE2_OPTS in /etc/conf.d/apache2 to add extra features
# or to modify the default configuration of the server.
# To know which flag to add to APACHE2_OPTS, look at the first line of the
# the file, which will usually be an <IfDefine OPTION> where OPTION is the
# flag to use.
Include /etc/apache2/modules.d/*.conf

# Virtual-host support
# Gentoo has made using virtual-hosts easy. In /etc/apache2/vhosts.d/ we
# include a default vhost (enabled by adding -D DEFAULT_VHOST to
# APACHE2_OPTS in /etc/conf.d/apache2).
Include /etc/apache2/vhosts.d/*.conf

# vim: ts=4 filetype=apache

# handler for PHP 6 scripts
<IfDefine PHP6CGI>
    ScriptAlias /php6-cgi /usr/local/bin/php-cgi
    Action php6-cgi /php6-cgi
    AddHandler php6-cgi .php6

<IfDefine PHP5>
        # Load the module first
        <IfModule !mod_php5.c>
                LoadModule php5_module    modules/

        # Set it to handle the files
        <FilesMatch "\.ph(p5?|tml)$">
                SetHandler application/x-httpd-php

        <FilesMatch "\.phps$">
                SetHandler application/x-httpd-php-source

        DirectoryIndex index.php index.phtml

/etc/apache2/vhosts.d/00_default_vhost.conf (edited just to not forget it should I switch to using vhosts after all)
# Virtual Hosts                                               
# If you want to maintain multiple domains/hostnames on your   
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below. 
# Please see the documentation at                                           
# <URL:>                             
# for further details before you try to setup virtual hosts.                 
# You may use the command line option '-S' to verify your virtual host       
# configuration.                                                             

# see bug #178966 why this is in here

# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>       
# directive.                                                       
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses.       
Listen 80                                                         

# Use name-based virtual hosting.
NameVirtualHost *:80

# When virtual hosts are enabled, the main host defined in the default
# httpd.conf configuration will go away. We redefine it here so that it is
# still available.
# If you disable this vhost by removing -D DEFAULT_VHOST from
# /etc/conf.d/apache2, the first defined virtual host elsewhere will be
# the default.
<VirtualHost *:80>
        ServerName localhost
        Include /etc/apache2/vhosts.d/default_vhost.include

        <IfModule mpm_peruser_module>
                ServerEnvironment apache apache

<IfDefine PHP6CGI>
# Add handler for PHP6-enabled scripts
        <IfDefine PHP6CGI>
            ScriptAlias /php6-cgi /usr/local/bin/php-cgi
            Action php6-cgi /php6-cgi
            AddHandler php6-cgi .php6

        <Location /php6>
            AddHandler php6-cgi .php


# vim: ts=4 filetype=apache
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Unsupported Software All times are GMT
Page 1 of 1

Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum